![]() |
(git:5e7fe52)
|
Assembly of complex k-point operators from real-space DBCSR matrices. The output is a complex full matrix on the distribution of the k-point group. The module splits this work into a start step and a finish step. One process can start the MPI transfers of many operators before it finishes any of them. The STANDARD k-point driver uses this order. The routines start, finish and get are collective over the environment-wide communicator. Every rank must call the same sequence of service calls. A context references its host kpoint environment without owning it, so it must not outlive that environment. The calls are not thread safe: the caller must serialize them, because their collective communication tolerates no concurrent service call. A separate context per thread only keeps the scratch from aliasing. More...
Data Types | |
| type | kpoint_operator_context_type |
| Caller-owned assembly context for one driver call. Created and released in the same driver routine and passed to helpers as an argument; never stored on the host kpoint_type. Components are private and touched only by this module. More... | |
Functions/Subroutines | |
| subroutine | kpoint_operator_densify (rsmat, matrix_row, ik, xkp, cell_to_index, sab_nl, grid, use_grid, rmatrix, cmatrix, tmpmat, fm_re, fm_im) |
| Transform one real-space operator to one k point and densify the result: the real part into fm_re and the imaginary part into fm_im. Densify means: copy the blocks of a DBCSR matrix into a full matrix. Stateless: fills caller-provided scratch. | |
| subroutine, public | kpoint_operator_cfm_to_mo (cmat, mo_re, mo_im, eigenvalues) |
| Split a complex matrix into the real and imaginary MO sets and copy the eigenvalues to the imaginary set. | |
| subroutine, public | kpoint_operator_context_create (ctx, kpoints, ao_ao_fm, nspin) |
| Create an empty operator context. The context owns no buffers after this call; they are created on first use and released with the context. | |
| subroutine, public | kpoint_operator_context_release (ctx) |
| Release the context together with every buffer it created. Call once, at the exit of the routine that created the context. Every started instance must be idle at this point. The call aborts when a transfer is still in flight, because nothing would ever wait for its MPI requests. | |
| subroutine, public | kpoint_operator_start (ctx, ikp, ispin, rsmat, slot, grid, use_grid, matrix_row) |
| Start the assembly of one operator for one local k point and spin and launch its transfers to every k-point group. The caller index ikp is local; the walk over groups happens here, so no caller can express a group-local loop. Finish every started instance with kpoint_operator_finish. The first start also creates the slot bookkeeping of the context. Collective over the environment-wide communicator: every rank must call the same sequence of service calls. | |
| subroutine, public | kpoint_operator_finish (ctx, ikp, ispin, slot, cmat) |
| Finish the transfers of one started instance: on the group that owns the k point, merge the received parts into cmat (real part first, overwrite then add); on every group, reclaim the send side. The slot returns to idle. Collective over the environment-wide communicator: every rank must call the same sequence of service calls. | |
| subroutine, public | kpoint_operator_get (ctx, ikp, ispin, rsmat, cmat, fm_re, fm_im, mat_re, mat_im, matrix_row) |
| Assemble one operator for one local k point and spin in one call: run the single-group transfer of the service for every group and finish it immediately, through transfer states local to this call. The persistent slot machinery stays with start and finish. Exactly one output flavor must be present: cmat receives the complex operator (real part overwrites, imaginary part adds) through the context buffer; the fm pair receives the two parts separately, transferred directly into fm_re and fm_im on the owning group (any distribution: the general copy redistributes); or the dbcsr pair receives the two parts as block-cyclic matrices built by the service, replacing the caller-side copy_fm_to_dbcsr_bc detour. The dbcsr matrices must be freshly initialized (dbcsr_init_p) and the cmat flavor must share the distribution of the k-point group. Collective over the environment-wide communicator: every rank must call the same sequence of service calls. | |
Variables | |
| integer, parameter, public | kpoint_slot_ks = 1 |
| integer, parameter, public | kpoint_slot_s = 2 |
| integer, parameter, public | kpoint_slot_t = 3 |
| integer, parameter, public | kpoint_spin_free = 1 |
| Row of rsmat that carries the spin-free operator image. S and T carry no spin copies: drivers launch one instance per spin of their loop and read this same row in every instance. | |
Assembly of complex k-point operators from real-space DBCSR matrices. The output is a complex full matrix on the distribution of the k-point group. The module splits this work into a start step and a finish step. One process can start the MPI transfers of many operators before it finishes any of them. The STANDARD k-point driver uses this order. The routines start, finish and get are collective over the environment-wide communicator. Every rank must call the same sequence of service calls. A context references its host kpoint environment without owning it, so it must not outlive that environment. The calls are not thread safe: the caller must serialize them, because their collective communication tolerates no concurrent service call. A separate context per thread only keeps the scratch from aliasing.
| subroutine qs_kpoint_operators::kpoint_operator_densify | ( | type(dbcsr_p_type), dimension(:, :), pointer | rsmat, |
| integer, intent(in) | matrix_row, | ||
| integer, intent(in) | ik, | ||
| real(kind=dp), dimension(3), intent(in) | xkp, | ||
| integer, dimension(:, :, :), pointer | cell_to_index, | ||
| type(neighbor_list_set_p_type), dimension(:), pointer | sab_nl, | ||
| type(rskp_grid_type), intent(in), optional | grid, | ||
| logical, intent(in) | use_grid, | ||
| type(dbcsr_type) | rmatrix, | ||
| type(dbcsr_type) | cmatrix, | ||
| type(dbcsr_type) | tmpmat, | ||
| type(cp_fm_type) | fm_re, | ||
| type(cp_fm_type) | fm_im ) |
Transform one real-space operator to one k point and densify the result: the real part into fm_re and the imaginary part into fm_im. Densify means: copy the blocks of a DBCSR matrix into a full matrix. Stateless: fills caller-provided scratch.
| rsmat | real-space image matrices of the operator |
| matrix_row | row of rsmat to transform (kpoint_spin_free for spin-free matrices such as S) |
| ik | global k-point index |
| xkp | coordinates of this k point |
| cell_to_index | mapping of cell indices to real-space index |
| sab_nl | neighbor lists defining the real-space sparsity |
| grid | prepared reciprocal-grid cache of the caller. Required when use_grid is set |
| use_grid | extract from grid instead of a direct phase sum |
| rmatrix | symmetric DBCSR workspace holding the real part of the k-point matrix |
| cmatrix | antisymmetric DBCSR workspace holding the imaginary part of the k-point matrix |
| tmpmat | unsymmetric DBCSR workspace |
| fm_re | full-matrix workspace holding the real part |
| fm_im | full-matrix workspace holding the imaginary part |
Definition at line 156 of file qs_kpoint_operators.F.
| subroutine, public qs_kpoint_operators::kpoint_operator_cfm_to_mo | ( | type(cp_cfm_type) | cmat, |
| type(mo_set_type) | mo_re, | ||
| type(mo_set_type) | mo_im, | ||
| real(kind=dp), dimension(:) | eigenvalues ) |
Split a complex matrix into the real and imaginary MO sets and copy the eigenvalues to the imaginary set.
| cmat | complex MO coefficients |
| mo_re | real part MO set |
| mo_im | imaginary part MO set |
| eigenvalues | eigenvalues of mo_re, copied to mo_im |
Definition at line 314 of file qs_kpoint_operators.F.
| subroutine, public qs_kpoint_operators::kpoint_operator_context_create | ( | type(kpoint_operator_context_type), intent(out) | ctx, |
| type(kpoint_type), pointer | kpoints, | ||
| type(cp_fm_type), intent(in) | ao_ao_fm, | ||
| integer, intent(in) | nspin ) |
Create an empty operator context. The context owns no buffers after this call; they are created on first use and released with the context.
| ctx | context to initialize |
| kpoints | host k-point environment, referenced, not copied |
| ao_ao_fm | any square full matrix on the environment-wide communicator; its matrix struct is the template for the context work buffers, which densify on the source side of transfers that cross into the k-point groups |
| nspin | instance spin space of the owning driver call: the bound of the spin loop its start and finish calls iterate. Fixed for the lifetime of the context |
Definition at line 350 of file qs_kpoint_operators.F.
| subroutine, public qs_kpoint_operators::kpoint_operator_context_release | ( | type(kpoint_operator_context_type), intent(inout) | ctx | ) |
Release the context together with every buffer it created. Call once, at the exit of the routine that created the context. Every started instance must be idle at this point. The call aborts when a transfer is still in flight, because nothing would ever wait for its MPI requests.
| ctx | context to release |
Definition at line 385 of file qs_kpoint_operators.F.
| subroutine, public qs_kpoint_operators::kpoint_operator_start | ( | type(kpoint_operator_context_type), intent(inout) | ctx, |
| integer, intent(in) | ikp, | ||
| integer, intent(in) | ispin, | ||
| type(dbcsr_p_type), dimension(:, :), pointer | rsmat, | ||
| integer, intent(in) | slot, | ||
| type(rskp_grid_type), intent(in), optional | grid, | ||
| logical, intent(in) | use_grid, | ||
| integer, intent(in) | matrix_row ) |
Start the assembly of one operator for one local k point and spin and launch its transfers to every k-point group. The caller index ikp is local; the walk over groups happens here, so no caller can express a group-local loop. Finish every started instance with kpoint_operator_finish. The first start also creates the slot bookkeeping of the context. Collective over the environment-wide communicator: every rank must call the same sequence of service calls.
| ctx | context created by kpoint_operator_context_create |
| ikp | local k-point index within kp_range |
| ispin | instance spin: keys the bookkeeping |
| rsmat | real-space image matrices of the operator, read at start time only. The matching finish does not read them |
| slot | destination slot of the operator (one of kpoint_slot_ks/s/t); the slot must be idle |
| grid | prepared reciprocal-grid cache of the caller |
| use_grid | extract from grid instead of a direct phase sum |
| matrix_row | row of rsmat to transform. Spin-free operators such as S and T must pass kpoint_spin_free: their first matrix dimension counts derivatives, not spins. A spin index is out of bounds in plain SCF, but with derivatives stored it reads another valid row silently |
Definition at line 515 of file qs_kpoint_operators.F.
| subroutine, public qs_kpoint_operators::kpoint_operator_finish | ( | type(kpoint_operator_context_type), intent(inout) | ctx, |
| integer, intent(in) | ikp, | ||
| integer, intent(in) | ispin, | ||
| integer, intent(in) | slot, | ||
| type(cp_cfm_type) | cmat ) |
Finish the transfers of one started instance: on the group that owns the k point, merge the received parts into cmat (real part first, overwrite then add); on every group, reclaim the send side. The slot returns to idle. Collective over the environment-wide communicator: every rank must call the same sequence of service calls.
| ctx | context that started the instance |
| ikp | local k-point index of the start call |
| ispin | spin component of the start call |
| slot | slot of the start call; the slot must be in flight |
| cmat | caller-allocated complex matrix that receives the operator. It must share the distribution of the k-point group |
Definition at line 603 of file qs_kpoint_operators.F.
| subroutine, public qs_kpoint_operators::kpoint_operator_get | ( | type(kpoint_operator_context_type), intent(inout) | ctx, |
| integer, intent(in) | ikp, | ||
| integer, intent(in) | ispin, | ||
| type(dbcsr_p_type), dimension(:, :), pointer | rsmat, | ||
| type(cp_cfm_type), optional | cmat, | ||
| type(cp_fm_type), optional | fm_re, | ||
| type(cp_fm_type), optional | fm_im, | ||
| type(dbcsr_type), intent(inout), optional | mat_re, | ||
| type(dbcsr_type), intent(inout), optional | mat_im, | ||
| integer, intent(in) | matrix_row ) |
Assemble one operator for one local k point and spin in one call: run the single-group transfer of the service for every group and finish it immediately, through transfer states local to this call. The persistent slot machinery stays with start and finish. Exactly one output flavor must be present: cmat receives the complex operator (real part overwrites, imaginary part adds) through the context buffer; the fm pair receives the two parts separately, transferred directly into fm_re and fm_im on the owning group (any distribution: the general copy redistributes); or the dbcsr pair receives the two parts as block-cyclic matrices built by the service, replacing the caller-side copy_fm_to_dbcsr_bc detour. The dbcsr matrices must be freshly initialized (dbcsr_init_p) and the cmat flavor must share the distribution of the k-point group. Collective over the environment-wide communicator: every rank must call the same sequence of service calls.
| ctx | context created by kpoint_operator_context_create |
| ikp | local k-point index within kp_range |
| ispin | instance spin: bounds-checked against the context spin space |
| rsmat | real-space image matrices of the operator |
| cmat | complex matrix output |
| fm_re | real-part matrix output |
| fm_im | imaginary-part matrix output |
| mat_re | real-part block-cyclic dbcsr output |
| mat_im | imaginary-part block-cyclic dbcsr output |
| matrix_row | row of rsmat to transform. Spin-free operators such as S and T must pass kpoint_spin_free: their first matrix dimension counts derivatives, not spins. A spin index is out of bounds in plain SCF, but with derivatives stored it reads another valid row silently |
Definition at line 678 of file qs_kpoint_operators.F.
| integer, parameter, public qs_kpoint_operators::kpoint_slot_ks = 1 |
Definition at line 73 of file qs_kpoint_operators.F.
| integer, parameter, public qs_kpoint_operators::kpoint_slot_s = 2 |
Definition at line 73 of file qs_kpoint_operators.F.
| integer, parameter, public qs_kpoint_operators::kpoint_slot_t = 3 |
Definition at line 73 of file qs_kpoint_operators.F.
| integer, parameter, public qs_kpoint_operators::kpoint_spin_free = 1 |
Row of rsmat that carries the spin-free operator image. S and T carry no spin copies: drivers launch one instance per spin of their loop and read this same row in every instance.
Definition at line 80 of file qs_kpoint_operators.F.