C++ Lab Course - Seminar topics
C++ Lab Course - Seminar topics
C++ Lab Course - Seminar topics
Create successful ePaper yourself
Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.
Computational physics<br />
<strong>C++</strong> <strong>Lab</strong> <strong>Course</strong> - <strong>Seminar</strong> <strong>topics</strong><br />
Armin Scrinzi
Chapter 1<br />
<strong>C++</strong> course project — single particle<br />
TDSE code<br />
We have discussed several important building blocks of a <strong>C++</strong> code. During the rest of the course,<br />
we will together build a functioning and extendable code to solve the time-dependent Schrödinger<br />
equation.<br />
1.1 Features<br />
• Bound states solver for general potentials, including truely 2d problems: atomic models, trap<br />
potentials(?), quantum dots,. . .<br />
• Resonance states for general potentials<br />
• Scattering states and cross-sections<br />
• Interaction with dipole fields: Stark effect and ionization rates<br />
1.2 Technical properties<br />
• General coordinate systems<br />
• General (basis set) discretizations: finite elements, gaussian, spherical harmonics, FFT (plane<br />
waves)<br />
• Linear algebra: LAPACK, <strong>C++</strong> packages, ARPACK<br />
• “Complex scaling” (for resonances and Stark effect)<br />
• Parallel: MPI, PETSC<br />
1.3 Tasks & grades<br />
We will try to reach this goal together. For that, tasks will be assigned to each team. The teams<br />
will present the results in the course. In these presentations, the team jointly present their solution,<br />
each member of the team should actively participate. The presentation is a prerequisit for getting<br />
the course credited. At the end of the course there will be an exam, where a small programming task<br />
will be assigned to everybody. Grades for the course will be based 50% on the team performance,<br />
50% on the final exam.<br />
Please, from the following list of tasks, pick one for your team. Each task will be formulated<br />
by me in python. (Several solutions already exist in python, others will be presented during the<br />
next 2 weeks.) Your task mostly is to “translate” the python code into <strong>C++</strong>. Please, supply a<br />
3
list of at least 3 tasks you would like to do, indicating your priorities. Assignement will be on a<br />
first-come-first-serve basis and according to your priorities. Tasks that are not picked, will be taken<br />
by us (Nina and Armin), such that at the end of a course, we have a functioning code that will be<br />
available for all and serve as a model for your future programming.<br />
Presentations start on June 5 (maximal 7 presentations).<br />
1.3.1 List of tasks<br />
1. Interface matrix class to LAPACK routines (for fast algorithms)<br />
2. Tensor class<br />
3. Wave function class<br />
4. Potential module<br />
5. Timer routines<br />
6. Operator class: tensor product operators<br />
7. Operator class: general potentials<br />
8. Time propagator class<br />
9. Read input, I/O<br />
1.3.2 Detailed description of tasks<br />
Extension of Matrix.h<br />
Starting from Matrix.h:<br />
• Build interface to the eigenvalue package into Matrix.h<br />
• Diagonal and banded matrices<br />
• Build interface to linear system solving package for full and banded matrices (a <strong>C++</strong> package<br />
will be supplied)<br />
Tensor class<br />
• Generalize the definition of a tensor from the tensor products to any linear map on the product<br />
space. The application for this are interaction operators:<br />
T (⃗a ⊗ ⃗ b) = ∑ ln<br />
T km,ln a l b n<br />
where T may be a tensor product or a 4-index object (like the interaction potential).<br />
• Implement the application of a tensor to a vector:<br />
[(A ⊗ B)⃗c] km = ∑ ln<br />
A kl A mn c ln<br />
• Generalize to 3-fold (or n-fold if you like) tensor products<br />
4
Wave function class<br />
A wave function is the following object<br />
• It has up to three coordinate axes which also defines a discretization by a product basis (the<br />
axis class will be supplied)<br />
• It has a time<br />
• We can form the scalar product of two wave functions.<br />
• We can apply the overlap matrix and the inverse of the overlap matrix to the wave function.<br />
Operator class<br />
Operator representations on product basis sets. This is an important and large class, the task can<br />
be split into smaller parts.<br />
• An operator is constructed given a set of axes and a string that defines the operator. A typical<br />
string could be the kinetic energy in 2-d polar coordinates φ, ρ in the tensor-product form<br />
kin = ’+1/2(|)x(d|d) +1(d|d)x(|1/q^2|)’<br />
or general potentials, e.g the harmonic oscillator:<br />
pot = ’harmonic(kappax,kappay)’<br />
for<br />
pot(x, y) = κ x x 2 + κ y y 2<br />
• An operator can be applied to a wave function, the result is a wave function.<br />
• Operators on finite-element basis sets are stored piecewise for each product of finite elemetns.<br />
• Tensor product operators are stored as the individual factors.<br />
• Potentials are stored by their values on quadrature points and by the transformation matrices<br />
from the basis set to the quadrature points (compare the discussion of DVR).<br />
Timer routines<br />
Functionality like in “mytimer.py”: find <strong>C++</strong> class with this functionality or translate the python<br />
code. We want<br />
• Minimal timer overhead — timer operation must be fast!<br />
• Option to switch off the timer (to reduce any possible overhead to the absolute mininum).<br />
• Progress monitor: let the timer print a “.” or “-” if more than n seconds that have elapsed<br />
since it was last called last time.<br />
Time propagator class<br />
A time-propagator takes as an argument and operator, wave function, a new time, and an accuracy<br />
parameter. Advances the wave function from its current time to the new time by solving the TDSE<br />
with the given operator. Controls the accuracy.<br />
5
Read input I/O<br />
Translate the python read input.py into <strong>C++</strong> with a few extra features.<br />
• Check input command sanity: on each call of read_input, record the command string. After<br />
you are through all commands, when calling read_input_finish, check all lines of the input<br />
file for command-like strings: if you find one that does not fit any, stop with the message that<br />
there is a misprint. (You may prototype this in Python, to see the logics at work).<br />
• Read vectors from columns of input, supplement empty entries by defaults.<br />
6