Octopus
td_write.F90
Go to the documentation of this file.
1! Copyright (C) 2002-2006 M. Marques, A. Castro, A. Rubio, G. Bertsch
2!!
3!! This program is free software; you can redistribute it and/or modify
4!! it under the terms of the GNU General Public License as published by
5!! the Free Software Foundation; either version 2, or (at your option)
6!! any later version.
7!!
8!! This program is distributed in the hope that it will be useful,
9!! but WITHOUT ANY WARRANTY; without even the implied warranty of
10!! MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11!! GNU General Public License for more details.
12!!
13!! You should have received a copy of the GNU General Public License
14!! along with this program; if not, write to the Free Software
15!! Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
16!! 02110-1301, USA.
17!!
18
19#include "global.h"
20
21module td_write_oct_m
22 use blas_oct_m
23 use comm_oct_m
25 use debug_oct_m
33 use global_oct_m
34 use grid_oct_m
35 use output_oct_m
44 use io_oct_m
46 use ions_oct_m
47 use kick_oct_m
48 use, intrinsic :: iso_fortran_env
50 use lasers_oct_m
53 use lda_u_oct_m
56 use math_oct_m
59 use mesh_oct_m
62 use mpi_oct_m
67 use parser_oct_m
73 use space_oct_m
83 use types_oct_m
84 use unit_oct_m
86 use utils_oct_m
88 use v_ks_oct_m
90
91 implicit none
92
93 private
94 public :: &
95 td_write_t, &
106
108 integer, parameter, public :: &
109 OUT_MULTIPOLES = 1, &
110 out_angular = 2, &
111 out_spin = 3, &
112 out_populations = 4, &
113 out_coords = 5, &
114 out_acc = 6, &
115 out_laser = 7, &
116 out_energy = 8, &
117 out_proj = 9, &
118 out_magnets = 10, &
119 out_gauge_field = 11, &
120 out_temperature = 12, &
121 out_ftchd = 13, &
122 out_vel = 14, &
123 out_eigs = 15, &
124 out_ion_ch = 16, &
125 out_total_current = 17, &
126 out_partial_charges = 18, &
127 out_kp_proj = 19, &
128 out_floquet = 20, &
129 out_n_ex = 21, &
130 out_separate_coords = 22, &
132 out_separate_forces = 24, &
134 out_tot_m = 26, &
135 out_q = 27, &
136 out_mxll_field = 28, &
137 out_norm_ks = 29, &
138 out_cell_parameters = 30, &
139 ! This constant should always equal the last integer above
140 ! as it defines the total numer of output options
141 out_max = 30
142
143
145 ! Entries must be consistent with the ordering above
146 character(len=100) :: td_file_name(OUT_MAX) = [character(100) :: &
147 "NULL", & ! Do not include OUT_MULTIPOLES (extension is a function of state index)
148 "angular", &
149 "spin", &
150 "populations", &
151 "coordinates", &
152 "acceleration", &
153 "NULL", & ! Do not include OUT_LASER
154 "energy", &
155 "projections", &
156 "magnetic_moments", &
157 "gauge_field", &
158 "temperature", &
159 "NULL", & ! Do not include OUT_FTCHD
160 "velocity", &
161 "eigenvalues", &
162 "ion_ch", &
163 "total_current", &
164 "partial_charges", &
165 "projections", &
166 "floquet_bands", &
167 "n_ex", &
168 "onlyCoordinates", &
169 "onlyVelocities", &
170 "onlyForces", &
171 "total_heat_current", &
172 "total_magnetization", &
173 "photons_q", &
174 "maxwell_dipole_field", &
175 "norm_wavefunctions", &
176 "cell_parameters"]
177
178 integer, parameter :: &
179 OUT_DFTU_EFFECTIVE_U = 1, &
180 out_dftu_max = 1
181
182
183 integer, parameter :: &
184 OUT_MAXWELL_TOTAL_E_FIELD = 1, &
190 out_maxwell_energy = 19, &
197
198 integer, parameter, public :: &
199 OUT_MAXWELL_MAX = 25
200
201 integer, parameter :: &
203 maxwell_long_field = 2, &
205
206 integer, parameter :: &
207 maxwell_e_field = 1, &
209
211 type td_write_prop_t
212 type(c_ptr) :: handle
213 type(c_ptr), allocatable :: mult_handles(:)
214 type(mpi_grp_t) :: mpi_grp
215 integer :: hand_start
216 integer :: hand_end
217 logical :: write = .false.
218 logical :: resolve_states = .false.
219 end type td_write_prop_t
220
224 type td_write_t
225 private
226 type(td_write_prop_t), public :: out(out_max)
227 type(td_write_prop_t) :: out_dftu(out_dftu_max)
228
229 integer :: lmax
230 real(real64) :: lmm_r
231 type(states_elec_t) :: gs_st
232 ! calculate the projections(s) onto it.
233 integer :: td_start_proj
234 integer :: n_excited_states
235 type(excited_states_t), allocatable :: excited_st(:)
236 integer :: compute_interval
237 end type td_write_t
238
239contains
240
241
242 subroutine td_write_kick(outp, namespace, space, mesh, kick, ions, iter)
243 type(output_t), intent(in) :: outp
244 type(namespace_t), intent(in) :: namespace
245 type(electron_space_t), intent(in) :: space
246 class(mesh_t), intent(in) :: mesh
247 type(kick_t), intent(in) :: kick
248 type(ions_t), intent(in) :: ions
249 integer, intent(in) :: iter
250
251 complex(real64), allocatable :: kick_function(:)
252 character(len=256) :: filename
253 integer :: err
254
255 push_sub(td_write_kick)
256
257 write(filename, '(a,i7.7)') "td.", iter ! name of directory
258 if (outp%what(option__output__delta_perturbation)) then
259 safe_allocate(kick_function(1:mesh%np))
260 call kick_function_get(space, mesh, kick, kick_function, 1)
261 call zio_function_output(outp%how(option__output__delta_perturbation), filename, "kick_function", namespace, &
262 space, mesh, kick_function(:), units_out%energy, err, pos=ions%pos, atoms=ions%atom)
263 safe_deallocate_a(kick_function)
264 end if
265
266 pop_sub(td_write_kick)
267 end subroutine td_write_kick
268
269
279 subroutine td_write_init(writ, namespace, space, outp, gr, st, hm, ions, ext_partners, ks, ions_move, &
280 with_gauge_field, kick, iter, max_iter, dt, mc)
281 type(td_write_t), target, intent(out) :: writ
282 type(namespace_t), intent(in) :: namespace
283 type(electron_space_t), intent(in) :: space
284 type(output_t), intent(inout) :: outp
285 type(grid_t), intent(in) :: gr
286 type(states_elec_t), intent(inout) :: st
287 type(hamiltonian_elec_t), intent(inout) :: hm
288 type(ions_t), intent(in) :: ions
289 type(partner_list_t), intent(in) :: ext_partners
290 type(v_ks_t), intent(inout) :: ks
291 logical, intent(in) :: ions_move
292 logical, intent(in) :: with_gauge_field
293 type(kick_t), intent(in) :: kick
294 integer, intent(in) :: iter
295 integer, intent(in) :: max_iter
296 real(real64), intent(in) :: dt
297 type(multicomm_t), intent(in) :: mc
298
299 real(real64) :: rmin
300 integer :: ierr, first, ii, ist, jj, flags, iout, default, ifile
301 logical :: output_options(max_output_types)
302 integer :: output_interval(0:max_output_types)
303 integer(int64) :: how(0:max_output_types)
304 type(block_t) :: blk
305 character(len=MAX_PATH_LEN) :: filename
307 logical :: resolve_states
308 logical, allocatable :: skip(:)
312 !%Variable TDOutput
313 !%Type block
314 !%Default multipoles + energy (+ others depending on other options)
315 !%Section Time-Dependent::TD Output
316 !%Description
317 !% Defines what should be output during the time-dependent
318 !% simulation. Many of the options can increase the computational
319 !% cost of the simulation, so only use the ones that you need. In
320 !% most cases the default value is enough, as it is adapted to the
321 !% details of the TD run. If the ions are allowed to be moved, additionally
322 !% the geometry and the temperature are output. If a laser is
323 !% included it will output by default.
324 !%
325 !% Note: the output files generated by this option are updated
326 !% every <tt>RestartWriteInterval</tt> steps.
327 !%
328 !% Example:
329 !% <br><br><tt>%TDOutput
330 !% <br>&nbsp;&nbsp;multipoles
331 !% <br>&nbsp;&nbsp;energy
332 !% <br>%<br></tt>
333 !%
334 !%Option multipoles 1
335 !% Outputs the (electric) multipole moments of the density to the file <tt>td.general/multipoles</tt>.
336 !% This is required to, <i>e.g.</i>, calculate optical absorption spectra of finite systems. The
337 !% maximum value of <math>l</math> can be set with the variable <tt>TDMultipoleLmax</tt>.
338 !%Option angular 2
339 !% Outputs the orbital angular momentum of the system to <tt>td.general/angular</tt>.
340 !% This can be used to calculate circular dicrhoism. Not implemented for periodic systems.
341 !% In case of a nonlocal pseudopotential, the gauge used can be specified using
342 !% the variable <tt>MagneticGaugeCorrection</tt>.
343 !%Option spin 3
344 !% (Experimental) Outputs the expectation value of the spin, which can be used to calculate magnetic
345 !% circular dichroism.
346 !%Option populations 4
347 !% (Experimental) Outputs the projection of the time-dependent
348 !% Kohn-Sham Slater determinant onto the ground state (or
349 !% approximations to the excited states) to the file
350 !% <tt>td.general/populations</tt>. Note that the calculation of
351 !% populations is expensive in memory and computer time, so it
352 !% should only be used if it is really needed. See <tt>TDExcitedStatesToProject</tt>.
353 !%Option geometry 5
354 !% If set (and if the atoms are allowed to move), outputs the coordinates, velocities,
355 !% and forces of the atoms to the the file <tt>td.general/coordinates</tt>. On by default if <tt>MoveIons = yes</tt>.
356 !%Option dipole_acceleration 6
357 !% When set, outputs the acceleration of the electronic dipole, calculated from the Ehrenfest theorem,
358 !% in the file <tt>td.general/acceleration</tt>. This file can then be
359 !% processed by the utility <tt>oct-harmonic-spectrum</tt> in order to obtain the harmonic spectrum.
360 !%Option laser 7
361 !% If set, outputs the laser field to the file <tt>td.general/laser</tt>.
362 !% On by default if <tt>TDExternalFields</tt> is set.
363 !%Option energy 8
364 !% If set, <tt>octopus</tt> outputs the different components of the energy
365 !% to the file <tt>td.general/energy</tt>. Will be zero except for every <tt>TDEnergyUpdateIter</tt> iterations.
366 !%Option td_occup 9
367 !% (Experimental) If set, outputs the projections of the
368 !% time-dependent Kohn-Sham wavefunctions onto the static
369 !% (zero-time) wavefunctions to the file
370 !% <tt>td.general/projections.XXX</tt>. Only use this option if
371 !% you really need it, as it might be computationally expensive. See <tt>TDProjStateStart</tt>.
372 !% The output interval of this quantity is controled by the variable <tt>TDOutputComputeInterval</tt>
373 !% In case of states parallelization, all the ground-state states are stored by each task.
374 !%Option local_mag_moments 10
375 !% If set, outputs the local magnetic moments, integrated in sphere centered around each atom.
376 !% The radius of the sphere can be set with <tt>LocalMagneticMomentsSphereRadius</tt>.
377 !%Option gauge_field 11
378 !% If set, outputs the vector gauge field corresponding to a spatially uniform (but time-dependent)
379 !% external electrical potential. This is only useful in a time-dependent periodic run.
380 !% On by default if <tt>GaugeVectorField</tt> is set.
381 !%Option temperature 12
382 !% If set, the ionic temperature at each step is printed. On by default if <tt>MoveIons = yes</tt>.
383 !%Option ftchd 13
384 !% Write Fourier transform of the electron density to the file <tt>ftchd.X</tt>,
385 !% where X depends on the kick (e.g. with sin-shaped perturbation X=sin).
386 !% This is needed for calculating the dynamic structure factor.
387 !% In the case that the kick mode is qbessel, the written quantity is integral over
388 !% density, multiplied by spherical Bessel function times real spherical harmonic.
389 !% On by default if <tt>TDMomentumTransfer</tt> is set.
390 !%Option dipole_velocity 14
391 !% When set, outputs the dipole velocity, calculated from the Ehrenfest theorem,
392 !% in the file <tt>td.general/velocity</tt>. This file can then be
393 !% processed by the utility <tt>oct-harmonic-spectrum</tt> in order to obtain the harmonic spectrum.
394 !%Option eigenvalues 15
395 !% Write the KS eigenvalues.
396 !%Option ionization_channels 16
397 !% Write the multiple-ionization channels using the KS orbital densities as proposed in
398 !% C. Ullrich, Journal of Molecular Structure: THEOCHEM 501, 315 (2000).
399 !%Option total_current 17
400 !% Output the total current (integral of the current density over the cell).
401 !%Option partial_charges 18
402 !% Bader and Hirshfeld partial charges. The output file is called 'td.general/partial_charges'.
403 !%Option td_kpoint_occup 19
404 !% Project propagated Kohn-Sham states to the states at t=0 given in the directory
405 !% restart_proj (see %RestartOptions). This is an alternative to the option
406 !% td_occup, with a formating more suitable for k-points and works only in
407 !% k- and/or state parallelization
408 !%Option td_floquet 20
409 !% Compute non-interacting Floquet bandstructure according to further options:
410 !% TDFloquetFrequency, TDFloquetSample, TDFloquetDimension.
411 !% This is done only once per td-run at t=0.
412 !% works only in k- and/or state parallelization
413 !%Option n_excited_el 21
414 !% Output the number of excited electrons, based on the projections
415 !% of the time evolved wave-functions on the ground-state wave-functions.
416 !% The output interval of this quantity is controled by the variable <tt>TDOutputComputeInterval</tt>
417 !% Note that if one sets RecalculateGSDuringEvolution=yes,
418 !% the code will recompute the GS states
419 !% and use them for the computing the number of excited electrons.
420 !% This is useful if ions are moving or if one wants to get the number of excited electrons in the basis
421 !% of the instantaneous eigenvalues of the Hamiltonian (Houston states).
422 !%Option coordinates_sep 22
423 !% Writes geometries in a separate file.
424 !%Option velocities_sep 23
425 !% Writes velocities in a separate file.
426 !%Option forces_sep 24
427 !% Writes forces in a separate file.
428 !%Option total_heat_current 25
429 !% Output the total heat current (integral of the heat current density over the cell).
430 !%Option total_magnetization 26
431 !% Writes the total magnetization, where the total magnetization is calculated at the momentum
432 !% defined by <tt>TDMomentumTransfer</tt>.
433 !% This is used to extract the magnon frequency in case of a magnon kick.
434 !%Option photons_q 27
435 !% Writes photons_q in a separate file.
436 !%Option maxwell_field 28
437 !% Writes total electric field (if coupling is in length_geuge) or vector potential
438 !% (if coupling is in velocity_gauge) coming from the interaction with Maxwell systems
439 !% (only if Maxwell-TDDFT coupling is in dipole).
440 !%Option norm_ks_orbitals 29
441 !% Writes the norm of each Kohn-Sham orbital.
442 !% The data is ordered per row as:
443 !% Iteration time (state 1 kpoint 1) (state2 kpoint1) ... (state-Nstates kpoint1) (state1 kpoint2) ... (state-Nstates kpoint-nkpt)
444 !% noting that the kpoint index will also include the spin index for spin-polarised calculations.
445 !%Option cell_parameters 30
446 !% Writes the cell parameters (lattice parameter lengths, angles, Cartesian coordinates).
447 !%End
448
449 !defaults
450 output_options = .false.
451 output_options(out_multipoles) = .true.
452 output_options(out_energy) = .true.
453 if (ions_move) then
454 output_options(out_coords) = .true.
455 output_options(out_temperature) = .true.
456 end if
457 if (with_gauge_field) output_options(out_gauge_field) = .true.
458 if (list_has_lasers(ext_partners)) output_options(out_laser) = .true.
459 if (kick%qkick_mode /= qkickmode_none) output_options(out_ftchd) = .true.
460
461 call io_function_read_what_how_when(namespace, space, output_options, how, output_interval, &
462 'TDOutput')
463
464 ! Define which files to write
465 do iout = 1, out_max
466 writ%out(iout)%write = output_options(iout)
467 end do
468
469 ! experimental stuff
470 if (writ%out(out_spin)%write) call messages_experimental('TDOutput = spin', namespace=namespace)
471 if (writ%out(out_populations)%write) call messages_experimental('TDOutput = populations', namespace=namespace)
472 if (writ%out(out_proj)%write) call messages_experimental('TDOutput = td_occup', namespace=namespace)
473 if (writ%out(out_ion_ch)%write) call messages_experimental('TDOutput = ionization_channels', namespace=namespace)
474 if (writ%out(out_partial_charges)%write) call messages_experimental('TDOutput = partial_charges', namespace=namespace)
475 if (writ%out(out_kp_proj)%write) call messages_experimental('TDOutput = td_kpoint_occup', namespace=namespace)
476 if (writ%out(out_floquet)%write) call messages_experimental('TDOutput = td_floquet', namespace=namespace)
477 if (writ%out(out_n_ex)%write) call messages_experimental('TDOutput = n_excited_el', namespace=namespace)
478 if (writ%out(out_q)%write) call messages_experimental('TDOutput = photons_q', namespace=namespace)
479 if (writ%out(out_mxll_field)%write) call messages_experimental('TDOutput = maxwell_field', namespace=namespace)
480
481 if (space%is_periodic() .and. writ%out(out_angular)%write) then
482 call messages_not_implemented("TDOutput angular for periodic systems", namespace=namespace)
483 end if
484
485 if (writ%out(out_cell_parameters)%write .and. space%dim /= 3) then
486 call messages_not_implemented("TDOutput cell_parameters for Dimensions /= 3", namespace=namespace)
487 end if
488
489 !See comment in zstates_elec_mpdotp
490 if (space%is_periodic() .and. writ%out(out_populations)%write) then
491 call messages_not_implemented("TDOutput populations for periodic systems", namespace=namespace)
492 end if
493
494 if (writ%out(out_kp_proj)%write.or.writ%out(out_floquet)%write) then
495 ! make sure this is not domain distributed
496 if (gr%np /= gr%np_global) then
497 message(1) = "TDOutput option td_kpoint_occup and td_floquet do not work with domain parallelization"
498 call messages_fatal(1, namespace=namespace)
499 end if
500 end if
501
502 if ((writ%out(out_separate_forces)%write .or. writ%out(out_coords)%write) .and. space%periodic_dim == 1) then
503 call messages_input_error(namespace, 'TDOutput', &
504 'Forces for systems periodic in 1D are not currently implemented and options that output the forces are not allowed.')
505 end if
506
507 ! NTD: The implementation of the option should be really redone properly
508 if (writ%out(out_kp_proj)%write .and. hm%kpoints%nik_skip == 0) then
509 message(1) = "TDOutput option td_kpoint_occup only work with zero-weight k-points at the moment."
510 call messages_fatal(1, namespace=namespace)
511 end if
512
513 !%Variable TDOutputResolveStates
514 !%Type logical
515 !%Default No
516 !%Section Time-Dependent::TD Output
517 !%Description
518 !% Defines whether the output should be resolved by states.
519 !%
520 !% So far only TDOutput = multipoles is supported.
521 !%
522 !%End
523 call parse_variable(namespace, 'TDOutputResolveStates', .false., resolve_states)
524 if (.not. writ%out(out_multipoles)%write .and. resolve_states) then
525 write(message(1),'(a)') "TDOutputResolveStates works only for TDOutput = multipoles."
526 call messages_warning(1, namespace=namespace)
527 end if
528
529 !%Variable TDMultipoleLmax
530 !%Type integer
531 !%Default 1
532 !%Section Time-Dependent::TD Output
533 !%Description
534 !% Maximum electric multipole of the density output to the file <tt>td.general/multipoles</tt>
535 !% during a time-dependent simulation. Must be non-negative.
536 !%End
537 call parse_variable(namespace, 'TDMultipoleLmax', 1, writ%lmax)
538 if (writ%lmax < 0) then
539 write(message(1), '(a,i6,a)') "Input: '", writ%lmax, "' is not a valid TDMultipoleLmax."
540 message(2) = '(Must be TDMultipoleLmax >= 0 )'
541 call messages_fatal(2, namespace=namespace)
542 end if
543 call messages_obsolete_variable(namespace, 'TDDipoleLmax', 'TDMultipoleLmax')
544
545 ! Compatibility test
546 if ((writ%out(out_acc)%write) .and. ions_move) then
547 message(1) = 'If harmonic spectrum is to be calculated, atoms should not be allowed to move.'
548 call messages_fatal(1, namespace=namespace)
549 end if
550
551 if ((writ%out(out_q)%write) .and. .not.(ks%has_photons)) then
552 message(1) = 'If q(t) is to be calculated, you need to allow for photon modes.'
553 call messages_fatal(1, namespace=namespace)
554 end if
555
556 if ((writ%out(out_mxll_field)%write) .and. .not. (hm%mxll%coupling_mode == velocity_gauge_dipole &
557 .or. hm%mxll%add_electric_dip)) then
558 message(1) = 'If the dipolar field has to be written, MaxwellCouplingMode has to be'
559 message(2) = '"lenght_gauge_dipole" or "velocity_gauge_dipole" and at least one Maxwell system'
560 message(3) = 'must be present.'
561 call messages_fatal(3, namespace=namespace)
562 end if
563
564 rmin = ions%min_distance()
565
566 ! This variable is documented in scf/scf.F90
567 call parse_variable(namespace, 'LocalMagneticMomentsSphereRadius', min(m_half*rmin, lmm_r_single_atom), writ%lmm_r, &
568 unit=units_inp%length)
569
570 if (writ%out(out_proj)%write .or. writ%out(out_populations)%write &
571 .or.writ%out(out_kp_proj)%write .or. writ%out(out_n_ex)%write) then
572
573 if (st%parallel_in_states .and. writ%out(out_populations)%write) then
574 message(1) = "Option TDOutput = populations is not implemented for parallel in states."
575 call messages_fatal(1, namespace=namespace)
576 end if
577
578 if (writ%out(out_proj)%write .or. writ%out(out_populations)%write) then
579 call states_elec_copy(writ%gs_st, st, exclude_wfns = .true., exclude_eigenval = .true.)
580 else
581 ! we want the same layout of gs_st as st
582 call states_elec_copy(writ%gs_st, st, special=.true.)
583 end if
584
585 ! clean up all the stuff we have to reallocate
586 safe_deallocate_a(writ%gs_st%node)
587
588 call restart_init(restart_gs, namespace, restart_proj, restart_type_load, mc, ierr, mesh=gr)
589
590 if (writ%out(out_proj)%write .or. writ%out(out_populations)%write) then
591 if (ierr == 0) then
592 call states_elec_look(restart_gs, ii, jj, writ%gs_st%nst, ierr)
593 end if
594 writ%gs_st%st_end = writ%gs_st%nst
595 if (ierr /= 0) then
596 message(1) = "Unable to read states information."
597 call messages_fatal(1, namespace=namespace)
598 end if
599
600 writ%gs_st%st_start = 1
601 writ%td_start_proj = 1
602 ! do this only when not calculating populations, since all states are needed then
603 if (.not. writ%out(out_populations)%write) then
604 ! We will store the ground-state Kohn-Sham system for all processors.
605 !%Variable TDProjStateStart
606 !%Type integer
607 !%Default 1
608 !%Section Time-Dependent::TD Output
609 !%Description
610 !% To be used with <tt>TDOutput = td_occup</tt>. Not available if <tt>TDOutput = populations</tt>.
611 !% Only output projections to states above <tt>TDProjStateStart</tt>. Usually one is only interested
612 !% in particle-hole projections around the HOMO, so there is no need to calculate (and store)
613 !% the projections of all TD states onto all static states. This sets a lower limit. The upper limit
614 !% is set by the number of states in the propagation and the number of unoccupied states
615 !% available.
616 !%End
617 call parse_variable(namespace, 'TDProjStateStart', 1, writ%td_start_proj)
618
619 if (.not. writ%out(out_n_ex)%write) writ%gs_st%st_start = writ%td_start_proj
620
621 if (st%parallel_in_states .and. writ%out(out_proj)%write .and. writ%gs_st%st_start > 1) then
622 call messages_not_implemented("TDOutput = td_occup for parallel in states with TDProjStateStart > 1", &
623 namespace=namespace)
624 end if
625 end if
626
627 writ%gs_st%lnst = writ%gs_st%st_end - writ%gs_st%st_start + 1
628
629 call states_elec_deallocate_wfns(writ%gs_st)
630
631 writ%gs_st%parallel_in_states = .false.
632
633 ! allocate memory
634 safe_allocate(writ%gs_st%occ(1:writ%gs_st%nst, 1:writ%gs_st%nik))
635 safe_allocate(writ%gs_st%eigenval(1:writ%gs_st%nst, 1:writ%gs_st%nik))
636
637 !We want all the task to have all the states
638 !States can be distibuted for the states we propagate.
639 safe_allocate(writ%gs_st%node(1:writ%gs_st%nst))
640 writ%gs_st%node(:) = 0
641
642 writ%gs_st%eigenval = huge(writ%gs_st%eigenval)
643 writ%gs_st%occ = m_zero
644 if (writ%gs_st%d%ispin == spinors) then
645 safe_deallocate_a(writ%gs_st%spin)
646 safe_allocate(writ%gs_st%spin(1:3, 1:writ%gs_st%nst, 1:writ%gs_st%nik))
647 end if
648
649 safe_allocate(skip(1:writ%gs_st%nst))
650 skip = .false.
651 skip(1:writ%gs_st%st_start-1) = .true.
652
653 call states_elec_allocate_wfns(writ%gs_st, gr, type_cmplx, packed=.true., skip=skip)
654
655 safe_deallocate_a(skip)
656 end if
657
658 call states_elec_load(restart_gs, namespace, space, writ%gs_st, gr, hm%kpoints, &
659 fixed_occ=.true., ierr=ierr, label = ': gs for TDOutput')
660
661 if (ierr /= 0 .and. ierr /= (writ%gs_st%st_end-writ%gs_st%st_start+1)*writ%gs_st%nik &
662 *writ%gs_st%d%dim*writ%gs_st%mpi_grp%size) then
663 message(1) = "Unable to read wavefunctions for TDOutput."
664 call messages_fatal(1, namespace=namespace)
665 end if
667 end if
668
669 ! Build the excited states...
670 if (writ%out(out_populations)%write) then
671 !%Variable TDExcitedStatesToProject
672 !%Type block
673 !%Section Time-Dependent::TD Output
674 !%Description
675 !% <b>[WARNING: This is a *very* experimental feature]</b>
676 !% To be used with <tt>TDOutput = populations</tt>.
677 !% The population of the excited states
678 !% (as defined by <Phi_I|Phi(t)> where |Phi(t)> is the many-body time-dependent state at
679 !% time <i>t</i>, and |Phi_I> is the excited state of interest) can be approximated -- it is not clear
680 !% how well -- by substituting for those real many-body states the time-dependent Kohn-Sham
681 !% determinant and some modification of the Kohn-Sham ground-state determinant (<i>e.g.</i>,
682 !% a simple HOMO-LUMO substitution, or the Casida ansatz for excited states in linear-response
683 !% theory. If you set <tt>TDOutput</tt> to contain <tt>populations</tt>, you may ask for these approximated
684 !% populations for a number of excited states, which will be described in the files specified
685 !% in this block: each line should be the name of a file that contains one excited state.
686 !%
687 !% This file structure is the one written by the casida run mode, in the files in the directory <tt>*_excitations</tt>.
688 !% The file describes the "promotions" from occupied
689 !% to unoccupied levels that change the initial Slater determinant
690 !% structure specified in ground_state. These promotions are a set
691 !% of electron-hole pairs. Each line in the file, after an optional header, has four
692 !% columns:
693 !%
694 !% <i>i a <math>\sigma</math> weight</i>
695 !%
696 !% where <i>i</i> should be an occupied state, <i>a</i> an unoccupied one, and <math>\sigma</math>
697 !% the spin of the corresponding orbital. This pair is then associated with a
698 !% creation-annihilation pair <math>a^{\dagger}_{a,\sigma} a_{i,\sigma}</math>, so that the
699 !% excited state will be a linear combination in the form:
700 !%
701 !% <math>\left|{\rm ExcitedState}\right> =
702 !% \sum weight(i,a,\sigma) a^{\dagger}_{a,\sigma} a_{i,\sigma} \left|{\rm GroundState}\right></math>
703 !%
704 !% where <i>weight</i> is the number in the fourth column.
705 !% These weights should be normalized to one; otherwise the routine
706 !% will normalize them, and write a warning.
707 !%End
708 if (parse_block(namespace, 'TDExcitedStatesToProject', blk) == 0) then
709 writ%n_excited_states = parse_block_n(blk)
710 safe_allocate(writ%excited_st(1:writ%n_excited_states))
711 do ist = 1, writ%n_excited_states
712 call parse_block_string(blk, ist-1, 0, filename)
713 call excited_states_init(writ%excited_st(ist), writ%gs_st, trim(filename), namespace)
714 end do
715 else
716 writ%n_excited_states = 0
717 end if
718 end if
719
720 !%Variable TDOutputComputeInterval
721 !%Type integer
722 !%Default 50
723 !%Section Time-Dependent::TD Output
724 !%Description
725 !% The TD output requested are computed
726 !% when the iteration number is a multiple of the <tt>TDOutputComputeInterval</tt> variable.
727 !% Must be >= 0. If it is 0, then no output is written.
728 !% Implemented only for projections and number of excited electrons for the moment.
729 !%End
730 call parse_variable(namespace, 'TDOutputComputeInterval', 50, writ%compute_interval)
731 if (writ%compute_interval < 0) then
732 message(1) = "TDOutputComputeInterval must be >= 0."
733 call messages_fatal(1, namespace=namespace)
734 end if
735
736 ! ----------------------------------------------
737 ! Initialize write file handlers
738 ! ----------------------------------------------
739
740 ! Step
741 if (iter == 0) then
742 first = 0
743 else
744 first = iter + 1
745 end if
746
747 ! Root dir for TD files
748 call io_mkdir('td.general', namespace)
749
750 ! ----------------------------------------------
751 ! Initialize write that are MPI agnostic
752 ! ----------------------------------------------
753
754 ! Default
755 writ%out(:)%mpi_grp = mpi_world
756
757 if (mpi_grp_is_root(mpi_world)) then
758
759 do ifile = 1, out_max
760 ! Exceptions that are handled later
761 if (any([out_multipoles, out_laser, out_ftchd] == ifile)) cycle
762
763 if (writ%out(ifile)%write) then
764 call write_iter_init(writ%out(ifile)%handle, &
765 first, &
766 units_from_atomic(units_out%time, dt), &
767 trim(io_workpath("td.general/"//trim(td_file_name(ifile)), namespace)))
768 end if
769
770 enddo
771
772 ! Exceptions
773
774 ! Multipoles, when MPI is not state-parallel
775 if (writ%out(out_multipoles)%write .and. .not. resolve_states) then
776 call write_iter_init(writ%out(out_multipoles)%handle, &
777 first, units_from_atomic(units_out%time, dt), &
778 trim(io_workpath("td.general/multipoles", namespace)))
779 end if
780
781 if (writ%out(out_ftchd)%write) then
782 select case (kick%qkick_mode)
783 case (qkickmode_sin)
784 write(filename, '(a)') 'td.general/ftchd.sin'
785 case (qkickmode_cos)
786 write(filename, '(a)') 'td.general/ftchd.cos'
787 case (qkickmode_bessel)
788 write(filename, '(a, SP, I0.3, a, I0.3)') 'td.general/ftchd.l', kick%qbessel_l, '_m', kick%qbessel_m
789 case default
790 write(filename, '(a)') 'td.general/ftchd'
791 end select
792 call write_iter_init(writ%out(out_ftchd)%handle, &
793 first, units_from_atomic(units_out%time, dt), trim(io_workpath(filename, namespace)))
794 end if
795
796 if (writ%out(out_laser)%write) then
797 if(associated(list_get_lasers(ext_partners))) then
798 ! The laser file is written for the full propagation in one go, so that
799 ! the user can check that the laser is correct and as intended before letting
800 ! the code run for a possibly large period of time. This is done even after
801 ! a restart, so that it takes into account any changes to max_iter.
802 call io_rm("td.general/laser", namespace=namespace)
803 call write_iter_init(writ%out(out_laser)%handle, 0, &
804 units_from_atomic(units_out%time, dt), &
805 trim(io_workpath("td.general/laser", namespace)))
806 do ii = 0, max_iter
807 call td_write_laser(writ%out(out_laser)%handle, space, list_get_lasers(ext_partners), dt, ii)
808 end do
809 call write_iter_end(writ%out(out_laser)%handle)
810 end if
811 end if
812
813 end if ! mpi_grp_is_root(mpi_world)
814
815 ! ----------------------------------------------
816 ! Initialize write that are MPI group-specific
817 ! ----------------------------------------------
818
819 if (writ%out(out_multipoles)%write .and. resolve_states) then
820 !resolve state contribution on multipoles
821 writ%out(out_multipoles)%hand_start = st%st_start
822 writ%out(out_multipoles)%hand_end = st%st_end
823 writ%out(out_multipoles)%resolve_states = .true.
824 writ%out(out_multipoles)%mpi_grp = gr%mpi_grp
825
826 safe_allocate(writ%out(out_multipoles)%mult_handles(st%st_start:st%st_end))
827
828 if (mpi_grp_is_root(writ%out(out_multipoles)%mpi_grp)) then
829 do ist = st%st_start, st%st_end
830 write(filename, '(a,i4.4)') 'td.general/multipoles-ist', ist
831 call write_iter_init(writ%out(out_multipoles)%mult_handles(ist), &
832 first, units_from_atomic(units_out%time, dt), &
833 trim(io_workpath(filename, namespace)))
834 end do
835 end if
836 end if
837
838 ! Misc operations
839
840 if (writ%out(out_total_current)%write .or. writ%out(out_total_heat_current)%write) then
841 !TODO: we should only compute the current here, not v_ks
842 call v_ks_calculate_current(ks, .true.)
843 call v_ks_calc(ks, namespace, space, hm, st, ions, ext_partners, &
844 calc_eigenval=.false., time = iter*dt, calc_energy = .false.)
845 end if
846
847
848 if (all(outp%how == 0) .and. writ%out(out_n_ex)%write) then
849 call io_function_read_what_how_when(namespace, space, outp%what, outp%how, outp%output_interval)
850 if (outp%how(option__output__current_kpt) + outp%how(option__output__density_kpt) /= 0) then
851 call io_mkdir(outp%iter_dir, namespace)
852 end if
853 end if
854
855 ! --------------------------------------------------------
856 ! All steps of the above routine, but specific to DFT+U
857 ! --------------------------------------------------------
858
859 !%Variable TDOutputDFTU
860 !%Type flag
861 !%Default none
862 !%Section Time-Dependent::TD Output
863 !%Description
864 !% Defines what should be output during the time-dependent
865 !% simulation, related to DFT+U.
866 !%
867 !% Note: the output files generated by this option are updated
868 !% every <tt>RestartWriteInterval</tt> steps.
869 !%Option effective_u 1
870 !% Writes the effective U for each orbital set as a function of time.
871 !%End
872 default = 0
873 if (hm%lda_u_level == dft_u_acbn0) default = default + 2**(out_dftu_effective_u - 1)
874 call parse_variable(namespace, 'TDOutputDFTU', default, flags)
875
876 if (.not. varinfo_valid_option('TDOutputDFTU', flags, is_flag = .true.)) then
877 call messages_input_error(namespace, 'TDOutputDFTU')
878 end if
879
880 do iout = 1, out_dftu_max
881 writ%out_dftu(iout)%write = (iand(flags, 2**(iout - 1)) /= 0)
882 end do
883
884 if (mpi_grp_is_root(mpi_world)) then
885 if (writ%out_dftu(out_dftu_effective_u)%write) then
886 call write_iter_init(writ%out_dftu(out_dftu_effective_u)%handle, &
887 first, units_from_atomic(units_out%time, dt), &
888 trim(io_workpath("td.general/effectiveU", namespace)))
889 end if
890 end if
891
892 pop_sub(td_write_init)
893 end subroutine td_write_init
894
895
896 ! ---------------------------------------------------------
897 subroutine td_write_end(writ)
898 type(td_write_t), intent(inout) :: writ
899
900 integer :: ist, iout
901
902 push_sub(td_write_end)
903
904 do iout = 1, out_max
905 if (iout == out_laser) cycle
906 if (writ%out(iout)%write) then
907 if (mpi_grp_is_root(writ%out(iout)%mpi_grp)) then
908 if (writ%out(iout)%resolve_states) then
909 do ist = writ%out(iout)%hand_start, writ%out(iout)%hand_end
910 call write_iter_end(writ%out(iout)%mult_handles(ist))
911 end do
912 safe_deallocate_a(writ%out(iout)%mult_handles)
913 else
914 call write_iter_end(writ%out(iout)%handle)
915 end if
916 end if
917 end if
918 end do
919
920 if (mpi_grp_is_root(mpi_world)) then
921 do iout = 1, out_dftu_max
922 if (writ%out_dftu(iout)%write) call write_iter_end(writ%out_dftu(iout)%handle)
923 end do
924
925 end if
926
927 if (writ%out(out_populations)%write) then
928 do ist = 1, writ%n_excited_states
929 call excited_states_kill(writ%excited_st(ist))
930 end do
931 writ%n_excited_states = 0
932 end if
933
934 if (writ%out(out_proj)%write .or. writ%out(out_populations)%write &
935 .or. writ%out(out_n_ex)%write .or. writ%out(out_kp_proj)%write) then
936 call states_elec_end(writ%gs_st)
937 end if
938
939 pop_sub(td_write_end)
940 end subroutine td_write_end
941
942
943 ! ---------------------------------------------------------
944 subroutine td_write_iter(writ, namespace, space, outp, gr, st, hm, ions, ext_partners, kick, ks, dt, iter, mc, recalculate_gs)
945 type(td_write_t), intent(inout) :: writ
946 type(namespace_t), intent(in) :: namespace
947 class(space_t), intent(in) :: space
948 type(output_t), intent(in) :: outp
949 type(grid_t), intent(in) :: gr
950 type(states_elec_t), intent(inout) :: st
951 type(hamiltonian_elec_t), intent(inout) :: hm
952 type(ions_t), intent(inout) :: ions
953 type(partner_list_t), intent(in) :: ext_partners
954 type(kick_t), intent(in) :: kick
955 type(v_ks_t), intent(in) :: ks
956 real(real64), intent(in) :: dt
957 integer, intent(in) :: iter
958 type(multicomm_t), intent(in) :: mc
959 logical, intent(in) :: recalculate_gs
960
961 type(gauge_field_t), pointer :: gfield
962 integer :: ierr
963 type(restart_t) :: restart_gs
964
965 push_sub_with_profile(td_write_iter)
966
967 if (writ%out(out_multipoles)%write) then
968 call td_write_multipole(writ%out(out_multipoles), space, gr, ions, st, writ%lmax, kick, iter)
969 end if
970
971 if (writ%out(out_ftchd)%write) then
972 call td_write_ftchd(writ%out(out_ftchd)%handle, space, gr, st, kick, iter)
973 end if
974
975 if (writ%out(out_angular)%write) then
976 call td_write_angular(writ%out(out_angular)%handle, namespace, space, gr, ions, hm, st, kick, iter)
977 end if
978
979 if (writ%out(out_spin)%write) then
980 call td_write_spin(writ%out(out_spin)%handle, gr, st, iter)
981 end if
982
983 if (writ%out(out_magnets)%write) then
984 call td_write_local_magnetic_moments(writ%out(out_magnets)%handle, gr, st, ions, writ%lmm_r, iter)
985 end if
986
987 if (writ%out(out_tot_m)%write) then
988 call td_write_tot_mag(writ%out(out_tot_m)%handle, gr, st, kick, iter)
989 end if
991 if (writ%out(out_proj)%write .and. mod(iter, writ%compute_interval) == 0) then
992 if (mpi_grp_is_root(mpi_world)) call write_iter_set(writ%out(out_proj)%handle, iter)
993 call td_write_proj(writ%out(out_proj)%handle, space, gr, ions, st, writ%gs_st, writ%td_start_proj, kick, iter)
994 end if
995
996 if (writ%out(out_floquet)%write) then
997 call td_write_floquet(namespace, space, hm, ext_partners, gr, st, iter)
998 end if
999
1000 if (writ%out(out_kp_proj)%write .and. mod(iter, writ%compute_interval) == 0) then
1001 call td_write_proj_kp(gr, hm%kpoints, st, writ%gs_st, namespace, iter)
1002 end if
1003
1004 if (writ%out(out_coords)%write) then
1005 call td_write_coordinates(writ%out(out_coords)%handle, ions%natoms, ions%space, &
1006 ions%pos, ions%vel, ions%tot_force, iter)
1007 end if
1008
1009 if (writ%out(out_separate_coords)%write) then
1010 call td_write_sep_coordinates(writ%out(out_separate_coords)%handle, ions%natoms, ions%space, &
1011 ions%pos, ions%vel, ions%tot_force, iter, 1)
1012 end if
1013
1014 if (writ%out(out_separate_velocity)%write) then
1015 call td_write_sep_coordinates(writ%out(out_separate_velocity)%handle, ions%natoms, ions%space, &
1016 ions%pos, ions%vel, ions%tot_force, iter, 2)
1017 end if
1018
1019 if (writ%out(out_separate_forces)%write) then
1020 call td_write_sep_coordinates(writ%out(out_separate_forces)%handle, ions%natoms, ions%space, &
1021 ions%pos, ions%vel, ions%tot_force, iter, 3)
1022 end if
1023
1024 if (writ%out(out_temperature)%write) then
1025 call td_write_temperature(writ%out(out_temperature)%handle, ions, iter)
1026 end if
1027
1028 if (writ%out(out_populations)%write) then
1029 call td_write_populations(writ%out(out_populations)%handle, namespace, space, gr, st, writ, dt, iter)
1030 end if
1031
1032 if (writ%out(out_acc)%write) then
1033 call td_write_acc(writ%out(out_acc)%handle, namespace, space, gr, ions, st, hm, ext_partners, dt, iter)
1034 end if
1035
1036 if (writ%out(out_vel)%write) then
1037 call td_write_vel(writ%out(out_vel)%handle, gr, st, space, hm%kpoints, iter)
1038 end if
1039
1040 ! td_write_laser no longer called here, because the whole laser is printed
1041 ! out at the beginning.
1042
1043 if (writ%out(out_energy)%write) then
1044 call td_write_energy(writ%out(out_energy)%handle, hm, iter, ions%kinetic_energy)
1045 end if
1046
1047 if (writ%out(out_gauge_field)%write) then
1048 gfield => list_get_gauge_field(ext_partners)
1049 if(associated(gfield)) then
1050 call gauge_field_output_write(gfield, writ%out(out_gauge_field)%handle, iter)
1051 end if
1052 end if
1053
1054 if (writ%out(out_eigs)%write) then
1055 call td_write_eigs(writ%out(out_eigs)%handle, st, iter)
1056 end if
1057
1058 if (writ%out(out_ion_ch)%write) then
1059 call td_write_ionch(writ%out(out_ion_ch)%handle, gr, st, iter)
1060 end if
1061
1062 if (writ%out(out_total_current)%write) then
1063 call td_write_total_current(writ%out(out_total_current)%handle, space, gr, st, iter)
1064 end if
1065
1066 if (writ%out(out_total_heat_current)%write) then
1067 call td_write_total_heat_current(writ%out(out_total_heat_current)%handle, space, hm, gr, st, iter)
1068 end if
1069
1070 if (writ%out(out_partial_charges)%write) then
1071 call td_write_partial_charges(writ%out(out_partial_charges)%handle, gr, st, &
1072 ions, iter)
1073 end if
1074
1075 if (writ%out(out_n_ex)%write .and. mod(iter, writ%compute_interval) == 0) then
1076 if (mpi_grp_is_root(mpi_world)) call write_iter_set(writ%out(out_n_ex)%handle, iter)
1077 if (recalculate_gs) then ! Load recomputed GS states
1078 call restart_init(restart_gs, namespace, restart_proj, restart_type_load, mc, ierr, mesh=gr)
1079 ! Fixed occupations here, as we only load the Houston states
1080 call states_elec_load(restart_gs, namespace, space, writ%gs_st, gr, hm%kpoints, fixed_occ=.true., &
1081 ierr=ierr, label = ': Houston states for TDOutput')
1083 end if
1084
1085 call td_write_n_ex(writ%out(out_n_ex)%handle, outp, namespace, gr, hm%kpoints, st, writ%gs_st, iter)
1086 end if
1087
1088 if (writ%out(out_norm_ks)%write) then
1089 call td_write_norm_ks_orbitals(writ%out(out_norm_ks)%handle, gr, hm%kpoints, st, iter)
1090 end if
1091
1092 if (writ%out(out_cell_parameters)%write) then
1093 call td_write_cell_parameters(writ%out(out_cell_parameters)%handle, ions, iter)
1094 end if
1095
1096 !DFT+U outputs
1097 if (writ%out_dftu(out_dftu_effective_u)%write) then
1098 call td_write_effective_u(writ%out_dftu(out_dftu_effective_u)%handle, hm%lda_u, iter)
1099 end if
1100
1101 if (writ%out(out_q)%write .and. ks%has_photons) then
1102 call td_write_q(writ%out(out_q)%handle, space, ks, iter)
1103 end if
1104
1105 if (writ%out(out_mxll_field)%write .and. hm%mxll%calc_field_dip) then
1106 call td_write_mxll_field(writ%out(out_mxll_field)%handle, space, hm, dt, iter)
1107 end if
1108
1109 pop_sub_with_profile(td_write_iter)
1110 end subroutine td_write_iter
1111
1112
1113 ! ---------------------------------------------------------
1114 subroutine td_write_data(writ)
1115 type(td_write_t), intent(inout) :: writ
1116
1117 integer :: iout, ii
1118
1119 push_sub(td_write_data)
1120 call profiling_in("TD_WRITE_DATA")
1121
1122 do iout = 1, out_max
1123 if (iout == out_laser) cycle
1124 if (writ%out(iout)%write) then
1125 if (mpi_grp_is_root(writ%out(iout)%mpi_grp)) then
1126 if (writ%out(iout)%resolve_states) then
1127 do ii = writ%out(iout)%hand_start, writ%out(iout)%hand_end
1128 call write_iter_flush(writ%out(iout)%mult_handles(ii))
1129 end do
1130 else
1131 call write_iter_flush(writ%out(iout)%handle)
1132 end if
1133 end if
1134 end if
1135 end do
1136
1137 if (mpi_grp_is_root(mpi_world)) then
1138 do iout = 1, out_dftu_max
1139 if (writ%out_dftu(iout)%write) call write_iter_flush(writ%out_dftu(iout)%handle)
1140 end do
1141 end if
1142
1143 call profiling_out("TD_WRITE_DATA")
1144 pop_sub(td_write_data)
1145 end subroutine td_write_data
1146
1147 ! ---------------------------------------------------------
1148 subroutine td_write_output(namespace, space, gr, st, hm, ks, outp, ions, ext_partners, iter, dt)
1149 type(namespace_t), intent(in) :: namespace
1150 type(electron_space_t), intent(in) :: space
1151 type(grid_t), intent(in) :: gr
1152 type(states_elec_t), intent(inout) :: st
1153 type(hamiltonian_elec_t), intent(inout) :: hm
1154 type(v_ks_t), intent(inout) :: ks
1155 type(output_t), intent(in) :: outp
1156 type(ions_t), intent(in) :: ions
1157 type(partner_list_t), intent(in) :: ext_partners
1158 integer, intent(in) :: iter
1159 real(real64), optional, intent(in) :: dt
1160
1161 character(len=256) :: filename
1162
1163 push_sub(td_write_output)
1164 call profiling_in("TD_WRITE_OUTPUT")
1165
1166 ! TODO this now overwrites wf inside st. If this is not wanted need to add an optional overwrite=no flag
1167 if (st%modelmbparticles%nparticle > 0) then
1168 call modelmb_sym_all_states(space, gr, st)
1169 end if
1170
1171 ! now write down the rest
1172 write(filename, '(a,a,i7.7)') trim(outp%iter_dir),"td.", iter ! name of directory
1173
1174 call output_all(outp, namespace, space, filename, gr, ions, iter, st, hm, ks)
1175
1176 call output_modelmb(outp, namespace, space, filename, gr, ions, iter, st)
1177
1178 if (present(dt)) then
1179 call output_scalar_pot(outp, namespace, space, filename, gr, ions, ext_partners, iter*dt)
1180 else
1181 if (iter == 0) call output_scalar_pot(outp, namespace, space, filename, gr, ions, ext_partners)
1182 end if
1183
1184 call profiling_out("TD_WRITE_OUTPUT")
1185 pop_sub(td_write_output)
1186 end subroutine td_write_output
1187
1188 ! ---------------------------------------------------------
1189 subroutine td_write_spin(out_spin, mesh, st, iter)
1190 type(c_ptr), intent(inout) :: out_spin
1191 class(mesh_t), intent(in) :: mesh
1192 type(states_elec_t), intent(in) :: st
1193 integer, intent(in) :: iter
1194
1195 character(len=130) :: aux
1196 real(real64) :: spin(3)
1197
1198 push_sub(td_write_spin)
1199
1200 ! The expectation value of the spin operator is half the total magnetic moment
1201 ! This has to be calculated by all nodes
1202 call magnetic_moment(mesh, st, st%rho, spin)
1203 spin = m_half*spin
1204
1205 if (mpi_grp_is_root(mpi_world)) then ! only first node outputs
1206
1207 if (iter == 0) then
1209
1210 !second line -> columns name
1212 if (st%d%ispin == spinors) then
1213 write(aux, '(a2,18x)') 'Sx'
1214 call write_iter_header(out_spin, aux)
1215 write(aux, '(a2,18x)') 'Sy'
1216 call write_iter_header(out_spin, aux)
1217 end if
1218 write(aux, '(a2,18x)') 'Sz'
1219 call write_iter_header(out_spin, aux)
1221
1223 end if
1224
1226 select case (st%d%ispin)
1227 case (spin_polarized)
1228 call write_iter_double(out_spin, spin(3), 1)
1229 case (spinors)
1230 call write_iter_double(out_spin, spin(1:3), 3)
1231 end select
1233
1234 end if
1235
1236 pop_sub(td_write_spin)
1237 end subroutine td_write_spin
1238
1239
1240 ! ---------------------------------------------------------
1241 subroutine td_write_local_magnetic_moments(out_magnets, gr, st, ions, lmm_r, iter)
1242 type(c_ptr), intent(inout) :: out_magnets
1243 type(grid_t), intent(in) :: gr
1244 type(states_elec_t), intent(in) :: st
1245 type(ions_t), intent(in) :: ions
1246 real(real64), intent(in) :: lmm_r
1247 integer, intent(in) :: iter
1248
1249 integer :: ia
1250 character(len=50) :: aux
1251 real(real64), allocatable :: lmm(:,:)
1252
1254
1255 !get the atoms` magnetization. This has to be calculated by all nodes
1256 safe_allocate(lmm(1:3, 1:ions%natoms))
1257 call magnetic_local_moments(gr, st, ions, gr%der%boundaries, st%rho, lmm_r, lmm)
1258
1259 if (mpi_grp_is_root(mpi_world)) then ! only first node outputs
1260
1261 if (iter == 0) then
1263
1264 !second line -> columns name
1266 do ia = 1, ions%natoms
1267 if (st%d%ispin == spinors) then
1268 write(aux, '(a2,i2.2,16x)') 'mx', ia
1270 write(aux, '(a2,i2.2,16x)') 'my', ia
1272 end if
1273 write(aux, '(a2,i2.2,16x)') 'mz', ia
1275 end do
1277
1279 end if
1280
1282 do ia = 1, ions%natoms
1283 select case (st%d%ispin)
1284 case (spin_polarized)
1285 call write_iter_double(out_magnets, lmm(3, ia), 1)
1286 case (spinors)
1287 call write_iter_double(out_magnets, lmm(1:3, ia), 3)
1288 end select
1289 end do
1291 end if
1292
1293 safe_deallocate_a(lmm)
1294
1296 end subroutine td_write_local_magnetic_moments
1297
1298 ! ---------------------------------------------------------
1299 subroutine td_write_tot_mag(out_magnets, mesh, st, kick, iter)
1300 type(c_ptr), intent(inout) :: out_magnets
1301 class(mesh_t), intent(in) :: mesh
1302 type(states_elec_t), intent(in) :: st
1303 type(kick_t), intent(in) :: kick
1304 integer, intent(in) :: iter
1305
1306 complex(real64), allocatable :: tm(:,:)
1307 integer :: ii, iq
1308
1309 push_sub(td_write_tot_mag)
1310
1311 safe_allocate(tm(1:6,1:kick%nqvec))
1312
1313 do iq = 1, kick%nqvec
1314 call magnetic_total_magnetization(mesh, st, kick%qvector(:,iq), tm(1:6,iq))
1315 end do
1316
1317 if (mpi_grp_is_root(mpi_world)) then ! only first node outputs
1318
1319 if (iter == 0) then
1320 call td_write_print_header_init(out_magnets)
1321 call kick_write(kick, out = out_magnets)
1322
1323 !second line -> columns name
1324 call write_iter_header_start(out_magnets)
1325 call write_iter_header(out_magnets, 'Re[m_x(q)]')
1326 call write_iter_header(out_magnets, 'Im[m_x(q)]')
1327 call write_iter_header(out_magnets, 'Re[m_y(q)]')
1328 call write_iter_header(out_magnets, 'Im[m_y(q)]')
1329 call write_iter_header(out_magnets, 'Re[m_z(q)]')
1330 call write_iter_header(out_magnets, 'Im[m_z(q)]')
1331 call write_iter_header(out_magnets, 'Re[m_x(-q)]')
1332 call write_iter_header(out_magnets, 'Im[m_x(-q)]')
1333 call write_iter_header(out_magnets, 'Re[m_y(-q)]')
1334 call write_iter_header(out_magnets, 'Im[m_y(-q)]')
1335 call write_iter_header(out_magnets, 'Re[m_z(-q)]')
1336 call write_iter_header(out_magnets, 'Im[m_z(-q)]')
1337 call write_iter_nl(out_magnets)
1338
1339 call td_write_print_header_end(out_magnets)
1340 end if
1341
1342 call write_iter_start(out_magnets)
1343 do iq = 1, kick%nqvec
1344 do ii = 1, 6
1345 call write_iter_double(out_magnets, real(tm(ii, iq), real64), 1)
1346 call write_iter_double(out_magnets, aimag(tm(ii, iq)), 1)
1347 end do
1348 end do
1349 call write_iter_nl(out_magnets)
1350 end if
1351
1352 safe_deallocate_a(tm)
1353
1354 pop_sub(td_write_tot_mag)
1355 end subroutine td_write_tot_mag
1356
1357
1358 ! ---------------------------------------------------------
1366 subroutine td_write_angular(out_angular, namespace, space, gr, ions, hm, st, kick, iter)
1367 type(c_ptr), intent(inout) :: out_angular
1368 type(namespace_t), intent(in) :: namespace
1369 class(space_t), intent(in) :: space
1370 type(grid_t), intent(in) :: gr
1371 type(ions_t), intent(inout) :: ions
1372 type(hamiltonian_elec_t), intent(inout) :: hm
1373 type(states_elec_t), intent(inout) :: st
1374 type(kick_t), intent(in) :: kick
1375 integer, intent(in) :: iter
1376
1377 integer :: idir
1378 character(len=130) :: aux
1379 real(real64) :: angular(3)
1380 class(perturbation_magnetic_t), pointer :: angular_momentum
1381
1382 push_sub(td_write_angular)
1383
1384 angular_momentum => perturbation_magnetic_t(namespace, ions)
1385 do idir = 1, 3
1386 call angular_momentum%setup_dir(idir)
1387 !we have to multiply by 2, because the perturbation returns L/2
1388 angular(idir) = &
1389 m_two*real(angular_momentum%zstates_elec_expectation_value(namespace, space, gr, hm, st), real64)
1390 end do
1391 safe_deallocate_p(angular_momentum)
1393 if (mpi_grp_is_root(mpi_world)) then ! Only first node outputs
1394
1395 if (iter == 0) then
1396 call td_write_print_header_init(out_angular)
1397
1398 write(aux, '(a15,i2)') '# nspin ', st%d%nspin
1399 call write_iter_string(out_angular, aux)
1400 call write_iter_nl(out_angular)
1401
1402 call kick_write(kick, out = out_angular)
1403
1404 !second line -> columns name
1405 call write_iter_header_start(out_angular)
1406 write(aux, '(a4,18x)') '<Lx>'
1407 call write_iter_header(out_angular, aux)
1408 write(aux, '(a4,18x)') '<Ly>'
1409 call write_iter_header(out_angular, aux)
1410 write(aux, '(a4,18x)') '<Lz>'
1411 call write_iter_header(out_angular, aux)
1412 call write_iter_nl(out_angular)
1413
1414 !third line -> should hold the units.
1415 call write_iter_string(out_angular, '#[Iter n.]')
1416 call write_iter_header(out_angular, '[' // trim(units_abbrev(units_out%time)) // ']')
1417 call write_iter_header(out_angular, '[hbar]')
1418 call write_iter_header(out_angular, '[hbar]')
1419 call write_iter_header(out_angular, '[hbar]')
1420 call write_iter_nl(out_angular)
1421
1422 call td_write_print_header_end(out_angular)
1423 end if
1424
1425 call write_iter_start(out_angular)
1426 call write_iter_double(out_angular, angular(1:3), 3)
1427 call write_iter_nl(out_angular)
1428
1429 end if
1430
1431 pop_sub(td_write_angular)
1432 end subroutine td_write_angular
1433
1434
1437 subroutine td_write_multipole(out_multip, space, gr, ions, st, lmax, kick, iter)
1438 type(td_write_prop_t), intent(inout) :: out_multip
1439 class(space_t), intent(in) :: space
1440 type(grid_t), intent(in) :: gr
1441 type(ions_t), intent(in) :: ions
1442 type(states_elec_t), intent(in) :: st
1443 integer, intent(in) :: lmax
1444 type(kick_t), intent(in) :: kick
1445 integer, intent(in) :: iter
1446
1447 integer :: ist
1448 real(real64), allocatable :: rho(:,:)
1449
1450 push_sub(td_write_multipole)
1451
1452 if (out_multip%resolve_states) then
1453 safe_allocate(rho(1:gr%np_part, 1:st%d%nspin))
1454 rho(:,:) = m_zero
1455
1456 do ist = st%st_start, st%st_end
1457 call density_calc(st, gr, rho, istin = ist)
1458 call td_write_multipole_r(out_multip%mult_handles(ist), space, gr, ions, st, lmax, kick, rho, iter, &
1459 mpi_grp = out_multip%mpi_grp)
1460 end do
1461
1462 safe_deallocate_a(rho)
1463
1464 else
1465 if (allocated(st%frozen_rho)) then
1466 safe_allocate(rho(1:gr%np, 1:st%d%nspin))
1467 call lalg_copy(gr%np, st%d%nspin, st%rho, rho)
1468 call lalg_axpy(gr%np, st%d%nspin, m_one, st%frozen_rho, rho)
1469
1470 call td_write_multipole_r(out_multip%handle, space, gr, ions, st, lmax, kick, rho, iter)
1471
1472 safe_deallocate_a(rho)
1473 else
1474 call td_write_multipole_r(out_multip%handle, space, gr, ions, st, lmax, kick, st%rho, iter)
1475 end if
1476
1477 end if
1478
1479 pop_sub(td_write_multipole)
1480 end subroutine td_write_multipole
1481
1482
1484 subroutine td_write_multipole_r(out_multip, space, mesh, ions, st, lmax, kick, rho, iter, mpi_grp)
1485 type(c_ptr), intent(inout) :: out_multip
1486 class(space_t), intent(in) :: space
1487 class(mesh_t), intent(in) :: mesh
1488 type(ions_t), intent(in) :: ions
1489 type(states_elec_t), intent(in) :: st
1490 integer, intent(in) :: lmax
1491 type(kick_t), intent(in) :: kick
1492 real(real64), intent(in) :: rho(:,:)
1493 integer, intent(in) :: iter
1494 type(mpi_grp_t), optional, intent(in) :: mpi_grp
1495
1496
1497 integer :: is, idir, ll, mm, add_lm
1498 character(len=120) :: aux
1499 real(real64) :: ionic_dipole(ions%space%dim)
1500 real(real64), allocatable :: multipole(:,:)
1501 type(mpi_grp_t) :: mpi_grp_
1502
1503 push_sub(td_write_multipole_r)
1504
1505 ! We cannot output multipoles beyond the dipole for higher dimensions
1506 assert(.not. (lmax > 1 .and. space%dim > 3))
1507
1508 mpi_grp_ = mpi_world
1509 if (present(mpi_grp)) mpi_grp_ = mpi_grp
1510
1511 if (mpi_grp_is_root(mpi_grp_).and.iter == 0) then
1512 call td_write_print_header_init(out_multip)
1513
1514 write(aux, '(a15,i2)') '# nspin ', st%d%nspin
1515 call write_iter_string(out_multip, aux)
1516 call write_iter_nl(out_multip)
1517
1518 write(aux, '(a15,i2)') '# lmax ', lmax
1519 call write_iter_string(out_multip, aux)
1520 call write_iter_nl(out_multip)
1521
1522 call kick_write(kick, out = out_multip)
1523
1524 call write_iter_header_start(out_multip)
1525
1526 do is = 1, st%d%nspin
1527 write(aux,'(a18,i1,a1)') 'Electronic charge(', is,')'
1528 call write_iter_header(out_multip, aux)
1529 if (lmax > 0) then
1530 do idir = 1, space%dim
1531 write(aux, '(4a1,i1,a1)') '<', index2axis(idir), '>', '(', is,')'
1532 call write_iter_header(out_multip, aux)
1533 end do
1534 end if
1535 do ll = 2, lmax
1536 do mm = -ll, ll
1537 write(aux, '(a2,i2,a4,i2,a2,i1,a1)') 'l=', ll, ', m=', mm, ' (', is,')'
1538 call write_iter_header(out_multip, aux)
1539 end do
1540 end do
1541 end do
1542 call write_iter_nl(out_multip)
1543
1544 ! units
1545 call write_iter_string(out_multip, '#[Iter n.]')
1546 call write_iter_header(out_multip, '[' // trim(units_abbrev(units_out%time)) // ']')
1547
1548 do is = 1, st%d%nspin
1549 call write_iter_header(out_multip, 'Electrons')
1550 if (lmax > 0) then
1551 do idir = 1, space%dim
1552 call write_iter_header(out_multip, '[' // trim(units_abbrev(units_out%length)) // ']')
1553 end do
1554 end if
1555 do ll = 2, lmax
1556 do mm = -ll, ll
1557 write(aux, '(a,a2,i1)') trim(units_abbrev(units_out%length)), "**", ll
1558 call write_iter_header(out_multip, '[' // trim(aux) // ']')
1559 end do
1560 end do
1561 end do
1562 call write_iter_nl(out_multip)
1563
1564 call td_write_print_header_end(out_multip)
1565 end if
1566
1567 if (space%dim > 3 .and. lmax == 1) then
1568 ! For higher dimensions we can only have up to the dipole
1569 safe_allocate(multipole(1:space%dim+1, 1:st%d%nspin))
1570 else
1571 safe_allocate(multipole(1:(lmax + 1)**2, 1:st%d%nspin))
1572 end if
1573 multipole(:,:) = m_zero
1574
1575 do is = 1, st%d%nspin
1576 call dmf_multipoles(mesh, rho(:,is), lmax, multipole(:,is))
1577 end do
1578
1579 if (lmax > 0) then
1580 ionic_dipole = ions%dipole()
1581 do is = 1, st%d%nspin
1582 multipole(2:space%dim+1, is) = -ionic_dipole(1:space%dim)/st%d%nspin - multipole(2:space%dim+1, is)
1583 end do
1584 end if
1585
1586 if (mpi_grp_is_root(mpi_grp_)) then
1587 call write_iter_start(out_multip)
1588 do is = 1, st%d%nspin
1589 call write_iter_double(out_multip, units_from_atomic(units_out%length**0, multipole(1, is)), 1)
1590 if (lmax > 0) then
1591 do idir = 1, space%dim
1592 call write_iter_double(out_multip, units_from_atomic(units_out%length, multipole(1+idir, is)), 1)
1593 end do
1594 end if
1595 add_lm = space%dim + 2
1596 do ll = 2, lmax
1597 do mm = -ll, ll
1598 call write_iter_double(out_multip, units_from_atomic(units_out%length**ll, multipole(add_lm, is)), 1)
1599 add_lm = add_lm + 1
1600 end do
1601 end do
1602 end do
1603 call write_iter_nl(out_multip)
1604 end if
1605
1606 safe_deallocate_a(multipole)
1607 pop_sub(td_write_multipole_r)
1608 end subroutine td_write_multipole_r
1609
1610 ! ---------------------------------------------------------
1611 subroutine td_write_ftchd(out_ftchd, space, mesh, st, kick, iter)
1612 type(c_ptr), intent(inout) :: out_ftchd
1613 class(space_t), intent(in) :: space
1614 class(mesh_t), intent(in) :: mesh
1615 type(states_elec_t), intent(in) :: st
1616 type(kick_t), intent(in) :: kick
1617 integer, intent(in) :: iter
1618
1619 integer :: is, ip, idir
1620 character(len=120) :: aux, aux2
1621 real(real64) :: ftchd_bessel
1622 complex(real64) :: ftchd
1623 real(real64) :: ylm
1624 real(real64), allocatable :: integrand_bessel(:)
1625 complex(real64), allocatable :: integrand(:)
1626
1627 push_sub(td_write_ftchd)
1628
1629 if (mpi_grp_is_root(mpi_world).and.iter == 0) then
1630 call td_write_print_header_init(out_ftchd)
1631
1632 write(aux,'(a15, i2)') '# qkickmode ', kick%qkick_mode
1633 call write_iter_string(out_ftchd, aux)
1634 call write_iter_nl(out_ftchd)
1635
1636 if (kick%qkick_mode == qkickmode_bessel) then
1637 write(aux,'(a15, i0.3, 1x, i0.3)') '# ll, mm ', kick%qbessel_l, kick%qbessel_m
1638 call write_iter_string(out_ftchd, aux)
1639 call write_iter_nl(out_ftchd)
1640 end if
1641
1642 if (kick%qkick_mode == qkickmode_bessel) then
1643 write(aux, '(a15, f9.6)') '# qlength ', kick%qlength
1644 else ! sin or cos
1645 write(aux, '(a15)') '# qvector '
1646 do idir = 1, space%dim
1647 write(aux2, '(f9.5)') kick%qvector(idir,1)
1648 aux = trim(aux) // trim(aux2)
1649 end do
1650 end if
1651 call write_iter_string(out_ftchd, aux)
1652 call write_iter_nl(out_ftchd)
1653
1654 write(aux, '(a15,f18.12)') '# kick strength', kick%delta_strength
1655 call write_iter_string(out_ftchd, aux)
1656 call write_iter_nl(out_ftchd)
1657
1658 call write_iter_header_start(out_ftchd)
1659 if (kick%qkick_mode == qkickmode_bessel) then
1660 write(aux,'(a17)') 'int(j_l*Y_lm*rho)'
1661 else
1662 write(aux,'(a12)') 'Real, Imag'
1663 end if
1664 call write_iter_header(out_ftchd, aux)
1665 call write_iter_nl(out_ftchd)
1666
1667 ! units
1668 call write_iter_string(out_ftchd, '#[Iter n.]')
1669 call write_iter_header(out_ftchd, '[' // trim(units_abbrev(units_out%time)) // ']')
1670 call write_iter_nl(out_ftchd)
1671 call td_write_print_header_end(out_ftchd)
1672
1673 end if
1674
1675 ftchd = m_zero
1676
1677 ! If kick mode is exp, sin, or cos, apply the normal Fourier transform
1678 if (kick%qkick_mode /= qkickmode_bessel) then
1679 safe_allocate(integrand(1:mesh%np))
1680 integrand = m_zero
1681 do is = 1, st%d%nspin
1682 do ip = 1, mesh%np
1683 integrand(ip) = integrand(ip) + st%rho(ip, is) * exp(-m_zi*sum(mesh%x(ip, 1:space%dim)*kick%qvector(1:space%dim, 1)))
1684 end do
1685 end do
1686 ftchd = zmf_integrate(mesh, integrand)
1687 safe_deallocate_a(integrand)
1688 else
1689 ftchd_bessel = m_zero
1690 safe_allocate(integrand_bessel(1:mesh%np))
1691 integrand_bessel = m_zero
1692 do is = 1, st%d%nspin
1693 do ip = 1, mesh%np
1694 call ylmr_real(mesh%x(ip, 1:3), kick%qbessel_l, kick%qbessel_m, ylm)
1695 integrand_bessel(ip) = integrand_bessel(ip) + st%rho(ip, is) * &
1696 loct_sph_bessel(kick%qbessel_l, kick%qlength*norm2(mesh%x(ip, :)))*ylm
1697 end do
1698 end do
1699 ftchd_bessel = dmf_integrate(mesh, integrand_bessel)
1700 safe_deallocate_a(integrand_bessel)
1701 end if
1702
1703 if (mpi_grp_is_root(mpi_world)) then
1704 call write_iter_start(out_ftchd)
1705 if (kick%qkick_mode == qkickmode_bessel) then
1706 call write_iter_double(out_ftchd, ftchd_bessel, 1)
1707 else ! exp, sin, cos
1708 call write_iter_double(out_ftchd, real(ftchd), 1)
1709 call write_iter_double(out_ftchd, aimag(ftchd), 1)
1710 end if
1711 call write_iter_nl(out_ftchd)
1712 end if
1713
1714 pop_sub(td_write_ftchd)
1715 end subroutine td_write_ftchd
1716
1717 ! ---------------------------------------------------------
1718 subroutine td_write_temperature(out_temperature, ions, iter)
1719 type(c_ptr), intent(inout) :: out_temperature
1720 type(ions_t), intent(in) :: ions
1721 integer, intent(in) :: iter
1722
1723 if (.not. mpi_grp_is_root(mpi_world)) return ! only first node outputs
1724
1725 push_sub(td_write_temperature)
1726
1727 if (iter == 0) then
1728 call td_write_print_header_init(out_temperature)
1729
1730 ! first line: column names
1731 call write_iter_header_start(out_temperature)
1732 call write_iter_header(out_temperature, 'Temperature')
1733 call write_iter_nl(out_temperature)
1734
1735 ! second line: units
1736 call write_iter_string(out_temperature, '#[Iter n.]')
1737 call write_iter_header(out_temperature, '[' // trim(units_abbrev(units_out%time)) // ']')
1738 call write_iter_string(out_temperature, ' [K]')
1739 call write_iter_nl(out_temperature)
1740
1741 call td_write_print_header_end(out_temperature)
1742 end if
1743
1744 call write_iter_start(out_temperature)
1745
1747
1748 call write_iter_nl(out_temperature)
1749
1750 pop_sub(td_write_temperature)
1751 end subroutine td_write_temperature
1752
1753
1754 ! ---------------------------------------------------------
1755 subroutine td_write_populations(out_populations, namespace, space, mesh, st, writ, dt, iter)
1756 type(c_ptr), intent(inout) :: out_populations
1757 type(namespace_t), intent(in) :: namespace
1758 class(space_t), intent(in) :: space
1759 class(mesh_t), intent(in) :: mesh
1760 type(states_elec_t), intent(inout) :: st
1761 type(td_write_t), intent(in) :: writ
1762 real(real64), intent(in) :: dt
1763 integer, intent(in) :: iter
1764
1765 integer :: ist
1766 character(len=6) :: excited_name
1767 complex(real64) :: gsp
1768 complex(real64), allocatable :: excited_state_p(:)
1769 complex(real64), allocatable :: dotprodmatrix(:, :, :)
1770
1771
1772 push_sub(td_write_populations)
1773
1774 safe_allocate(dotprodmatrix(1:writ%gs_st%nst, 1:st%nst, 1:st%nik))
1775 call zstates_elec_matrix(writ%gs_st, st, mesh, dotprodmatrix)
1776
1777
1778 !See comment in zstates_elec_mpdotp
1779 assert(.not. space%is_periodic())
1780
1781 ! all processors calculate the projection
1782 gsp = zstates_elec_mpdotp(namespace, mesh, writ%gs_st, st, dotprodmatrix)
1783
1784 if (writ%n_excited_states > 0) then
1785 safe_allocate(excited_state_p(1:writ%n_excited_states))
1786 do ist = 1, writ%n_excited_states
1787 excited_state_p(ist) = zstates_elec_mpdotp(namespace, mesh, writ%excited_st(ist), st, dotprodmatrix)
1788 end do
1789 end if
1790
1791 if (mpi_grp_is_root(mpi_world)) then
1792 if (iter == 0) then
1793 call td_write_print_header_init(out_populations)
1794
1795 ! first line -> column names
1796 call write_iter_header_start(out_populations)
1797 call write_iter_header(out_populations, 'Re<Phi_gs|Phi(t)>')
1798 call write_iter_header(out_populations, 'Im<Phi_gs|Phi(t)>')
1799 do ist = 1, writ%n_excited_states
1800 write(excited_name,'(a2,i3,a1)') 'P(', ist,')'
1801 call write_iter_header(out_populations, 'Re<'//excited_name//'|Phi(t)>')
1802 call write_iter_header(out_populations, 'Im<'//excited_name//'|Phi(t)>')
1803 end do
1804 call write_iter_nl(out_populations)
1805
1806 ! second line -> units
1807 call write_iter_string(out_populations, '#[Iter n.]')
1808 call write_iter_header(out_populations, '[' // trim(units_abbrev(units_out%time)) // ']')
1809 call write_iter_nl(out_populations)
1810
1811 call td_write_print_header_end(out_populations)
1812 end if
1813
1814 ! cannot call write_iter_start, for the step is not 1
1815 call write_iter_int(out_populations, iter, 1)
1816 call write_iter_double(out_populations, units_from_atomic(units_out%time, iter*dt), 1)
1817 call write_iter_double(out_populations, real(gsp), 1)
1818 call write_iter_double(out_populations, aimag(gsp), 1)
1819 do ist = 1, writ%n_excited_states
1820 call write_iter_double(out_populations, real(excited_state_p(ist)), 1)
1821 call write_iter_double(out_populations, aimag(excited_state_p(ist)), 1)
1822 end do
1823 call write_iter_nl(out_populations)
1824 end if
1825
1826 if (writ%n_excited_states > 0) then
1827 safe_deallocate_a(excited_state_p)
1828 end if
1829 safe_deallocate_a(dotprodmatrix)
1830 pop_sub(td_write_populations)
1831 end subroutine td_write_populations
1832
1833
1834 ! ---------------------------------------------------------
1835 subroutine td_write_acc(out_acc, namespace, space, gr, ions, st, hm, ext_partners, dt, iter)
1836 type(c_ptr), intent(inout) :: out_acc
1837 type(namespace_t), intent(in) :: namespace
1838 class(space_t), intent(in) :: space
1839 type(grid_t), intent(in) :: gr
1840 type(ions_t), intent(inout) :: ions
1841 type(states_elec_t), intent(inout) :: st
1842 type(hamiltonian_elec_t), intent(inout) :: hm
1843 type(partner_list_t), intent(in) :: ext_partners
1844 real(real64), intent(in) :: dt
1845 integer, intent(in) :: iter
1846
1847 integer :: idim
1848 character(len=7) :: aux
1849 real(real64) :: acc(space%dim)
1850
1851 push_sub(td_write_acc)
1852
1853 if (iter == 0 .and. mpi_grp_is_root(mpi_world)) then
1854 call td_write_print_header_init(out_acc)
1855
1856 ! first line -> column names
1857 call write_iter_header_start(out_acc)
1858 do idim = 1, space%dim
1859 write(aux, '(a4,i1,a1)') 'Acc(', idim, ')'
1860 call write_iter_header(out_acc, aux)
1861 end do
1862 call write_iter_nl(out_acc)
1863
1864 ! second line: units
1865 call write_iter_string(out_acc, '#[Iter n.]')
1866 call write_iter_header(out_acc, '[' // trim(units_abbrev(units_out%time)) // ']')
1867 do idim = 1, space%dim
1868 call write_iter_header(out_acc, '[' // trim(units_abbrev(units_out%acceleration)) // ']')
1869 end do
1870 call write_iter_nl(out_acc)
1871 call td_write_print_header_end(out_acc)
1872 end if
1873
1874 call td_calc_tacc(namespace, space, gr, ions, ext_partners, st, hm, acc, dt*iter)
1875
1876 if (mpi_grp_is_root(mpi_world)) then
1877 call write_iter_start(out_acc)
1878 acc = units_from_atomic(units_out%acceleration, acc)
1879 call write_iter_double(out_acc, acc, space%dim)
1880 call write_iter_nl(out_acc)
1881 end if
1882
1883 pop_sub(td_write_acc)
1884 end subroutine td_write_acc
1885
1886 ! ---------------------------------------------------------
1887 subroutine td_write_vel(out_vel, gr, st, space, kpoints, iter)
1888 type(c_ptr), intent(inout) :: out_vel
1889 type(grid_t), intent(in) :: gr
1890 type(states_elec_t), intent(in) :: st
1891 type(space_t), intent(in) :: space
1892 type(kpoints_t), intent(in) :: kpoints
1893 integer, intent(in) :: iter
1894
1895 integer :: idim
1896 character(len=7) :: aux
1897 real(real64) :: vel(space%dim)
1898
1899 push_sub(td_write_vel)
1900
1901 if (iter == 0 .and. mpi_grp_is_root(mpi_world)) then
1902 call td_write_print_header_init(out_vel)
1903
1904 ! first line -> column names
1905 call write_iter_header_start(out_vel)
1906 do idim = 1, space%dim
1907 write(aux, '(a4,i1,a1)') 'Vel(', idim, ')'
1908 call write_iter_header(out_vel, aux)
1909 end do
1910 call write_iter_nl(out_vel)
1911
1912 ! second line: units
1913 call write_iter_string(out_vel, '#[Iter n.]')
1914 call write_iter_header(out_vel, '[' // trim(units_abbrev(units_out%time)) // ']')
1915 do idim = 1, space%dim
1916 call write_iter_header(out_vel, '[' // trim(units_abbrev(units_out%velocity)) // ']')
1917 end do
1918 call write_iter_nl(out_vel)
1919 call td_write_print_header_end(out_vel)
1920 end if
1921
1922 call td_calc_tvel(gr, st, space, kpoints, vel)
1923
1924 if (mpi_grp_is_root(mpi_world)) then
1925 call write_iter_start(out_vel)
1926 vel = units_from_atomic(units_out%velocity, vel)
1927 call write_iter_double(out_vel, vel, space%dim)
1928 call write_iter_nl(out_vel)
1929 end if
1930
1931 pop_sub(td_write_vel)
1932 end subroutine td_write_vel
1933
1934
1935 ! ---------------------------------------------------------
1936 subroutine td_write_laser(out_laser, space, lasers, dt, iter)
1937 type(c_ptr), intent(inout) :: out_laser
1938 class(space_t), intent(in) :: space
1939 type(lasers_t), intent(inout) :: lasers
1940 real(real64), intent(in) :: dt
1941 integer, intent(in) :: iter
1942
1943 integer :: il, idir
1944 real(real64) :: field(space%dim)
1945 real(real64) :: ndfield(space%dim)
1946 character(len=80) :: aux
1947
1948 if (.not. mpi_grp_is_root(mpi_world)) return ! only first node outputs
1949
1950 ! no PUSH SUB, called too often
1951
1952 if (iter == 0) then
1953 call td_write_print_header_init(out_laser)
1954
1955 ! first line
1956 write(aux, '(a7,e20.12,3a)') '# dt = ', units_from_atomic(units_out%time, dt), &
1957 " [", trim(units_abbrev(units_out%time)), "]"
1958 call write_iter_string(out_laser, aux)
1959 call write_iter_nl(out_laser)
1960
1961 call write_iter_header_start(out_laser)
1962 do il = 1, lasers%no_lasers
1963 select case (laser_kind(lasers%lasers(il)))
1964 case (e_field_electric)
1965 do idir = 1, space%dim
1966 write(aux, '(a,i1,a)') 'E(', idir, ')'
1967 call write_iter_header(out_laser, aux)
1968 end do
1969 case (e_field_magnetic)
1970 do idir = 1, space%dim
1971 write(aux, '(a,i1,a)') 'B(', idir, ')'
1972 call write_iter_header(out_laser, aux)
1973 end do
1975 do idir = 1, space%dim
1976 write(aux, '(a,i1,a)') 'A(', idir, ')'
1977 call write_iter_header(out_laser, aux)
1978 end do
1980 write(aux, '(a,i1,a)') 'e(t)'
1981 call write_iter_header(out_laser, aux)
1982 end select
1983 end do
1984
1985 if (lasers_with_nondipole_field(lasers)) then
1986 do idir = 1, space%dim
1987 write(aux, '(a,i1,a)') 'A^M(', idir, ')'
1988 call write_iter_header(out_laser, aux)
1989 end do
1990 end if
1991 call write_iter_nl(out_laser)
1992
1993 call write_iter_string(out_laser, '#[Iter n.]')
1994 call write_iter_header(out_laser, '[' // trim(units_abbrev(units_out%time)) // ']')
1995
1996 ! Note that we do not print out units of E, B, or A, but rather units of e*E, e*B, e*A.
1997 ! (force, force, and energy, respectively). The reason is that the units of E, B or A
1998 ! are ugly.
1999 do il = 1, lasers%no_lasers
2000 select case (laser_kind(lasers%lasers(il)))
2002 aux = '[' // trim(units_abbrev(units_out%force)) // ']'
2003 do idir = 1, space%dim
2004 call write_iter_header(out_laser, aux)
2005 end do
2007 aux = '[' // trim(units_abbrev(units_out%energy)) // ']'
2008 do idir = 1, space%dim
2009 call write_iter_header(out_laser, aux)
2010 end do
2012 aux = '[adim]'
2013 call write_iter_header(out_laser, aux)
2014 end select
2015 end do
2016
2017 if (lasers_with_nondipole_field(lasers)) then
2018 aux = '[' // trim(units_abbrev(units_out%energy)) // ']'
2019 do idir = 1, space%dim
2020 call write_iter_header(out_laser, aux)
2021 end do
2022 end if
2023
2024
2025 call write_iter_nl(out_laser)
2026
2027 call td_write_print_header_end(out_laser)
2028 end if
2030 call write_iter_start(out_laser)
2031
2032 do il = 1, lasers%no_lasers
2033 field = m_zero
2034 call laser_field(lasers%lasers(il), field(1:space%dim), iter*dt)
2035 select case (laser_kind(lasers%lasers(il)))
2037 field = units_from_atomic(units_out%force, field)
2038 call write_iter_double(out_laser, field, space%dim)
2040 field = units_from_atomic(units_out%energy, field)
2041 call write_iter_double(out_laser, field, space%dim)
2043 call write_iter_double(out_laser, field(1), 1)
2044 end select
2045 end do
2046
2047 if (lasers_with_nondipole_field(lasers)) then
2048 call lasers_nondipole_laser_field_step(lasers, ndfield, iter*dt)
2049 call lasers_set_nondipole_parameters(lasers, ndfield, iter*dt)
2050 call write_iter_double(out_laser, ndfield, space%dim)
2051 end if
2052 call write_iter_nl(out_laser)
2053
2054 end subroutine td_write_laser
2055
2056
2057 ! ---------------------------------------------------------
2058 subroutine td_write_energy(out_energy, hm, iter, ke)
2059 type(c_ptr), intent(inout) :: out_energy
2060 type(hamiltonian_elec_t), intent(in) :: hm
2061 integer, intent(in) :: iter
2062 real(real64), intent(in) :: ke
2063
2064 integer :: ii
2065
2066 integer :: n_columns
2067
2068 if (.not. mpi_grp_is_root(mpi_world)) return ! only first node outputs
2069
2070 push_sub(td_write_energy)
2071
2072 n_columns = 9
2073
2074 if (iter == 0) then
2075 call td_write_print_header_init(out_energy)
2076
2077 ! first line -> column names
2078 call write_iter_header_start(out_energy)
2079 call write_iter_header(out_energy, 'Total')
2080 call write_iter_header(out_energy, 'Kinetic (ions)')
2081 call write_iter_header(out_energy, 'Ion-Ion')
2082 call write_iter_header(out_energy, 'Electronic')
2083 call write_iter_header(out_energy, 'Eigenvalues')
2084 call write_iter_header(out_energy, 'Hartree')
2085 call write_iter_header(out_energy, 'Int[n v_xc]')
2086 call write_iter_header(out_energy, 'Exchange')
2087 call write_iter_header(out_energy, 'Correlation')
2088
2089 if (hm%pcm%run_pcm) then
2090 call write_iter_header(out_energy, 'E_M-solvent')
2091 n_columns = n_columns + 1
2092 end if
2093
2094 if (hm%lda_u_level /= dft_u_none) then
2095 call write_iter_header(out_energy, 'Hubbard')
2096 n_columns = n_columns + 1
2097 end if
2098
2099 call write_iter_nl(out_energy)
2100
2101 ! units
2102
2103 call write_iter_string(out_energy, '#[Iter n.]')
2104 call write_iter_header(out_energy, '[' // trim(units_abbrev(units_out%time)) // ']')
2105
2106 do ii = 1, n_columns
2107 call write_iter_header(out_energy, '[' // trim(units_abbrev(units_out%energy)) // ']')
2108 end do
2109 call write_iter_nl(out_energy)
2110
2111
2112 call td_write_print_header_end(out_energy)
2113 end if
2114
2115 call write_iter_start(out_energy)
2116 call write_iter_double(out_energy, units_from_atomic(units_out%energy, hm%energy%total+ke), 1)
2117 call write_iter_double(out_energy, units_from_atomic(units_out%energy, ke), 1)
2118 call write_iter_double(out_energy, units_from_atomic(units_out%energy, hm%ep%eii), 1)
2119 call write_iter_double(out_energy, units_from_atomic(units_out%energy, hm%energy%total-hm%ep%eii), 1)
2120 call write_iter_double(out_energy, units_from_atomic(units_out%energy, hm%energy%eigenvalues), 1)
2121 call write_iter_double(out_energy, units_from_atomic(units_out%energy, hm%energy%hartree), 1)
2122 call write_iter_double(out_energy, units_from_atomic(units_out%energy, hm%energy%intnvxc), 1)
2123 call write_iter_double(out_energy, units_from_atomic(units_out%energy, hm%energy%exchange), 1)
2124 call write_iter_double(out_energy, units_from_atomic(units_out%energy, hm%energy%correlation), 1)
2125
2126 !adding the molecule-solvent electrostatic interaction
2127 if (hm%pcm%run_pcm) call write_iter_double(out_energy, &
2128 units_from_atomic(units_out%energy, hm%energy%int_ee_pcm + hm%energy%int_en_pcm + &
2129 hm%energy%int_nn_pcm + hm%energy%int_ne_pcm), 1)
2130
2131 if (hm%lda_u_level /= dft_u_none) then
2132 call write_iter_double(out_energy, units_from_atomic(units_out%energy, hm%energy%dft_u), 1)
2133 end if
2134
2135 call write_iter_nl(out_energy)
2136
2137 pop_sub(td_write_energy)
2138 end subroutine td_write_energy
2139
2140 ! ---------------------------------------------------------
2141 subroutine td_write_eigs(out_eigs, st, iter)
2142 type(c_ptr), intent(inout) :: out_eigs
2143 type(states_elec_t), intent(in) :: st
2144 integer, intent(in) :: iter
2145
2146 integer :: ii, is
2147 character(len=68) :: buf
2148
2149 push_sub(td_write_eigs)
2150
2152 pop_sub(td_write_eigs)
2153 return ! only first node outputs
2154 end if
2155
2156
2157 if (iter == 0) then
2158 call td_write_print_header_init(out_eigs)
2159
2160 write(buf, '(a15,i2)') '# nst ', st%nst
2161 call write_iter_string(out_eigs, buf)
2162 call write_iter_nl(out_eigs)
2163
2164 write(buf, '(a15,i2)') '# nspin ', st%d%nspin
2165 call write_iter_string(out_eigs, buf)
2166 call write_iter_nl(out_eigs)
2167
2168 ! first line -> column names
2169 call write_iter_header_start(out_eigs)
2170 do is = 1, st%d%kpt%nglobal
2171 do ii = 1, st%nst
2172 write(buf, '(a,i4)') 'Eigenvalue ',ii
2173 call write_iter_header(out_eigs, buf)
2174 end do
2175 end do
2176 call write_iter_nl(out_eigs)
2177
2178 ! second line: units
2179 call write_iter_string(out_eigs, '#[Iter n.]')
2180 call write_iter_header(out_eigs, '[' // trim(units_abbrev(units_out%time)) // ']')
2181 do is = 1, st%d%kpt%nglobal
2182 do ii = 1, st%nst
2183 call write_iter_header(out_eigs, '[' // trim(units_abbrev(units_out%energy)) // ']')
2184 end do
2185 end do
2186 call write_iter_nl(out_eigs)
2187 call td_write_print_header_end(out_eigs)
2188 end if
2189
2190 call write_iter_start(out_eigs)
2191 do is = 1, st%d%kpt%nglobal
2192 do ii =1 , st%nst
2193 call write_iter_double(out_eigs, units_from_atomic(units_out%energy, st%eigenval(ii,is)), 1)
2194 end do
2195 end do
2196 call write_iter_nl(out_eigs)
2197
2198 pop_sub(td_write_eigs)
2199 end subroutine td_write_eigs
2200
2201 ! ---------------------------------------------------------
2202 subroutine td_write_ionch(out_ionch, mesh, st, iter)
2203 type(c_ptr), intent(inout) :: out_ionch
2204 class(mesh_t), intent(in) :: mesh
2205 type(states_elec_t), intent(in) :: st
2206 integer, intent(in) :: iter
2207
2208 integer :: ii, ist, Nch, ik, idim
2209 character(len=68) :: buf
2210 real(real64), allocatable :: ch(:), occ(:)
2211 real(real64), allocatable :: occbuf(:)
2212
2213 push_sub(td_write_ionch)
2214
2215
2216 nch = st%nst * st%d%kpt%nglobal * st%d%dim
2217 safe_allocate(ch(0: nch))
2218 safe_allocate(occ(0: nch))
2219
2220 occ(:) = m_zero
2221 ii = 1
2222 do ik = 1, st%nik
2223 do ist = 1, st%nst
2224 do idim = 1, st%d%dim
2225 if (st%st_start <= ist .and. ist <= st%st_end .and. &
2226 st%d%kpt%start <= ik .and. ik <= st%d%kpt%end) then
2227 occ(ii) = st%occ(ist, ik)
2228 end if
2229 ii = ii+1
2230 end do
2231 end do
2232 end do
2233
2235 if (st%parallel_in_states) then
2236 safe_allocate(occbuf(0: nch))
2237 occbuf(:) = m_zero
2238 call st%mpi_grp%allreduce(occ(0), occbuf(0), nch+1, mpi_double_precision, mpi_sum)
2239 occ(:) = occbuf(:)
2240 safe_deallocate_a(occbuf)
2241 end if
2242
2243 !Calculate the channels
2244 call td_calc_ionch(mesh, st, ch, nch)
2245
2246
2247 if (.not. mpi_grp_is_root(mpi_world)) then
2248 safe_deallocate_a(ch)
2249 safe_deallocate_a(occ)
2250 pop_sub(td_write_ionch)
2251 return ! only first node outputs
2252 end if
2253
2254
2255 if (iter == 0) then
2256 call td_write_print_header_init(out_ionch)
2257
2258 ! first line -> column names
2259 call write_iter_header_start(out_ionch)
2260
2261 do ii = 0, nch
2262 if (occ(ii)>m_zero .or. ii == 0) then
2263 write(buf, '(a,f4.1,a)') 'Pion(',occ(ii)*ii,'+, t)'
2264 call write_iter_header(out_ionch, buf)
2265 end if
2266 end do
2267 call write_iter_nl(out_ionch)
2268
2269 ! second line: units
2270 call write_iter_string(out_ionch, '#[Iter n.]')
2271 call write_iter_header(out_ionch, '[' // trim(units_abbrev(units_out%time)) // ']')
2272 do ii = 0, nch
2273 if (occ(ii)>m_zero .or. ii == 0) then
2274 call write_iter_header(out_ionch, '[' // trim(units_abbrev(unit_one)) // ']')
2275 end if
2276 end do
2277 call write_iter_nl(out_ionch)
2278 call td_write_print_header_end(out_ionch)
2279 end if
2280
2281 call write_iter_start(out_ionch)
2282 do ii =0 , nch
2283 if (occ(ii)>m_zero .or. ii == 0) then
2284 call write_iter_double(out_ionch, units_from_atomic(unit_one, ch(ii)), 1)
2285 end if
2286 end do
2287 call write_iter_nl(out_ionch)
2288
2289 safe_deallocate_a(ch)
2290 safe_deallocate_a(occ)
2291
2292 pop_sub(td_write_ionch)
2293 end subroutine td_write_ionch
2294
2295 ! ---------------------------------------------------------
2296 subroutine td_write_proj(out_proj, space, mesh, ions, st, gs_st, td_start_proj, kick, iter)
2297 type(c_ptr), intent(inout) :: out_proj
2298 class(space_t), intent(in) :: space
2299 class(mesh_t), intent(in) :: mesh
2300 type(ions_t), intent(in) :: ions
2301 type(states_elec_t), intent(inout) :: st
2302 type(states_elec_t), intent(in) :: gs_st
2303 integer, intent(in) :: td_start_proj
2304 type(kick_t), intent(in) :: kick
2305 integer, intent(in) :: iter
2306
2307 complex(real64), allocatable :: projections(:,:,:)
2308 character(len=80) :: aux
2309 integer :: ik, ist, uist, idir
2310
2311 push_sub(td_write_proj)
2312
2313 if (iter == 0) then
2314 if (mpi_grp_is_root(mpi_world)) then
2315 call td_write_print_header_init(out_proj)
2316
2317 write(aux, '(a15,i2)') '# nspin ', st%d%nspin
2318 call write_iter_string(out_proj, aux)
2319 call write_iter_nl(out_proj)
2320
2321 call kick_write(kick, out = out_proj)
2322
2323 call write_iter_string(out_proj, "#%")
2324 call write_iter_nl(out_proj)
2325
2326 write(aux, '(a,i8)') "# nik ", st%nik
2327 call write_iter_string(out_proj, aux)
2328 call write_iter_nl(out_proj)
2329
2330 write(aux, '(a,2i8)') "# st ", td_start_proj, st%nst
2331 call write_iter_string(out_proj, aux)
2332 call write_iter_nl(out_proj)
2333
2334 write(aux, '(a,2i8)') "# ust ", td_start_proj, gs_st%st_end
2335 call write_iter_string(out_proj, aux)
2336 call write_iter_nl(out_proj)
2337
2338 do ik = 1, st%nik
2339 call write_iter_string(out_proj, "# w(ik)*occ(ist,ik) ")
2340 do ist = td_start_proj, st%nst
2341 call write_iter_double(out_proj, st%kweights(ik)*st%occ(ist, ik), 1)
2342 end do
2343 call write_iter_nl(out_proj)
2344 end do
2345
2346 call write_iter_header_start(out_proj)
2347 do ik = 1, st%nik
2348 do ist = td_start_proj, st%nst
2349 do uist = td_start_proj, gs_st%st_end
2350 write(aux, '(i4,a,i4)') ist, ' -> ', uist
2351 call write_iter_header(out_proj, 'Re {'//trim(aux)//'}')
2352 call write_iter_header(out_proj, 'Im {'//trim(aux)//'}')
2353 end do
2354 end do
2355 end do
2356 call write_iter_nl(out_proj)
2357
2358 end if
2359
2360 !The dipole matrix elements cannot be computed like that for solids
2361 if (.not. space%is_periodic()) then
2362
2363 safe_allocate(projections(td_start_proj:st%nst, td_start_proj:gs_st%st_end, 1:st%nik))
2364 do idir = 1, space%dim
2365 projections = m_z0
2366
2367 call dipole_matrix_elements(idir)
2368
2369 if (mpi_grp_is_root(mpi_world)) then
2370 write(aux, '(a,i1,a)') "<i|x_", idir, "|a>"
2371 call write_iter_string(out_proj, "# ------")
2372 call write_iter_header(out_proj, aux)
2373 do ik = 1, st%nik
2374 do ist = td_start_proj, st%nst
2375 do uist = td_start_proj, gs_st%nst
2376 call write_iter_double(out_proj, real(projections(ist, uist, ik), real64), 1)
2377 call write_iter_double(out_proj, aimag(projections(ist, uist, ik)), 1)
2378 end do
2379 end do
2380 end do
2381 call write_iter_nl(out_proj)
2382
2383 end if
2384 end do
2385 safe_deallocate_a(projections)
2386
2387 end if
2388
2390 call td_write_print_header_end(out_proj)
2391 end if
2392
2393 end if
2394
2395 safe_allocate(projections(td_start_proj:st%nst, td_start_proj:gs_st%nst, 1:st%nik))
2396 projections(:,:,:) = m_z0
2397 call calc_projections(mesh, st, gs_st, td_start_proj, projections)
2398
2399 if (mpi_grp_is_root(mpi_world)) then
2400 call write_iter_start(out_proj)
2401 do ik = 1, st%nik
2402 do ist = td_start_proj, st%nst
2403 do uist = td_start_proj, gs_st%nst
2404 call write_iter_double(out_proj, real(projections(ist, uist, ik), real64), 1)
2405 call write_iter_double(out_proj, aimag(projections(ist, uist, ik)), 1)
2406 end do
2407 end do
2408 end do
2409 call write_iter_nl(out_proj)
2410 end if
2411
2412 safe_deallocate_a(projections)
2413 pop_sub(td_write_proj)
2414
2415 contains
2416 ! ---------------------------------------------------------
2417 subroutine dipole_matrix_elements(dir)
2418 integer, intent(in) :: dir
2419
2420 integer :: uist, ist, ik, idim
2421 real(real64) :: n_dip(space%dim)
2422 complex(real64), allocatable :: xpsi(:,:)
2423 complex(real64), allocatable :: psi(:, :), gspsi(:, :)
2424
2426
2427 safe_allocate(psi(1:mesh%np, 1:st%d%dim))
2428 safe_allocate(gspsi(1:mesh%np, 1:st%d%dim))
2429 safe_allocate(xpsi(1:mesh%np, 1:st%d%dim))
2430
2431 do ik = st%d%kpt%start, st%d%kpt%end
2432 do ist = max(td_start_proj, st%st_start), st%st_end
2433 call states_elec_get_state(st, mesh, ist, ik, psi)
2434 do uist = max(td_start_proj, gs_st%st_start), gs_st%st_end
2435 call states_elec_get_state(gs_st, mesh, uist, ik, gspsi)
2436
2437 do idim = 1, st%d%dim
2438 xpsi(1:mesh%np, idim) = mesh%x(1:mesh%np, dir)*gspsi(1:mesh%np, idim)
2439 end do
2440 projections(ist, uist, ik) = -zmf_dotp(mesh, st%d%dim, psi, xpsi, reduce = .false.)
2441
2442 end do
2443 end do
2444 end do
2445
2446 safe_deallocate_a(xpsi)
2447 safe_deallocate_a(gspsi)
2448 safe_deallocate_a(psi)
2449
2450 call comm_allreduce(st%dom_st_kpt_mpi_grp, projections)
2451
2452 ! n_dip is not defined for more than space%dim
2453 n_dip = ions%dipole()
2454 do ik = 1, st%nik
2455 do ist = max(td_start_proj, st%st_start), st%nst
2456 do uist = max(td_start_proj, gs_st%st_start), gs_st%st_end
2457 projections(ist, uist, ik) = projections(ist, uist, ik) - n_dip(dir)
2458 end do
2459 end do
2460 end do
2461
2462
2464 end subroutine dipole_matrix_elements
2465
2466 end subroutine td_write_proj
2467
2468 ! ---------------------------------------------------------
2472 ! ---------------------------------------------------------
2473 subroutine td_write_n_ex(out_nex, outp, namespace, mesh, kpoints, st, gs_st, iter)
2474 type(c_ptr), intent(inout) :: out_nex
2475 type(output_t), intent(in) :: outp
2476 type(namespace_t), intent(in) :: namespace
2477 class(mesh_t), intent(in) :: mesh
2478 type(kpoints_t), intent(in) :: kpoints
2479 type(states_elec_t), intent(inout) :: st
2480 type(states_elec_t), intent(inout) :: gs_st
2481 integer, intent(in) :: iter
2482
2483 complex(real64), allocatable :: projections(:,:)
2484 character(len=80) :: aux, dir
2485 integer :: ik, ikpt, ist, uist, err
2486 real(real64) :: Nex, weight
2487 integer :: gs_nst
2488 real(real64), allocatable :: Nex_kpt(:)
2489
2490
2491 push_sub(td_write_n_ex)
2492
2493 if (iter == 0) then
2494 if (mpi_grp_is_root(mpi_world)) then
2495 call td_write_print_header_init(out_nex)
2496
2497 write(aux, '(a15,i2)') '# nspin ', st%d%nspin
2498 call write_iter_string(out_nex, aux)
2499 call write_iter_nl(out_nex)
2500
2501 call write_iter_string(out_nex, "#%")
2502 call write_iter_nl(out_nex)
2503
2504 write(aux, '(a,i8)') "# nik ", st%nik
2505 call write_iter_string(out_nex, aux)
2506 call write_iter_nl(out_nex)
2507
2508 write(aux, '(a,2i8)') "# st ", gs_st%st_start, st%nst
2509 call write_iter_string(out_nex, aux)
2510 call write_iter_nl(out_nex)
2511
2512 write(aux, '(a,2i8)') "# ust ", gs_st%st_start, gs_st%st_end
2513 call write_iter_string(out_nex, aux)
2514 call write_iter_nl(out_nex)
2515
2516 call write_iter_header_start(out_nex)
2517 call write_iter_header(out_nex, '# iter t Nex(t)')
2518 call write_iter_nl(out_nex)
2519
2520 end if
2521
2522 if (mpi_grp_is_root(mpi_world)) then
2523 call td_write_print_header_end(out_nex)
2524 end if
2525
2526 end if
2527
2528 !We only need the occupied GS states
2529 gs_nst = 1
2530 do ik = 1, st%nik
2531 do ist = 1, gs_st%nst
2532 if (gs_st%occ(ist, ik) > m_min_occ .and. ist > gs_nst) gs_nst = ist
2533 end do
2534 end do
2535
2536 safe_allocate(projections(1:gs_nst, 1:st%nst))
2537
2538 safe_allocate(nex_kpt(1:st%nik))
2539 nex_kpt = m_zero
2540 do ik = st%d%kpt%start, st%d%kpt%end
2541 ikpt = st%d%get_kpoint_index(ik)
2542 call zstates_elec_calc_projections(st, gs_st, namespace, mesh, ik, projections, gs_nst)
2543 do ist = 1, gs_nst
2544 weight = st%kweights(ik) * gs_st%occ(ist, ik)/ st%smear%el_per_state
2545 do uist = st%st_start, st%st_end
2546 nex_kpt(ikpt) = nex_kpt(ikpt) - weight * st%occ(uist, ik) * abs(projections(ist, uist))**2
2547 end do
2548 end do
2549 nex_kpt(ikpt) = nex_kpt(ikpt) + sum(st%occ(st%st_start:st%st_end, ik))*st%kweights(ik)
2550 end do
2551
2552 if (st%parallel_in_states .or. st%d%kpt%parallel) then
2553 call comm_allreduce(st%st_kpt_mpi_grp, nex_kpt)
2554 end if
2555
2556 nex = sum(nex_kpt)
2557
2558 if (mpi_grp_is_root(mpi_world)) then
2559 call write_iter_start(out_nex)
2560 call write_iter_double(out_nex, nex, 1)
2561 call write_iter_nl(out_nex)
2562
2563 ! now write down the k-resolved part
2564 write(dir, '(a,a,i7.7)') trim(outp%iter_dir),"td.", iter ! name of directory
2565
2566 call io_function_output_global_bz(outp%how(option__output__current_kpt) &
2567 + outp%how(option__output__density_kpt), dir, "n_excited_el_kpt", namespace, &
2568 kpoints, nex_kpt, unit_one, err)
2569 end if
2570
2571 safe_deallocate_a(projections)
2572 safe_deallocate_a(nex_kpt)
2573
2574 pop_sub(td_write_n_ex)
2575 end subroutine td_write_n_ex
2576
2577 ! ---------------------------------------------------------
2582 ! ---------------------------------------------------------
2583 subroutine calc_projections(mesh, st, gs_st, td_start_proj, projections)
2584 class(mesh_t), intent(in) :: mesh
2585 type(states_elec_t), intent(inout) :: st
2586 type(states_elec_t), intent(in) :: gs_st
2587 integer, intent(in) :: td_start_proj
2588 complex(real64), intent(inout) :: projections(td_start_proj:st%nst, td_start_proj:gs_st%nst, 1:st%nik)
2589
2590 integer :: uist, ist, ik
2591 complex(real64), allocatable :: psi(:, :), gspsi(:, :)
2592 push_sub(calc_projections)
2593
2594 safe_allocate(psi(1:mesh%np, 1:st%d%dim))
2595 safe_allocate(gspsi(1:mesh%np, 1:st%d%dim))
2596
2597 projections(:,:,:) = m_zero
2598
2599 do ik = st%d%kpt%start, st%d%kpt%end
2600 do ist = max(td_start_proj, st%st_start), st%st_end
2601 call states_elec_get_state(st, mesh, ist, ik, psi)
2602 do uist = max(td_start_proj, gs_st%st_start), gs_st%st_end
2603 call states_elec_get_state(gs_st, mesh, uist, ik, gspsi)
2604 projections(ist, uist, ik) = zmf_dotp(mesh, st%d%dim, psi, gspsi, reduce = .false.)
2605 end do
2606 end do
2607 end do
2608
2609 safe_deallocate_a(psi)
2610 safe_deallocate_a(gspsi)
2611
2612 call comm_allreduce(st%dom_st_kpt_mpi_grp, projections)
2613
2614 pop_sub(calc_projections)
2615 end subroutine calc_projections
2616
2617
2618 subroutine td_write_proj_kp(mesh, kpoints, st, gs_st, namespace, iter)
2619 class(mesh_t), intent(in) :: mesh
2620 type(kpoints_t), intent(in) :: kpoints
2621 type(states_elec_t), intent(in) :: st
2622 type(states_elec_t), intent(inout) :: gs_st
2623 type(namespace_t), intent(in) :: namespace
2624 integer, intent(in) :: iter
2625
2626 complex(real64), allocatable :: proj(:,:), psi(:,:,:), gs_psi(:,:,:), temp_state(:,:)
2627 character(len=80) :: filename1, filename2
2628 integer :: ik,ist, jst, file, idim, nk_proj
2629
2630 push_sub(td_write_proj_kp)
2631
2632 write(filename1,'(I10)') iter
2633 filename1 = 'td.general/projections_iter_'//trim(adjustl(filename1))
2634 file = 9845623
2635
2636 safe_allocate(proj(1:gs_st%nst, 1:gs_st%nst))
2637 safe_allocate(psi(1:gs_st%nst,1:gs_st%d%dim,1:mesh%np))
2638 safe_allocate(gs_psi(1:gs_st%nst,1:gs_st%d%dim,1:mesh%np))
2639 safe_allocate(temp_state(1:mesh%np,1:gs_st%d%dim))
2640
2641 ! Project only k-points that have a zero weight.
2642 ! Why? It is unlikely that one is interested in the projections
2643 ! of the Monkhorst-Pack kpoints, but instead we assume that
2644 ! the user has specified a k-path with zero weights
2645 nk_proj = kpoints%nik_skip
2646
2647 do ik = kpoints%reduced%npoints-nk_proj+1, kpoints%reduced%npoints
2648 ! reset arrays
2649 psi(1:gs_st%nst, 1:gs_st%d%dim, 1:mesh%np)= m_zero
2650 gs_psi(1:gs_st%nst, 1:gs_st%d%dim, 1:mesh%np)= m_zero
2651 ! open file for writing
2652 if (mpi_world%rank == 0) then
2653 write(filename2,'(I10)') ik
2654 filename2 = trim(adjustl(filename1))//'_ik_'//trim(adjustl(filename2))
2655 file = io_open(filename2, namespace, action='write')
2656 end if
2657 ! get all states at ik that are locally stored (ground state and td-states)
2658 do ist=gs_st%st_start,gs_st%st_end
2659 if (state_kpt_is_local(gs_st, ist, ik)) then
2660 call states_elec_get_state(st, mesh, ist, ik,temp_state)
2661 do idim = 1,gs_st%d%dim
2662 psi(ist,idim,1:mesh%np) = temp_state(1:mesh%np,idim)
2663 end do
2664 call states_elec_get_state(gs_st, mesh, ist, ik, temp_state)
2665 do idim = 1,gs_st%d%dim
2666 gs_psi(ist,idim,1:mesh%np) = temp_state(1:mesh%np,idim)
2667 end do
2668 end if
2669 end do
2670 ! collect states at ik from all processes in one array
2671 call comm_allreduce(mpi_world, psi)
2672 call comm_allreduce(mpi_world, gs_psi)
2673
2674 ! compute the overlaps as a matrix product
2675 assert(mesh%np_global*gs_st%d%dim < huge(0_int32))
2676 proj(1:gs_st%nst, 1:gs_st%nst) = m_zero
2677 call zgemm('n', &
2678 'c', &
2679 gs_st%nst, &
2680 gs_st%nst, &
2681 i8_to_i4(mesh%np_global*gs_st%d%dim), &
2682 cmplx(mesh%volume_element, m_zero, real64) , &
2683 psi(1, 1, 1), &
2684 ubound(psi, dim = 1), &
2685 gs_psi(1, 1, 1), &
2686 ubound(gs_psi, dim = 1), &
2687 m_z0, &
2688 proj(1, 1), &
2689 ubound(proj, dim = 1))
2690
2691 ! write to file
2692 if (mpi_world%rank == 0) then
2693 do ist = 1, gs_st%nst
2694 do jst = 1, gs_st%nst
2695 write(file,'(I3,1x,I3,1x,e13.6,1x,e13.6,2x)') ist, jst, proj(ist,jst)
2696 end do
2697 end do
2698 call io_close(file)
2699 end if
2700
2701 end do! ik
2702
2703 safe_deallocate_a(proj)
2704 safe_deallocate_a(psi)
2705 safe_deallocate_a(gs_psi)
2706 safe_deallocate_a(temp_state)
2707
2708 pop_sub(td_write_proj_kp)
2709 end subroutine td_write_proj_kp
2710
2711 !---------------------------------------
2712 subroutine td_write_floquet(namespace, space, hm, ext_partners, mesh, st, iter)
2713 type(namespace_t), intent(in) :: namespace
2714 class(space_t), intent(in) :: space
2715 type(hamiltonian_elec_t), intent(inout) :: hm
2716 type(partner_list_t), intent(in) :: ext_partners
2717 class(mesh_t), intent(in) :: mesh
2718 type(states_elec_t), intent(inout) :: st
2719 integer, intent(in) :: iter
2720
2721 complex(real64), allocatable :: hmss(:,:), psi(:,:,:), hpsi(:,:,:), temp_state1(:,:)
2722 complex(real64), allocatable :: HFloquet(:,:,:), HFloq_eff(:,:), temp(:,:)
2723 real(real64), allocatable :: eigenval(:), bands(:,:)
2724 character(len=80) :: filename
2725 integer :: it, nT, ik, ist, in, im, file, idim, nik, ik_count
2726 integer :: Forder, Fdim, m0, n0, n1, nst, ii, jj, lim_nst
2727 logical :: downfolding
2728 type(states_elec_t) :: hm_st
2729
2730 real(real64) :: dt, Tcycle, omega
2731
2732 push_sub(td_write_floquet)
2733
2734 downfolding = .false.
2735
2736 ! this does not depend on propagation, so we do it only once
2737 if (.not. iter == 0) then
2738 pop_sub(td_write_floquet)
2739 return
2740 end if
2741
2742 nst = st%nst
2743
2744 !for now no domain distributionallowed
2745 assert(mesh%np == mesh%np_global)
2746
2747 ! this is used to initialize the hpsi (more effiecient ways?)
2748 call states_elec_copy(hm_st, st)
2749
2750 !%Variable TDFloquetFrequency
2751 !%Type float
2752 !%Default 0
2753 !%Section Time-Dependent::TD Output
2754 !%Description
2755 !% Frequency for the Floquet analysis, this should be the carrier frequency or integer multiples of it.
2756 !% Other options will work, but likely be nonsense.
2757 !%
2758 !%End
2759 call parse_variable(namespace, 'TDFloquetFrequency', m_zero, omega, units_inp%energy)
2760 call messages_print_var_value('Frequency used for Floquet analysis', omega, namespace=namespace)
2761 if (abs(omega) <= m_epsilon) then
2762 message(1) = "Please give a non-zero value for TDFloquetFrequency"
2763 call messages_fatal(1, namespace=namespace)
2764 end if
2765
2766 ! get time of one cycle
2767 tcycle = m_two * m_pi / omega
2768
2769 !%Variable TDFloquetSample
2770 !%Type integer
2771 !%Default 20
2772 !%Section Time-Dependent::TD Output
2773 !%Description
2774 !% Number of points on which one Floquet cycle is sampled in the time-integral of the Floquet analysis.
2775 !%
2776 !%End
2777 call parse_variable(namespace, 'TDFloquetSample',20 ,nt)
2778 call messages_print_var_value('Number of Floquet time-sampling points', nt, namespace=namespace)
2779 dt = tcycle/real(nt, real64)
2780
2781 !%Variable TDFloquetDimension
2782 !%Type integer
2783 !%Default -1
2784 !%Section Time-Dependent::TD Output
2785 !%Description
2786 !% Order of Floquet Hamiltonian. If negative number is given, downfolding is performed.
2787 !%End
2788 call parse_variable(namespace, 'TDFloquetDimension',-1,forder)
2789 if (forder .ge. 0) then
2790 call messages_print_var_value('Order of multiphoton Floquet-Hamiltonian', forder, namespace=namespace)
2791 !Dimension of multiphoton Floquet-Hamiltonian
2792 fdim = 2 * forder + 1
2793 else
2794 message(1) = 'Floquet-Hamiltonian is downfolded'
2795 call messages_info(1, namespace=namespace)
2796 downfolding = .true.
2797 forder = 1
2798 fdim = 3
2799 end if
2800
2801 dt = tcycle/real(nt, real64)
2802
2803 ! we are only interested for k-point with zero weight
2804 nik = hm%kpoints%nik_skip
2806 safe_allocate(hmss(1:nst,1:nst))
2807 safe_allocate( psi(1:nst,1:st%d%dim,1:mesh%np))
2808 safe_allocate(hpsi(1:nst,1:st%d%dim,1:mesh%np))
2809 safe_allocate(temp_state1(1:mesh%np,1:st%d%dim))
2810
2811 ! multiphoton Floquet Hamiltonian, layout:
2812 ! (H_{-n,-m} ... H_{-n,0} ... H_{-n,m})
2813 ! ( . . . . . )
2814 ! H = (H_{0,-m} ... H_{0,0} ... H_{0,m} )
2815 ! ( . . . . . )
2816 ! (H_{n,-m} ... H_{n,0} ... H_{n,m} )
2817 safe_allocate(hfloquet(1:nik,1:nst*fdim, 1:nst*fdim))
2818 hfloquet(1:nik,1:nst*fdim, 1:nst*fdim) = m_zero
2819
2820 ! perform time-integral over one cycle
2821 do it = 1, nt
2822 ! get non-interacting Hamiltonian at time (offset by one cycle to allow for ramp)
2823 call hm%update(mesh, namespace, space, ext_partners, time=tcycle+it*dt)
2824 ! get hpsi
2825 call zhamiltonian_elec_apply_all(hm, namespace, mesh, st, hm_st)
2826
2827 ! project Hamiltonian into grounstates for zero weight k-points
2828 ik_count = 0
2829
2830 do ik = hm%kpoints%reduced%npoints-nik+1, hm%kpoints%reduced%npoints
2831 ik_count = ik_count + 1
2832
2833 psi(1:nst, 1:st%d%dim, 1:mesh%np)= m_zero
2834 hpsi(1:nst, 1:st%d%dim, 1:mesh%np)= m_zero
2835
2836 do ist = st%st_start, st%st_end
2837 if (state_kpt_is_local(st, ist, ik)) then
2838 call states_elec_get_state(st, mesh, ist, ik,temp_state1)
2839 do idim = 1, st%d%dim
2840 psi(ist, idim, 1:mesh%np) = temp_state1(1:mesh%np,idim)
2841 end do
2842 call states_elec_get_state(hm_st, mesh, ist, ik,temp_state1)
2843 do idim = 1, st%d%dim
2844 hpsi(ist, idim,1:mesh%np) = temp_state1(1:mesh%np,idim)
2845 end do
2846 end if
2847 end do
2848 call comm_allreduce(mpi_world, psi)
2849 call comm_allreduce(mpi_world, hpsi)
2850 assert(mesh%np_global*st%d%dim < huge(0_int32))
2851 hmss(1:nst,1:nst) = m_zero
2852 call zgemm( 'n', &
2853 'c', &
2854 nst, &
2855 nst, &
2856 i8_to_i4(mesh%np_global*st%d%dim), &
2857 cmplx(mesh%volume_element, m_zero, real64) , &
2858 hpsi(1, 1, 1), &
2859 ubound(hpsi, dim = 1), &
2860 psi(1, 1, 1), &
2861 ubound(psi, dim = 1), &
2862 m_z0, &
2863 hmss(1, 1), &
2864 ubound(hmss, dim = 1))
2865
2866 hmss(1:nst,1:nst) = conjg(hmss(1:nst,1:nst))
2867
2868 ! accumulate the Floqeut integrals
2869 do in = -forder, forder
2870 do im = -forder, forder
2871 ii = (in+forder) * nst
2872 jj = (im+forder) * nst
2873 hfloquet(ik_count, ii+1:ii+nst, jj+1:jj+nst) = &
2874 hfloquet(ik_count, ii+1:ii+nst, jj+1:jj+nst) + hmss(1:nst, 1:nst) * exp(-(in-im)*m_zi*omega*it*dt)
2875 ! diagonal term
2876 if (in == im) then
2877 do ist = 1, nst
2878 hfloquet(ik_count, ii+ist, ii+ist) = hfloquet(ik_count, ii+ist, ii+ist) + in*omega
2879 end do
2880 end if
2881 end do
2882 end do
2883 end do !ik
2884
2885 end do ! it
2886
2887 hfloquet(:,:,:) = m_one/nt*hfloquet(:,:,:)
2888
2889 ! diagonalize Floquet Hamiltonian
2890 if (downfolding) then
2891 ! here perform downfolding
2892 safe_allocate(hfloq_eff(1:nst,1:nst))
2893 safe_allocate(eigenval(1:nst))
2894 safe_allocate(bands(1:nik,1:nst))
2895
2896 hfloq_eff(1:nst,1:nst) = m_zero
2897 do ik = 1, nik
2898 ! the HFloquet blocks are copied directly out of the super matrix
2899 m0 = nst ! the m=0 start position
2900 n0 = nst ! the n=0 start postion
2901 n1 = 2*nst ! the n=+1 start postion
2902 hfloq_eff(1:nst, 1:nst) = hfloquet(ik, n0+1:n0+nst, m0+1:m0+nst) + &
2903 m_one/omega*(matmul(hfloquet(ik, 1:nst, m0+1:m0+nst), hfloquet(ik, n1+1:n1+nst, m0+1:m0+nst))- &
2904 matmul(hfloquet(ik, n1+1:n1+nst, m0+1:m0+nst), hfloquet(ik, 1:nst, m0+1:m0+nst)))
2905
2906 call lalg_eigensolve(nst, hfloq_eff, eigenval)
2907 bands(ik,1:nst) = eigenval(1:nst)
2908 end do
2909 safe_deallocate_a(hfloq_eff)
2910 else
2911 ! the full Floquet
2912 safe_allocate(eigenval(1:nst*fdim))
2913 safe_allocate(bands(1:nik,1:nst*fdim))
2914 safe_allocate(temp(1:nst*fdim, 1:nst*fdim))
2915
2916 do ik = 1, nik
2917 temp(1:nst*fdim, 1:nst*fdim) = hfloquet(ik, 1:nst*fdim, 1:nst*fdim)
2918 call lalg_eigensolve(nst*fdim, temp, eigenval)
2919 bands(ik, 1:nst*fdim) = eigenval(1:nst*fdim)
2920 end do
2921 end if
2922
2923 !write bandstructure to file
2924 if (downfolding) then
2925 lim_nst = nst
2926 filename = "downfolded_floquet_bands"
2927 else
2928 lim_nst = nst*fdim
2929 filename = "floquet_bands"
2930 end if
2931 ! write bands (full or downfolded)
2932 if (mpi_world%rank == 0) then
2933 file = 987254
2934 file = io_open(filename, namespace, action = 'write')
2935 do ik = 1,nik
2936 do ist = 1,lim_nst
2937 write(file,'(e13.6, 1x)',advance='no') bands(ik,ist)
2938 end do
2939 write(file,'(1x)')
2940 end do
2941 call io_close(file)
2942 end if
2943
2944 if (.not. downfolding) then
2945 ! for the full Floquet case compute also the trivially shifted
2946 ! Floquet bands for reference (i.e. setting H_{nm}=0 for n!=m)
2947 bands(1:nik, 1:nst*fdim) = m_zero
2948 do ik = 1, nik
2949 temp(1:nst*fdim,1:nst*fdim) = m_zero
2950 do jj = 0, fdim - 1
2951 ii = jj * nst
2952 temp(ii+1:ii+nst, ii+1:ii+nst) = hfloquet(ik, ii+1:ii+nst, ii+1:ii+nst)
2953 end do
2954 call lalg_eigensolve(nst*fdim, temp, eigenval)
2955 bands(ik, 1:nst*fdim) = eigenval(1:nst*fdim)
2956 end do
2957
2958 if (mpi_world%rank == 0) then
2959 filename = 'trivial_floquet_bands'
2960 file = io_open(filename, namespace, action = 'write')
2961 do ik=1,nik
2962 do ist = 1,lim_nst
2963 write(file,'(e13.6, 1x)', advance='no') bands(ik,ist)
2964 end do
2965 write(file,'(1x)')
2966 end do
2967 call io_close(file)
2968 end if
2969 end if
2970
2971 ! reset time in Hamiltonian
2972 call hm%update(mesh, namespace, space, ext_partners, time=m_zero)
2973
2974 safe_deallocate_a(hmss)
2975 safe_deallocate_a(psi)
2976 safe_deallocate_a(hpsi)
2977 safe_deallocate_a(temp_state1)
2978 safe_deallocate_a(hfloquet)
2979 safe_deallocate_a(eigenval)
2980 safe_deallocate_a(bands)
2981 safe_deallocate_a(temp)
2982
2983 pop_sub(td_write_floquet)
2984
2985 end subroutine td_write_floquet
2986
2987 ! ---------------------------------------------------------
2988 subroutine td_write_total_current(out_total_current, space, mesh, st, iter)
2989 type(c_ptr), intent(inout) :: out_total_current
2990 class(space_t), intent(in) :: space
2991 class(mesh_t), intent(in) :: mesh
2992 type(states_elec_t), intent(in) :: st
2993 integer, intent(in) :: iter
2994
2995 integer :: idir, ispin
2996 character(len=50) :: aux
2997 real(real64) :: total_current(space%dim), abs_current(space%dim)
2998
2999 push_sub(td_write_total_current)
3000
3001 if (mpi_grp_is_root(mpi_world) .and. iter == 0) then
3002 call td_write_print_header_init(out_total_current)
3003
3004 ! first line: column names
3005 call write_iter_header_start(out_total_current)
3006
3007 do idir = 1, space%dim
3008 write(aux, '(a2,a1,a1)') 'I(', index2axis(idir), ')'
3009 call write_iter_header(out_total_current, aux)
3010 end do
3011
3012 do idir = 1, space%dim
3013 write(aux, '(a10,a1,a1)') 'IntAbs(j)(', index2axis(idir), ')'
3014 call write_iter_header(out_total_current, aux)
3015 end do
3016
3017 do ispin = 1, st%d%nspin
3018 do idir = 1, space%dim
3019 write(aux, '(a4,i1,a1,a1,a1)') 'I-sp', ispin, '(', index2axis(idir), ')'
3020 call write_iter_header(out_total_current, aux)
3021 end do
3022 end do
3023
3024 call write_iter_nl(out_total_current)
3025
3026 call td_write_print_header_end(out_total_current)
3027 end if
3028
3029 assert(allocated(st%current))
3030
3031 if (mpi_grp_is_root(mpi_world)) then
3032 call write_iter_start(out_total_current)
3033 end if
3034
3035 total_current = 0.0_real64
3036 do idir = 1, space%dim
3037 do ispin = 1, st%d%spin_channels
3038 total_current(idir) = total_current(idir) + dmf_integrate(mesh, st%current(:, idir, ispin), reduce = .false.)
3039 end do
3040 total_current(idir) = units_from_atomic(units_out%length/units_out%time, total_current(idir))
3041 end do
3042 call mesh%allreduce(total_current, dim = space%dim)
3043
3044 abs_current = 0.0_real64
3045 do idir = 1, space%dim
3046 do ispin = 1, st%d%spin_channels
3047 abs_current(idir) = abs_current(idir) + dmf_integrate(mesh, abs(st%current(:, idir, ispin)), reduce = .false.)
3048 end do
3049 abs_current(idir) = units_from_atomic(units_out%length/units_out%time, abs_current(idir))
3050 end do
3051 call mesh%allreduce(abs_current, dim = space%dim)
3052
3053 if (mpi_grp_is_root(mpi_world)) then
3054 call write_iter_double(out_total_current, total_current, space%dim)
3055 call write_iter_double(out_total_current, abs_current, space%dim)
3056 end if
3057
3058 do ispin = 1, st%d%nspin
3059 total_current = units_from_atomic(units_out%length/units_out%time, dmf_integrate(mesh, space%dim, st%current(:, :, ispin)))
3060
3061 if (mpi_grp_is_root(mpi_world)) then
3062 call write_iter_double(out_total_current, total_current, space%dim)
3063 end if
3064 end do
3065
3066 if (mpi_grp_is_root(mpi_world)) then
3067 call write_iter_nl(out_total_current)
3068 end if
3069
3070 pop_sub(td_write_total_current)
3071 end subroutine td_write_total_current
3072
3073 ! ---------------------------------------------------------
3074
3075 subroutine td_write_total_heat_current(write_obj, space, hm, gr, st, iter)
3076 type(c_ptr), intent(inout) :: write_obj
3077 class(space_t), intent(in) :: space
3078 type(hamiltonian_elec_t), intent(inout) :: hm
3079 type(grid_t), intent(in) :: gr
3080 type(states_elec_t), intent(in) :: st
3081 integer, intent(in) :: iter
3082
3083 integer :: idir, ispin
3084 character(len=50) :: aux
3085 real(real64), allocatable :: heat_current(:, :, :)
3086 real(real64) :: total_current(space%dim)
3087
3089
3090 if (mpi_grp_is_root(mpi_world) .and. iter == 0) then
3091 call td_write_print_header_init(write_obj)
3092
3093 ! first line: column names
3094 call write_iter_header_start(write_obj)
3095
3096 do idir = 1, space%dim
3097 write(aux, '(a2,i1,a1)') 'Jh(', idir, ')'
3098 call write_iter_header(write_obj, aux)
3099 end do
3100
3101 call write_iter_nl(write_obj)
3102
3103 call td_write_print_header_end(write_obj)
3104 end if
3105
3106 safe_allocate(heat_current(1:gr%np, 1:space%dim, 1:st%d%nspin))
3107
3108 call current_heat_calculate(space, gr%der, hm, st, heat_current)
3109
3110 if (mpi_grp_is_root(mpi_world)) call write_iter_start(write_obj)
3111
3112 total_current = 0.0_real64
3113 do idir = 1, space%dim
3114 do ispin = 1, st%d%spin_channels
3115 total_current(idir) = total_current(idir) + dmf_integrate(gr, heat_current(:, idir, ispin))
3116 end do
3117 total_current(idir) = units_from_atomic(units_out%energy*units_out%length/units_out%time, total_current(idir))
3118 end do
3119
3120 safe_deallocate_a(heat_current)
3121
3122 if (mpi_grp_is_root(mpi_world)) call write_iter_double(write_obj, total_current, space%dim)
3123
3124 if (mpi_grp_is_root(mpi_world)) call write_iter_nl(write_obj)
3125
3127 end subroutine td_write_total_heat_current
3128
3129
3130 ! ---------------------------------------------------------
3131 subroutine td_write_partial_charges(out_partial_charges, mesh, st, ions, iter)
3132 type(c_ptr), intent(inout) :: out_partial_charges
3133 class(mesh_t), intent(in) :: mesh
3134 type(states_elec_t), intent(in) :: st
3135 type(ions_t), intent(in) :: ions
3136 integer, intent(in) :: iter
3137
3138 integer :: idir
3139 character(len=50) :: aux
3140 real(real64), allocatable :: hirshfeld_charges(:)
3141
3142 push_sub(td_write_partial_charges)
3143
3144 safe_allocate(hirshfeld_charges(1:ions%natoms))
3145
3146 call partial_charges_calculate(mesh, st, ions, hirshfeld_charges)
3147
3148 if (mpi_grp_is_root(mpi_world)) then
3149
3150 if (iter == 0) then
3151
3152 call td_write_print_header_init(out_partial_charges)
3153
3154 ! first line: column names
3155 call write_iter_header_start(out_partial_charges)
3156
3157 do idir = 1, ions%natoms
3158 write(aux, '(a13,i3,a1)') 'hirshfeld(atom=', idir, ')'
3159 call write_iter_header(out_partial_charges, aux)
3160 end do
3161
3162 call write_iter_nl(out_partial_charges)
3163
3164 call td_write_print_header_end(out_partial_charges)
3165 end if
3166
3167 call write_iter_start(out_partial_charges)
3169 call write_iter_double(out_partial_charges, hirshfeld_charges, ions%natoms)
3170
3171 call write_iter_nl(out_partial_charges)
3172 end if
3173
3174 safe_deallocate_a(hirshfeld_charges)
3175
3177 end subroutine td_write_partial_charges
3178
3179 ! ---------------------------------------------------------
3180 subroutine td_write_q(out_q, space, ks, iter)
3181 type(c_ptr), intent(inout) :: out_q
3182 class(space_t), intent(in) :: space
3183 type(v_ks_t), intent(in) :: ks
3184 integer, intent(in) :: iter
3185
3186 integer :: ii
3187 character(len=50) :: aux
3188
3189 push_sub(td_write_q)
3190
3191 if (mpi_grp_is_root(mpi_world)) then
3192 if (iter == 0) then
3193 call td_write_print_header_init(out_q)
3194 call write_iter_header_start(out_q)
3195 do ii = 1, ks%pt%nmodes
3196 write(aux, '(a1,i3,a3)') 'q', ii, '(t)'
3197 call write_iter_header(out_q, aux)
3198 end do
3199 do ii = 1, ks%pt%nmodes
3200 write(aux, '(a1,i3,a3)') 'p', ii, '(t)'
3201 call write_iter_header(out_q, aux)
3202 end do
3203 do ii = 1, space%dim
3204 write(aux, '(a3,i3,a3)') 'f_pt', ii, '(t)'
3205 call write_iter_header(out_q, aux)
3206 end do
3207 call write_iter_nl(out_q)
3208 call td_write_print_header_end(out_q)
3209 end if
3210
3211 call write_iter_start(out_q)
3212 call write_iter_double(out_q, ks%pt_mx%pt_q, ks%pt%nmodes)
3213 call write_iter_double(out_q, ks%pt_mx%pt_p, ks%pt%nmodes)
3214 call write_iter_double(out_q, ks%pt_mx%fmf, space%dim)
3215 call write_iter_nl(out_q)
3216 end if
3217
3218 pop_sub(td_write_q)
3219 end subroutine td_write_q
3220
3221
3222 ! ---------------------------------------------------------
3223 subroutine td_write_mxll_field(out_mxll, space, hm, dt, iter)
3224 type(c_ptr), intent(inout) :: out_mxll
3225 class(space_t), intent(in) :: space
3226 type(hamiltonian_elec_t),intent(in) :: hm
3227 real(real64), intent(in) :: dt
3228 integer, intent(in) :: iter
3229
3230 integer :: idir
3231 real(real64) :: field(space%dim)
3232 character(len=80) :: aux
3233 character(len=1) :: field_char
3234
3235 push_sub(td_write_mxll_field)
3236
3237 if (.not. mpi_grp_is_root(mpi_world)) then
3238 pop_sub(td_write_mxll_field)
3239 return ! only first node outputs
3240 end if
3241
3242 ! TODO: This is wrong if both are present
3243 ! Not clear how to solve this
3244 !A SSERT(hm%mxll%add_electric_dip .neqv. hm%mxll%add_magnetic_dip)
3245
3246 if (iter == 0) then
3247 call td_write_print_header_init(out_mxll)
3248
3249 write(aux, '(a7,e20.12,3a)') '# dt = ', units_from_atomic(units_out%time, dt), &
3250 " [", trim(units_abbrev(units_out%time)), "]"
3251 call write_iter_string(out_mxll, aux)
3252 call write_iter_nl(out_mxll)
3253
3254 call write_iter_header_start(out_mxll)
3255 select case (hm%mxll%coupling_mode)
3256 case (length_gauge_dipole, multipolar_expansion)
3257 if (hm%mxll%add_electric_dip) field_char = 'E'
3258 if (hm%mxll%add_magnetic_dip) field_char = 'B'
3259 do idir = 1, space%dim
3260 write(aux, '(a,i1,a)') field_char // '(', idir, ')'
3261 call write_iter_header(out_mxll, aux)
3262 end do
3263 case (velocity_gauge_dipole)
3264 do idir = 1, space%dim
3265 write(aux, '(a,i1,a)') 'A(', idir, ')'
3266 call write_iter_header(out_mxll, aux)
3267 end do
3268 end select
3269 call write_iter_nl(out_mxll)
3270
3271 call write_iter_string(out_mxll, '#[Iter n.]')
3272 call write_iter_header(out_mxll, '[' // trim(units_abbrev(units_out%time)) // ']')
3274 ! Note that we do not print out units of E, A or B, but rather units of e*E, e*A or e*B
3275 ! (force, energy and magnetic flux density, respectively).
3276 select case (hm%mxll%coupling_mode)
3277 case (length_gauge_dipole, multipolar_expansion)
3278 if (hm%mxll%add_electric_dip) aux = '[' // trim(units_abbrev(units_out%force)) // ']'
3279 if (hm%mxll%add_magnetic_dip) aux = '[' // trim(units_abbrev(unit_one/units_out%length**2)) // ']'
3280 do idir = 1, space%dim
3281 call write_iter_header(out_mxll, aux)
3282 end do
3283 case (velocity_gauge_dipole)
3284 aux = '[' // trim(units_abbrev(units_out%energy)) // ']'
3285 do idir = 1, space%dim
3286 call write_iter_header(out_mxll, aux)
3287 end do
3288 end select
3289 call write_iter_nl(out_mxll)
3290 call td_write_print_header_end(out_mxll)
3291 end if
3292
3293 call write_iter_start(out_mxll)
3294
3295 field = m_zero
3296 select case (hm%mxll%coupling_mode)
3297 case (length_gauge_dipole, multipolar_expansion)
3298 if (hm%mxll%add_electric_dip) field = units_from_atomic(units_out%force, hm%mxll%e_field_dip)
3299 if (hm%mxll%add_magnetic_dip) field = units_from_atomic(unit_one/units_out%length**2, hm%mxll%b_field_dip)
3300 call write_iter_double(out_mxll, field, space%dim)
3301 case (velocity_gauge_dipole)
3302 field = units_from_atomic(units_out%energy, hm%mxll%vec_pot_dip)
3303 call write_iter_double(out_mxll, field, space%dim)
3304 end select
3305 call write_iter_nl(out_mxll)
3306
3307 pop_sub(td_write_mxll_field)
3308 end subroutine td_write_mxll_field
3309
3310
3311 ! ---------------------------------------------------------
3312 subroutine td_write_effective_u(out_coords, lda_u, iter)
3313 type(c_ptr), intent(inout) :: out_coords
3314 type(lda_u_t), intent(in) :: lda_u
3315 integer, intent(in) :: iter
3317 integer :: ios, inn
3318 character(len=50) :: aux
3319
3320 if (.not. mpi_grp_is_root(mpi_world)) return ! only first node outputs
3321
3322 push_sub(td_write_effective_u)
3323
3324 if (iter == 0) then
3325 call td_write_print_header_init(out_coords)
3326
3327 ! first line: column names
3328 call write_iter_header_start(out_coords)
3329
3330 do ios = 1, lda_u%norbsets
3331 write(aux, '(a2,i3,a1)') 'Ueff(', ios, ')'
3332 call write_iter_header(out_coords, aux)
3333 end do
3334
3335 do ios = 1, lda_u%norbsets
3336 write(aux, '(a2,i3,a1)') 'U(', ios, ')'
3337 call write_iter_header(out_coords, aux)
3338 end do
3339
3340 do ios = 1, lda_u%norbsets
3341 write(aux, '(a2,i3,a1)') 'J(', ios, ')'
3342 call write_iter_header(out_coords, aux)
3343 end do
3344
3345 if (lda_u%intersite) then
3346 do ios = 1, lda_u%norbsets
3347 do inn = 1, lda_u%orbsets(ios)%nneighbors
3348 write(aux, '(a2,i3,a1,i3,a1)') 'V(', ios,'-', inn, ')'
3349 call write_iter_header(out_coords, aux)
3350 end do
3351 end do
3352 end if
3353
3354
3355 call write_iter_nl(out_coords)
3356
3357 ! second line: units
3358 call write_iter_string(out_coords, '#[Iter n.]')
3359 call write_iter_header(out_coords, '[' // trim(units_abbrev(units_out%time)) // ']')
3360 call write_iter_string(out_coords, &
3361 'Effective U ' // trim(units_abbrev(units_out%energy)) // &
3362 ', U in '// trim(units_abbrev(units_out%energy)) // &
3363 ', J in ' // trim(units_abbrev(units_out%energy)))
3364 call write_iter_nl(out_coords)
3365
3366 call td_write_print_header_end(out_coords)
3367 end if
3368
3369 call write_iter_start(out_coords)
3370
3371 do ios = 1, lda_u%norbsets
3372 call write_iter_double(out_coords, units_from_atomic(units_out%energy, &
3373 lda_u%orbsets(ios)%Ueff), 1)
3374 end do
3375
3376 do ios = 1, lda_u%norbsets
3377 call write_iter_double(out_coords, units_from_atomic(units_out%energy, &
3378 lda_u%orbsets(ios)%Ubar), 1)
3379 end do
3380
3381 do ios = 1, lda_u%norbsets
3382 call write_iter_double(out_coords, units_from_atomic(units_out%energy, &
3383 lda_u%orbsets(ios)%Jbar), 1)
3384 end do
3385
3386 if (lda_u%intersite) then
3387 do ios = 1, lda_u%norbsets
3388 do inn = 1, lda_u%orbsets(ios)%nneighbors
3389 call write_iter_double(out_coords, units_from_atomic(units_out%energy, &
3390 lda_u%orbsets(ios)%V_ij(inn,0)), 1)
3391 end do
3392 end do
3393 end if
3394
3395 call write_iter_nl(out_coords)
3396
3397 pop_sub(td_write_effective_u)
3398 end subroutine td_write_effective_u
3399
3401 subroutine td_write_norm_ks_orbitals(file_handle, grid, kpoints, st, iter)
3402 type(c_ptr), intent(inout) :: file_handle
3403 type(grid_t), intent(in) :: grid
3404 type(kpoints_t), intent(in) :: kpoints
3405 type(states_elec_t), intent(in) :: st
3406 integer, intent(in) :: iter
3407
3408 integer :: ik_ispin, ist
3409 character(len=7) :: nkpt_str, nst_str
3410 character(len=7) :: ik_str, ist_str
3411 real(real64), allocatable :: norm_ks(:, :)
3412 real(real64) :: n_electrons
3413
3415
3416 safe_allocate(norm_ks(1:st%nst, 1:st%nik))
3417 call states_elec_calc_norms(grid, kpoints, st, norm_ks)
3418
3419 if (mpi_grp_is_root(mpi_world)) then
3420 ! Header
3421 if (iter == 0) then
3422 call td_write_print_header_init(file_handle)
3423
3424 ! Line 1
3425 write(nkpt_str, '(I7)') st%nik
3426 write(nst_str, '(I7)') st%nst
3427 call write_iter_string(file_handle, '# Dimensions. (nstates, nkpt * nspin):')
3428 call write_iter_string(file_handle, trim(adjustl(nst_str)) // ' ' // trim(adjustl(nkpt_str)))
3429 call write_iter_nl(file_handle)
3430
3431 ! Line 2
3432 call write_iter_string(file_handle, '# Norm ordering: (istate, ikpoint_spin)')
3433 call write_iter_nl(file_handle)
3434
3435 ! Line 3
3436 call write_iter_header_start(file_handle)
3437 call write_iter_header(file_handle, 'N_electrons')
3438 do ik_ispin = 1, st%nik
3439 do ist = 1, st%nst
3440 write(ik_str, '(I7)') ik_ispin
3441 write(ist_str, '(I7)') ist
3442 call write_iter_header(file_handle, &
3443 'Norm (' // trim(ist_str) // ',' // trim(ik_str) // ')')
3444 enddo
3445 enddo
3446 call write_iter_nl(file_handle)
3447 call td_write_print_header_end(file_handle)
3448 end if
3449
3450 n_electrons = sum(st%occ * norm_ks**2)
3451
3452 ! Output norms for time step `iter`
3453 call write_iter_start(file_handle)
3454 call write_iter_double(file_handle, n_electrons, 1)
3455 do ik_ispin = 1, st%nik
3456 call write_iter_double(file_handle, norm_ks(:, ik_ispin), size(norm_ks, 1))
3457 enddo
3458 call write_iter_nl(file_handle)
3459
3460 end if
3461
3462 safe_deallocate_a(norm_ks)
3463
3465
3466 end subroutine td_write_norm_ks_orbitals
3467
3468 ! ---------------------------------------------------------
3470 subroutine td_write_cell_parameters(file_handle, ions, iter)
3471 type(c_ptr), intent(inout) :: file_handle
3472 type(ions_t), intent(in) :: ions
3473 integer, intent(in) :: iter
3474
3475 integer :: idir
3476 real(real64) :: tmp(3)
3477
3478 if (.not. mpi_grp_is_root(mpi_world)) return ! only first task outputs
3479
3480 push_sub(td_write_cell_parameters)
3481
3482 assert(ions%space%dim == 3)
3483
3484 if (iter == 0) then
3485 call td_write_print_header_init(file_handle)
3486
3487 ! first line: column names
3488 call write_iter_header_start(file_handle)
3489
3490 call write_iter_string(file_handle, '# Iter, a, b, c, volume, alpha, beta, gamma, ' &
3491 // 'a_x, a_y, a_z, b_x, b_y, b_z, c_x, c_y, c_z')
3492
3493 ! second line: units
3494 call write_iter_string(file_handle, '#[Iter n.]')
3495 call write_iter_header(file_handle, '[' // trim(units_abbrev(units_out%time)) // ']')
3496 call write_iter_string(file_handle, &
3497 'Lengths in ' // trim(units_abbrev(units_out%length)) // &
3498 ', Volume in ' // trim(units_abbrev(units_out%length**3)) // &
3499 ', Angles in degree, Lattice vectors in '// trim(units_abbrev(units_out%length)))
3500 call write_iter_nl(file_handle)
3501
3502 call td_write_print_header_end(file_handle)
3503 end if
3504
3505 call write_iter_start(file_handle)
3506
3507 ! Length of the lattice vectors
3508 do idir = 1, 3
3509 tmp(idir) = units_from_atomic(units_out%length, norm2(ions%latt%rlattice(1:3, idir)))
3510 end do
3511 call write_iter_double(file_handle, tmp, 3)
3512
3513 ! Cell volume
3514 tmp(1) = units_from_atomic(units_out%length**3, ions%latt%rcell_volume)
3515 call write_iter_double(file_handle, tmp(1), 1)
3516
3517 ! Lattice angles
3518 call write_iter_double(file_handle, ions%latt%alpha, 1)
3519 call write_iter_double(file_handle, ions%latt%beta, 1)
3520 call write_iter_double(file_handle, ions%latt%gamma, 1)
3521
3522 !Lattice vectors
3523 do idir = 1, 3
3524 tmp(1:3) = units_from_atomic(units_out%length, ions%latt%rlattice(:, idir))
3525 call write_iter_double(file_handle, tmp, 3)
3526 end do
3527 call write_iter_nl(file_handle)
3528
3530 end subroutine td_write_cell_parameters
3531
3532
3533 ! ---------------------------------------------------------
3534 subroutine td_write_mxll_init(writ, namespace, iter, dt)
3535 type(td_write_t), intent(out) :: writ
3536 type(namespace_t), intent(in) :: namespace
3537 integer, intent(in) :: iter
3538 real(real64), intent(in) :: dt
3539
3540 integer :: default, flags, iout, first
3541
3542 push_sub(td_write_mxll_init)
3543
3544 !%Variable MaxwellTDOutput
3545 !%Type flag
3546 !%Default maxwell_energy
3547 !%Section Maxwell::Output
3548 !%Description
3549 !% Defines what should be output during the time-dependent
3550 !% Maxwell simulation. Many of the options can increase the computational
3551 !% cost of the simulation, so only use the ones that you need. In
3552 !% most cases the default value is enough, as it is adapted to the
3553 !% details of the TD run.
3554 !% WARNING: the calculation of the longitudinal or transverse E and B fields
3555 !% can be very expensive, so please consider using the MaxwellOutput block
3556 !% to calculate and output these quantities at certain timesteps.
3557 !%Option maxwell_total_e_field 1
3558 !% Output of the total (longitudinal plus transverse) electric field at
3559 !% the points specified in the MaxwellFieldsCoordinate block
3560 !%Option maxwell_total_b_field 8
3561 !% Output of the total (longitudinal plus transverse) magnetic field at
3562 !% the points specified in the MaxwellFieldsCoordinate block
3563 !%Option maxwell_longitudinal_e_field 64
3564 !% Output of the longitudinal electric field at the points
3565 !% specified in the MaxwellFieldsCoordinate block (can slow down the run)
3566 !%Option maxwell_longitudinal_b_field 512
3567 !% Output of the longitudinal magnetic field at the points
3568 !% specified in the MaxwellFieldsCoordinate block (can slow down the run)
3569 !%Option maxwell_transverse_e_field 4096
3570 !% Output of the transverse electric field at the points
3571 !% specified in the MaxwellFieldsCoordinate block (can slow down the run)
3572 !%Option maxwell_transverse_b_field 32768
3573 !% Output of the transverse magnetic field at the points
3574 !% specified in the MaxwellFieldsCoordinate block (can slow down the run)
3575 !%Option maxwell_energy 262144
3576 !% Output of the electromagnetic field energy into the folder <tt>td.general/maxwell</tt>.
3577 !% WARNING: the transverse and longitudinal energies will be correct only if you request
3578 !% the longitudinal and transverse E or B fields as output. Otherwise they will be set to
3579 !% zero.
3580 !%Option e_field_surface_x 524288
3581 !% Output of the E field sliced along the plane x=0 for each field component
3582 !%Option e_field_surface_y 1048576
3583 !% Output of the E field sliced along the plane y=0 for each field component
3584 !%Option e_field_surface_z 2097152
3585 !% Output of the E field sliced along the plane z=0 for each field component
3586 !%Option b_field_surface_x 4194304
3587 !% Output of the B field sliced along the plane x=0 for each field component
3588 !%Option b_field_surface_y 8388608
3589 !% Output of the B field sliced along the plane y=0 for each field component
3590 !%Option b_field_surface_z 16777216
3591 !% Output of the B field sliced along the plane z=0 for each field component
3592 !%End
3593
3594 default = 2**(out_maxwell_energy - 1)
3595 call parse_variable(namespace, 'MaxwellTDOutput', default, flags)
3596
3597 if (.not. varinfo_valid_option('MaxwellTDOutput', flags, is_flag = .true.)) then
3598 call messages_input_error(namespace, 'MaxwellTDOutput')
3599 end if
3600
3602 writ%out(iout)%write = (iand(flags, 2**(iout - 1)) /= 0)
3603 if (writ%out(iout)%write) then
3604 writ%out(iout + 1)%write = .true.
3605 writ%out(iout + 2)%write = .true.
3606 end if
3607 end do
3608
3610 writ%out(iout)%write = (iand(flags, 2**(iout - 1)) /= 0)
3611 end do
3612
3613 if (iter == 0) then
3614 first = 0
3615 else
3616 first = iter + 1
3617 end if
3618
3619 call io_mkdir('td.general', namespace)
3620
3621 ! total E field
3622 if (writ%out(out_maxwell_total_e_field)%write) then
3623 call write_iter_init(writ%out(out_maxwell_total_e_field)%handle, first, &
3624 units_from_atomic(units_out%time, dt), trim(io_workpath("td.general/total_e_field_x", namespace)))
3625 call write_iter_init(writ%out(out_maxwell_total_e_field + 1)%handle, first, &
3626 units_from_atomic(units_out%time, dt), trim(io_workpath("td.general/total_e_field_y", namespace)))
3627 call write_iter_init(writ%out(out_maxwell_total_e_field + 2)%handle, first, &
3628 units_from_atomic(units_out%time, dt), trim(io_workpath("td.general/total_e_field_z", namespace)))
3629 end if
3630
3631 ! total B field
3632 if (writ%out(out_maxwell_total_b_field)%write) then
3633 call write_iter_init(writ%out(out_maxwell_total_b_field)%handle, first, &
3634 units_from_atomic(units_out%time, dt), trim(io_workpath("td.general/total_b_field_x", namespace)))
3635 call write_iter_init(writ%out(out_maxwell_total_b_field + 1)%handle, first, &
3636 units_from_atomic(units_out%time, dt), trim(io_workpath("td.general/total_b_field_y", namespace)))
3637 call write_iter_init(writ%out(out_maxwell_total_b_field + 2)%handle, first, &
3638 units_from_atomic(units_out%time, dt), trim(io_workpath("td.general/total_b_field_z", namespace)))
3639 end if
3640
3641 ! longitudinal E field
3642 if (writ%out(out_maxwell_long_e_field)%write) then
3643 call write_iter_init(writ%out(out_maxwell_long_e_field)%handle, first, &
3644 units_from_atomic(units_out%time, dt), trim(io_workpath("td.general/longitudinal_e_field_x", namespace)))
3645 call write_iter_init(writ%out(out_maxwell_long_e_field + 1)%handle, first, &
3646 units_from_atomic(units_out%time, dt), trim(io_workpath("td.general/longitudinal_e_field_y", namespace)))
3647 call write_iter_init(writ%out(out_maxwell_long_e_field + 2)%handle, first, &
3648 units_from_atomic(units_out%time, dt), trim(io_workpath("td.general/longitudinal_e_field_z", namespace)))
3649 end if
3650
3651 ! longitudinal B field
3652 if (writ%out(out_maxwell_long_b_field)%write) then
3653 call write_iter_init(writ%out(out_maxwell_long_b_field)%handle, first, &
3654 units_from_atomic(units_out%time, dt), trim(io_workpath("td.general/longitudinal_b_field_x", namespace)))
3655 call write_iter_init(writ%out(out_maxwell_long_b_field + 1)%handle, first, &
3656 units_from_atomic(units_out%time, dt), trim(io_workpath("td.general/longitudinal_b_field_y", namespace)))
3657 call write_iter_init(writ%out(out_maxwell_long_b_field + 2)%handle, first, &
3658 units_from_atomic(units_out%time, dt), trim(io_workpath("td.general/longitudinal_b_field_z", namespace)))
3659 end if
3660
3661 ! transverse E field
3662 if (writ%out(out_maxwell_trans_e_field)%write) then
3663 call write_iter_init(writ%out(out_maxwell_trans_e_field)%handle, first, &
3664 units_from_atomic(units_out%time, dt), trim(io_workpath("td.general/transverse_e_field_x", namespace)))
3665 call write_iter_init(writ%out(out_maxwell_trans_e_field + 1)%handle, first, &
3666 units_from_atomic(units_out%time, dt), trim(io_workpath("td.general/transverse_e_field_y", namespace)))
3667 call write_iter_init(writ%out(out_maxwell_trans_e_field + 2)%handle, first, &
3668 units_from_atomic(units_out%time, dt), trim(io_workpath("td.general/transverse_e_field_z", namespace)))
3669 end if
3670
3671 ! transverse B field
3672 if (writ%out(out_maxwell_trans_b_field)%write) then
3673 call write_iter_init(writ%out(out_maxwell_trans_b_field)%handle, first, &
3674 units_from_atomic(units_out%time, dt), trim(io_workpath("td.general/transverse_b_field_x", namespace)))
3675 call write_iter_init(writ%out(out_maxwell_trans_b_field + 1)%handle, first, &
3676 units_from_atomic(units_out%time, dt), trim(io_workpath("td.general/transverse_b_field_y", namespace)))
3677 call write_iter_init(writ%out(out_maxwell_trans_b_field + 2)%handle, first, &
3678 units_from_atomic(units_out%time, dt), trim(io_workpath("td.general/transverse_b_field_z", namespace)))
3679 end if
3680
3681 ! Maxwell energy
3682 if (writ%out(out_maxwell_energy)%write) then
3683 call write_iter_init(writ%out(out_maxwell_energy)%handle, first, &
3684 units_from_atomic(units_out%time, dt), trim(io_workpath("td.general/maxwell_energy", namespace)))
3685 end if
3686
3687 if (writ%out(out_e_field_surface_x)%write) then
3688 call write_iter_init(writ%out(out_e_field_surface_x)%handle, first, &
3689 units_from_atomic(units_out%time, dt), trim(io_workpath("td.general/electric_field_surface-x", namespace)))
3690 end if
3691
3692 if (writ%out(out_e_field_surface_y)%write) then
3693 call write_iter_init(writ%out(out_e_field_surface_y)%handle, first, &
3694 units_from_atomic(units_out%time, dt), trim(io_workpath("td.general/electric_field_surface-y", namespace)))
3695 end if
3696
3697 if (writ%out(out_e_field_surface_z)%write) then
3698 call write_iter_init(writ%out(out_e_field_surface_z)%handle, first, &
3699 units_from_atomic(units_out%time, dt), trim(io_workpath("td.general/electric_field_surface-z", namespace)))
3700 end if
3701
3702 if (writ%out(out_b_field_surface_x)%write) then
3703 call write_iter_init(writ%out(out_b_field_surface_x)%handle, first, &
3704 units_from_atomic(units_out%time, dt), trim(io_workpath("td.general/magnetic_field_surface-x", namespace)))
3705 end if
3706
3707 if (writ%out(out_b_field_surface_y)%write) then
3708 call write_iter_init(writ%out(out_b_field_surface_y)%handle, first, &
3709 units_from_atomic(units_out%time, dt), trim(io_workpath("td.general/magnetic_field_surface-y", namespace)))
3710 end if
3711
3712 if (writ%out(out_b_field_surface_z)%write) then
3713 call write_iter_init(writ%out(out_b_field_surface_z)%handle, first, &
3714 units_from_atomic(units_out%time, dt), trim(io_workpath("td.general/magnetic_field_surface-z", namespace)))
3715 end if
3716
3717 pop_sub(td_write_mxll_init)
3718 end subroutine td_write_mxll_init
3719
3720
3721 ! ---------------------------------------------------------
3722 subroutine td_write_mxll_end(writ)
3723 type(td_write_t), intent(inout) :: writ
3724
3725 integer :: iout
3726
3727 push_sub(td_write_mxll_end)
3728
3729 do iout = 1, out_maxwell_max
3730 if (writ%out(iout)%write) call write_iter_end(writ%out(iout)%handle)
3731 end do
3732
3733 pop_sub(td_write_mxll_end)
3734 end subroutine td_write_mxll_end
3735
3736
3737 ! ---------------------------------------------------------
3738 subroutine td_write_mxll_iter(writ, space, gr, st, hm, helmholtz, dt, iter, namespace)
3739 type(td_write_t), intent(inout) :: writ
3740 class(space_t), intent(in) :: space
3741 type(grid_t), intent(inout) :: gr
3742 type(states_mxll_t), intent(inout) :: st
3743 type(hamiltonian_mxll_t), intent(inout) :: hm
3744 type(helmholtz_decomposition_t), intent(inout) :: helmholtz
3745 real(real64), intent(in) :: dt
3746 integer, intent(in) :: iter
3747 type(namespace_t), intent(in) :: namespace
3748
3749
3750 push_sub(td_write_mxll_iter)
3751
3752 call profiling_in("TD_WRITE_ITER_MAXWELL")
3753
3754 if (writ%out(out_maxwell_trans_e_field)%write .or. writ%out(out_maxwell_trans_b_field)%write) then
3755 call helmholtz%get_trans_field(namespace, st%rs_state_trans, total_field=st%rs_state)
3756 call get_rs_state_at_point(st%selected_points_rs_state_trans(:,:), st%rs_state_trans, &
3757 st%selected_points_coordinate(:,:), st, gr)
3758 !TODO: calculate transverse energy
3759 else
3760 hm%energy%energy_trans = m_zero
3761 end if
3762
3763 if (writ%out(out_maxwell_long_e_field)%write .or. writ%out(out_maxwell_long_b_field)%write) then
3764 call helmholtz%get_long_field(namespace, st%rs_state_long, total_field=st%rs_state)
3765 call get_rs_state_at_point(st%selected_points_rs_state_long(:,:), st%rs_state_long, &
3766 st%selected_points_coordinate(:,:), st, gr)
3767 !TODO: calculate longitudinal energy
3768 else
3769 hm%energy%energy_long = m_zero
3770 end if
3771
3772 ! total E field
3773 if (writ%out(out_maxwell_total_e_field)%write) then
3774 call td_write_fields(writ%out(out_maxwell_total_e_field)%handle, space, st, iter, dt, &
3776 call td_write_fields(writ%out(out_maxwell_total_e_field + 1)%handle, space, st, iter, dt, &
3778 call td_write_fields(writ%out(out_maxwell_total_e_field + 2)%handle, space, st, iter, dt, &
3780 end if
3781
3782 ! total B field
3783 if (writ%out(out_maxwell_total_b_field)%write) then
3784 call td_write_fields(writ%out(out_maxwell_total_b_field)%handle, space, st, iter, dt, &
3786 call td_write_fields(writ%out(out_maxwell_total_b_field + 1)%handle, space, st, iter, dt, &
3788 call td_write_fields(writ%out(out_maxwell_total_b_field + 2)%handle, space, st, iter, dt, &
3790 end if
3791
3792 ! Longitudinal E field
3793 if (writ%out(out_maxwell_long_e_field)%write) then
3794 call td_write_fields(writ%out(out_maxwell_long_e_field)%handle, space, st, iter, dt, &
3796 call td_write_fields(writ%out(out_maxwell_long_e_field + 1)%handle, space, st, iter, dt, &
3798 call td_write_fields(writ%out(out_maxwell_long_e_field + 2)%handle, space, st, iter, dt, &
3800 end if
3801
3802 ! Longitudinal B field
3803 if (writ%out(out_maxwell_long_b_field)%write) then
3804 call td_write_fields(writ%out(out_maxwell_long_b_field)%handle, space, st, iter, dt, &
3806 call td_write_fields(writ%out(out_maxwell_long_b_field + 1)%handle, space, st, iter, dt, &
3808 call td_write_fields(writ%out(out_maxwell_long_b_field + 2)%handle, space, st, iter, dt, &
3810 end if
3811
3812 ! Transverse E field
3813 if (writ%out(out_maxwell_trans_e_field)%write) then
3814 call td_write_fields(writ%out(out_maxwell_trans_e_field)%handle, space, st, iter, dt, &
3816 call td_write_fields(writ%out(out_maxwell_trans_e_field + 1)%handle, space, st, iter, dt, &
3818 call td_write_fields(writ%out(out_maxwell_trans_e_field + 2)%handle, space, st, iter, dt, &
3820 end if
3821
3822 ! Transverse B field
3823 if (writ%out(out_maxwell_trans_b_field)%write) then
3824 call td_write_fields(writ%out(out_maxwell_trans_b_field)%handle, space, st, iter, dt, &
3826 call td_write_fields(writ%out(out_maxwell_trans_b_field + 1)%handle, space, st, iter, dt, &
3828 call td_write_fields(writ%out(out_maxwell_trans_b_field + 2)%handle, space, st, iter, dt, &
3830 end if
3832 ! Maxwell energy
3833 if (writ%out(out_maxwell_energy)%write) then
3834 call td_write_maxwell_energy(writ%out(out_maxwell_energy)%handle, hm, iter)
3835 end if
3836
3837 if (writ%out(out_e_field_surface_x)%write) then
3838 call td_write_electric_field_box_surface(writ%out(out_e_field_surface_x)%handle, st, 1, iter)
3839 end if
3840
3841 if (writ%out(out_e_field_surface_y)%write) then
3842 call td_write_electric_field_box_surface(writ%out(out_e_field_surface_y)%handle, st, 2, iter)
3843 end if
3844
3845 if (writ%out(out_e_field_surface_z)%write) then
3846 call td_write_electric_field_box_surface(writ%out(out_e_field_surface_z)%handle, st, 3, iter)
3847 end if
3848
3849 if (writ%out(out_b_field_surface_x)%write) then
3850 call td_write_magnetic_field_box_surface(writ%out(out_b_field_surface_x)%handle, st, 1, iter)
3851 end if
3852
3853 if (writ%out(out_b_field_surface_y)%write) then
3854 call td_write_magnetic_field_box_surface(writ%out(out_b_field_surface_y)%handle, st, 2, iter)
3855 end if
3856
3857 if (writ%out(out_b_field_surface_z)%write) then
3858 call td_write_magnetic_field_box_surface(writ%out(out_b_field_surface_z)%handle, st, 3, iter)
3859 end if
3860
3861 call profiling_out("TD_WRITE_ITER_MAXWELL")
3862
3863 pop_sub(td_write_mxll_iter)
3864 end subroutine td_write_mxll_iter
3865
3866
3867 ! ---------------------------------------------------------
3868 subroutine td_write_maxwell_energy(out_maxwell_energy, hm, iter)
3869 type(c_ptr), intent(inout) :: out_maxwell_energy
3870 type(hamiltonian_mxll_t), intent(in) :: hm
3871 integer, intent(in) :: iter
3872
3873 integer :: ii
3874
3875 integer :: n_columns
3876
3877 if (.not. mpi_grp_is_root(mpi_world)) return ! only first node outputs
3878
3879 push_sub(td_write_maxwell_energy)
3880
3881 n_columns = 8
3882
3883 if (iter == 0) then
3884 call td_write_print_header_init(out_maxwell_energy)
3885
3886 ! first line -> column names
3887 call write_iter_header_start(out_maxwell_energy)
3888 call write_iter_header(out_maxwell_energy, 'Total')
3889 call write_iter_header(out_maxwell_energy, 'E**2')
3890 call write_iter_header(out_maxwell_energy, 'B**2')
3891 call write_iter_header(out_maxwell_energy, 'Total+Boundaries')
3892 call write_iter_header(out_maxwell_energy, 'Boundaries')
3893 call write_iter_header(out_maxwell_energy, 'Transversal')
3894 call write_iter_header(out_maxwell_energy, 'Longitudinal')
3895 call write_iter_header(out_maxwell_energy, 'Incident Waves')
3896
3897 call write_iter_nl(out_maxwell_energy)
3898
3899 ! units
3900
3901 call write_iter_string(out_maxwell_energy, '#[Iter n.]')
3902 call write_iter_header(out_maxwell_energy, '[' // trim(units_abbrev(units_out%time)) // ']')
3903
3904 do ii = 1, n_columns
3905 call write_iter_header(out_maxwell_energy, '[' // trim(units_abbrev(units_out%energy)) // ']')
3906 end do
3907 call write_iter_nl(out_maxwell_energy)
3908
3909 call td_write_print_header_end(out_maxwell_energy)
3910 end if
3911
3912 call write_iter_start(out_maxwell_energy)
3913 call write_iter_double(out_maxwell_energy, units_from_atomic(units_out%energy, hm%energy%energy), 1)
3914 call write_iter_double(out_maxwell_energy, units_from_atomic(units_out%energy, hm%energy%e_energy), 1)
3915 call write_iter_double(out_maxwell_energy, units_from_atomic(units_out%energy, hm%energy%b_energy), 1)
3916 call write_iter_double(out_maxwell_energy, units_from_atomic(units_out%energy, &
3917 hm%energy%energy+hm%energy%boundaries), 1)
3918 call write_iter_double(out_maxwell_energy, units_from_atomic(units_out%energy, hm%energy%boundaries), 1)
3919 call write_iter_double(out_maxwell_energy, units_from_atomic(units_out%energy, hm%energy%energy_trans), 1)
3920 call write_iter_double(out_maxwell_energy, units_from_atomic(units_out%energy, hm%energy%energy_long), 1)
3921 call write_iter_double(out_maxwell_energy, units_from_atomic(units_out%energy, hm%energy%energy_plane_waves), 1)
3922 call write_iter_nl(out_maxwell_energy)
3923
3925 end subroutine td_write_maxwell_energy
3926
3927
3928 ! ---------------------------------------------------------
3929 subroutine td_write_electric_field_box_surface(out_field_surf, st, dim, iter)
3930 type(c_ptr), intent(inout) :: out_field_surf
3931 type(states_mxll_t), intent(in) :: st
3932 integer, intent(in) :: dim
3933 integer, intent(in) :: iter
3934
3935 integer :: ii
3936
3937 integer :: n_columns
3938
3939 if (.not. mpi_grp_is_root(mpi_world)) return ! only first node outputs
3940
3942
3943 n_columns = 12
3944
3945 if (iter == 0) then
3946 call td_write_print_header_init(out_field_surf)
3947
3948 ! first line -> column names
3949 call write_iter_header_start(out_field_surf)
3950 call write_iter_header(out_field_surf, '- x direction')
3951 call write_iter_header(out_field_surf, '+ x direction')
3952 call write_iter_header(out_field_surf, '- y direction')
3953 call write_iter_header(out_field_surf, '+ y direction')
3954 call write_iter_header(out_field_surf, '- z direction')
3955 call write_iter_header(out_field_surf, '+ z direction')
3956 call write_iter_header(out_field_surf, '- x dir. p. w.')
3957 call write_iter_header(out_field_surf, '+ x dir. p. w.')
3958 call write_iter_header(out_field_surf, '- y dir. p. w.')
3959 call write_iter_header(out_field_surf, '+ y dir. p. w.')
3960 call write_iter_header(out_field_surf, '- z dir. p. w.')
3961 call write_iter_header(out_field_surf, '+ z dir. p. w.')
3962
3963 call write_iter_nl(out_field_surf)
3964
3965 ! units
3966 call write_iter_string(out_field_surf, '#[Iter n.]')
3967 call write_iter_header(out_field_surf, '[' // trim(units_abbrev(units_out%time)) // ']')
3968
3969 do ii = 1, n_columns
3970 call write_iter_header(out_field_surf, '[' // trim(units_abbrev(units_out%energy/units_out%length)) // ']')
3971 end do
3972 call write_iter_nl(out_field_surf)
3973
3974 call td_write_print_header_end(out_field_surf)
3975 end if
3976
3977 call write_iter_start(out_field_surf)
3978 call write_iter_double(out_field_surf, units_from_atomic(units_out%energy/units_out%length, &
3979 st%electric_field_box_surface(1,1,dim)), 1)
3980 call write_iter_double(out_field_surf, units_from_atomic(units_out%energy/units_out%length, &
3981 st%electric_field_box_surface(2,1,dim)), 1)
3982 call write_iter_double(out_field_surf, units_from_atomic(units_out%energy/units_out%length, &
3983 st%electric_field_box_surface(1,2,dim)), 1)
3984 call write_iter_double(out_field_surf, units_from_atomic(units_out%energy/units_out%length, &
3985 st%electric_field_box_surface(2,2,dim)), 1)
3986 call write_iter_double(out_field_surf, units_from_atomic(units_out%energy/units_out%length, &
3987 st%electric_field_box_surface(1,3,dim)), 1)
3988 call write_iter_double(out_field_surf, units_from_atomic(units_out%energy/units_out%length, &
3989 st%electric_field_box_surface(2,3,dim)), 1)
3990 call write_iter_double(out_field_surf, units_from_atomic(units_out%energy/units_out%length, &
3991 st%electric_field_box_surface_plane_waves(1,1,dim)), 1)
3992 call write_iter_double(out_field_surf, units_from_atomic(units_out%energy/units_out%length, &
3993 st%electric_field_box_surface_plane_waves(2,1,dim)), 1)
3994 call write_iter_double(out_field_surf, units_from_atomic(units_out%energy/units_out%length, &
3995 st%electric_field_box_surface_plane_waves(1,2,dim)), 1)
3996 call write_iter_double(out_field_surf, units_from_atomic(units_out%energy/units_out%length, &
3997 st%electric_field_box_surface_plane_waves(2,2,dim)), 1)
3998 call write_iter_double(out_field_surf, units_from_atomic(units_out%energy/units_out%length, &
3999 st%electric_field_box_surface_plane_waves(1,3,dim)), 1)
4000 call write_iter_double(out_field_surf, units_from_atomic(units_out%energy/units_out%length, &
4001 st%electric_field_box_surface_plane_waves(2,3,dim)), 1)
4002 call write_iter_nl(out_field_surf)
4003
4006
4007
4008 ! ---------------------------------------------------------
4009 subroutine td_write_magnetic_field_box_surface(out_field_surf, st, dim, iter)
4010 type(c_ptr), intent(inout) :: out_field_surf
4011 type(states_mxll_t), intent(in) :: st
4012 integer, intent(in) :: dim
4013 integer, intent(in) :: iter
4014
4015 integer :: ii
4016
4017 integer :: n_columns
4018
4019 if (.not. mpi_grp_is_root(mpi_world)) return ! only first node outputs
4020
4023 n_columns = 12
4024
4025 if (iter == 0) then
4026 call td_write_print_header_init(out_field_surf)
4027
4028 ! first line -> column names
4029 call write_iter_header_start(out_field_surf)
4030 call write_iter_header(out_field_surf, '- x direction')
4031 call write_iter_header(out_field_surf, '+ x direction')
4032 call write_iter_header(out_field_surf, '- y direction')
4033 call write_iter_header(out_field_surf, '+ y direction')
4034 call write_iter_header(out_field_surf, '- z direction')
4035 call write_iter_header(out_field_surf, '+ z direction')
4036 call write_iter_header(out_field_surf, '- x dir. p. w.')
4037 call write_iter_header(out_field_surf, '+ x dir. p. w.')
4038 call write_iter_header(out_field_surf, '- y dir. p. w.')
4039 call write_iter_header(out_field_surf, '+ y dir. p. w.')
4040 call write_iter_header(out_field_surf, '- z dir. p. w.')
4041 call write_iter_header(out_field_surf, '+ z dir. p. w.')
4042
4043 call write_iter_nl(out_field_surf)
4044
4045 ! units
4046 call write_iter_string(out_field_surf, '#[Iter n.]')
4047 call write_iter_header(out_field_surf, '[' // trim(units_abbrev(units_out%time)) // ']')
4048
4049 do ii = 1, n_columns
4050 call write_iter_header(out_field_surf, '[' // trim(units_abbrev(unit_one/units_out%length**2)) // ']')
4051 end do
4052 call write_iter_nl(out_field_surf)
4053
4054 call td_write_print_header_end(out_field_surf)
4055 end if
4056
4057 call write_iter_start(out_field_surf)
4058 call write_iter_double(out_field_surf, units_from_atomic(unit_one/units_out%length**2, &
4059 st%magnetic_field_box_surface(1,1,dim)), 1)
4060 call write_iter_double(out_field_surf, units_from_atomic(unit_one/units_out%length**2, &
4061 st%magnetic_field_box_surface(2,1,dim)), 1)
4062 call write_iter_double(out_field_surf, units_from_atomic(unit_one/units_out%length**2, &
4063 st%magnetic_field_box_surface(1,2,dim)), 1)
4064 call write_iter_double(out_field_surf, units_from_atomic(unit_one/units_out%length**2, &
4065 st%magnetic_field_box_surface(2,2,dim)), 1)
4066 call write_iter_double(out_field_surf, units_from_atomic(unit_one/units_out%length**2, &
4067 st%magnetic_field_box_surface(1,3,dim)), 1)
4068 call write_iter_double(out_field_surf, units_from_atomic(unit_one/units_out%length**2, &
4069 st%magnetic_field_box_surface(2,3,dim)), 1)
4070 call write_iter_double(out_field_surf, units_from_atomic(unit_one/units_out%length**2, &
4071 st%magnetic_field_box_surface_plane_waves(1,1,dim)), 1)
4072 call write_iter_double(out_field_surf, units_from_atomic(unit_one/units_out%length**2, &
4073 st%magnetic_field_box_surface_plane_waves(2,1,dim)), 1)
4074 call write_iter_double(out_field_surf, units_from_atomic(unit_one/units_out%length**2, &
4075 st%magnetic_field_box_surface_plane_waves(1,2,dim)), 1)
4076 call write_iter_double(out_field_surf, units_from_atomic(unit_one/units_out%length**2, &
4077 st%magnetic_field_box_surface_plane_waves(2,2,dim)), 1)
4078 call write_iter_double(out_field_surf, units_from_atomic(unit_one/units_out%length**2, &
4079 st%magnetic_field_box_surface_plane_waves(1,3,dim)), 1)
4080 call write_iter_double(out_field_surf, units_from_atomic(unit_one/units_out%length**2, &
4081 st%magnetic_field_box_surface_plane_waves(2,3,dim)), 1)
4082 call write_iter_nl(out_field_surf)
4083
4086
4087 ! ---------------------------------------------------------
4088 subroutine td_write_fields(out_fields, space, st, iter, dt, e_or_b_field, field_type, idir)
4089 type(c_ptr), intent(inout) :: out_fields
4090 class(space_t), intent(in) :: space
4091 type(states_mxll_t), intent(in) :: st
4092 integer, intent(in) :: iter
4093 real(real64), intent(in) :: dt
4094 integer, intent(in) :: e_or_b_field
4095 integer, intent(in) :: field_type
4096 integer, intent(in) :: idir
4097
4098
4099 integer :: id
4100 real(real64) :: field(space%dim), selected_field
4101 character(len=80) :: aux
4103 if (.not. mpi_grp_is_root(mpi_world)) return ! only first node outputs
4104
4105 push_sub(td_write_fields)
4106
4107 if (iter == 0) then
4108 call td_write_print_header_init(out_fields)
4109
4110 ! first line
4111 write(aux, '(a7,e20.12,3a)') '# dt = ', units_from_atomic(units_out%time, dt), &
4112 " [", trim(units_abbrev(units_out%time)), "]"
4113 call write_iter_string(out_fields, aux)
4114 call write_iter_nl(out_fields)
4115
4116 call write_iter_header_start(out_fields)
4117
4118 do id = 1, st%selected_points_number
4119 select case (e_or_b_field)
4120 case (maxwell_e_field)
4121 write(aux, '(a,i1,a)') 'E(', id, ')'
4122 case (maxwell_b_field)
4123 write(aux, '(a,i1,a)') 'B(', id, ')'
4124 end select
4125 call write_iter_header(out_fields, aux)
4126 end do
4127
4128 call write_iter_nl(out_fields)
4129 call write_iter_string(out_fields, '#[Iter n.]')
4130 call write_iter_header(out_fields, ' [' // trim(units_abbrev(units_out%time)) // ']')
4131
4132 ! Note that we do not print out units of E, B, or A, but rather units of e*E, e*B, e*A.
4133 ! (force, force, and energy, respectively). The reason is that the units of E, B or A
4134 ! are ugly.
4135 aux = ' [' // trim(units_abbrev(units_out%force)) // ']'
4136 do id = 1, st%selected_points_number
4137 call write_iter_header(out_fields, aux)
4138 end do
4139 call write_iter_nl(out_fields)
4140 call td_write_print_header_end(out_fields)
4141 end if
4142
4143 call write_iter_start(out_fields)
4144
4145 do id = 1, st%selected_points_number
4146 select case (e_or_b_field)
4147 case (maxwell_e_field)
4148 ! Output of electric field at selected point
4149 select case (field_type)
4150 case (maxwell_total_field)
4151 call get_electric_field_vector(st%selected_points_rs_state(:,id), field(1:st%dim))
4152 case (maxwell_long_field)
4153 call get_electric_field_vector(st%selected_points_rs_state_long(:,id), field(1:st%dim))
4154 case (maxwell_trans_field)
4155 call get_electric_field_vector(st%selected_points_rs_state_trans(:,id), field(1:st%dim))
4156 end select
4157 selected_field = units_from_atomic(units_out%energy/units_out%length, field(idir))
4158 case (maxwell_b_field)
4159 ! Output of magnetic field at selected point
4160 select case (field_type)
4161 case (maxwell_total_field)
4162 call get_magnetic_field_vector(st%selected_points_rs_state(:,id), st%rs_sign, field(1:st%dim))
4163 case (maxwell_long_field)
4164 call get_magnetic_field_vector(st%selected_points_rs_state_long(:,id), st%rs_sign, field(1:st%dim))
4165 case (maxwell_trans_field)
4166 call get_magnetic_field_vector(st%selected_points_rs_state_trans(:,id), st%rs_sign, field(1:st%dim))
4167 end select
4168 selected_field = units_from_atomic(unit_one/units_out%length**2, field(idir))
4169 end select
4170 call write_iter_double(out_fields, selected_field, 1)
4171 end do
4172
4173 call write_iter_nl(out_fields)
4174
4175 pop_sub(td_write_fields)
4176 end subroutine td_write_fields
4177
4178
4179 !----------------------------------------------------------
4180 subroutine td_write_mxll_free_data(writ, namespace, space, gr, st, hm, helmholtz, outp, iter, time)
4181 type(td_write_t), intent(inout) :: writ
4182 type(namespace_t), intent(in) :: namespace
4183 class(space_t), intent(in) :: space
4184 type(grid_t), intent(inout) :: gr
4185 type(states_mxll_t), intent(inout) :: st
4186 type(hamiltonian_mxll_t), intent(inout) :: hm
4187 type(helmholtz_decomposition_t), intent(inout) :: helmholtz
4188 type(output_t), intent(in) :: outp
4189 integer, intent(in) :: iter
4190 real(real64), intent(in) :: time
4191
4192 character(len=256) :: filename
4193
4194 push_sub(td_write_mxwll_free_data)
4195 call profiling_in("TD_WRITE_MAXWELL_DATA")
4196
4197 ! now write down the rest
4198 write(filename, '(a,a,i7.7)') trim(outp%iter_dir),"td.", iter ! name of directory
4199
4200 call output_mxll(outp, namespace, space, gr, st, hm, helmholtz, time, filename)
4201
4202 call profiling_out("TD_WRITE_MAXWELL_DATA")
4203 pop_sub(td_write_mxwll_free_data)
4204 end subroutine td_write_mxll_free_data
4205
4206end module td_write_oct_m
4207
4208!! Local Variables:
4209!! mode: f90
4210!! coding: utf-8
4211!! End:
ssize_t ssize_t write(int __fd, const void *__buf, size_t __n) __attribute__((__access__(__read_only__
constant times a vector plus a vector
Definition: lalg_basic.F90:171
Copies a vector x, to a vector y.
Definition: lalg_basic.F90:186
Sets the iteration number to the C object.
Definition: write_iter.F90:174
Writes to the corresponding file and adds one to the iteration. Must be called after write_iter_init(...
Definition: write_iter.F90:167
double exp(double __x) __attribute__((__nothrow__
This module contains interfaces for BLAS routines You should not use these routines directly....
Definition: blas.F90:118
This module implements a calculator for the density and defines related functions.
Definition: density.F90:120
subroutine, public density_calc(st, gr, density, istin)
Computes the density from the orbitals in st.
Definition: density.F90:612
This module calculates the derivatives (gradients, Laplacians, etc.) of a function.
integer, parameter, public spinors
integer, parameter, public spin_polarized
subroutine, public excited_states_kill(excited_state)
Kills an excited_state structure.
subroutine, public excited_states_init(excited_state, ground_state, filename, namespace)
Fills in an excited_state structure, by reading a file called "filename". This file describes the "pr...
type(gauge_field_t) function, pointer, public list_get_gauge_field(partners)
logical function, public list_has_lasers(partners)
type(lasers_t) function, pointer, public list_get_lasers(partners)
subroutine, public gauge_field_output_write(this, out_gauge, iter)
real(real64), parameter, public m_two
Definition: global.F90:190
real(real64), parameter, public m_zero
Definition: global.F90:188
complex(real64), parameter, public m_z0
Definition: global.F90:198
real(real64), parameter, public lmm_r_single_atom
Default local magnetic moments sphere radius for an isolated system.
Definition: global.F90:216
complex(real64), parameter, public m_zi
Definition: global.F90:202
integer, parameter, public max_output_types
Definition: global.F90:148
real(real64), parameter, public m_half
Definition: global.F90:194
real(real64), parameter, public m_one
Definition: global.F90:189
real(real64), parameter, public m_min_occ
Minimal occupation that is considered to be non-zero.
Definition: global.F90:211
This module implements the underlying real-space grid.
Definition: grid.F90:117
The Helmholtz decomposition is intended to contain "only mathematical" functions and procedures to co...
This module defines classes and functions for interaction partners.
subroutine, public zio_function_output(how, dir, fname, namespace, space, mesh, ff, unit, ierr, pos, atoms, grp, root)
Top-level IO routine for functions defined on the mesh.
subroutine, public io_function_read_what_how_when(namespace, space, what, how, output_interval, what_tag_in, how_tag_in, output_interval_tag_in, ignore_error)
Definition: io.F90:114
subroutine, public io_close(iunit, grp)
Definition: io.F90:418
character(len=max_path_len) function, public io_workpath(path, namespace)
Definition: io.F90:270
subroutine, public io_rm(fname, namespace)
Definition: io.F90:342
subroutine, public io_mkdir(fname, namespace, parents)
Definition: io.F90:311
integer function, public io_open(file, namespace, action, status, form, position, die, recl, grp)
Definition: io.F90:352
real(real64) function, public ion_dynamics_temperature(ions)
This function returns the ionic temperature in energy units.
integer, parameter, public qkickmode_cos
Definition: kick.F90:169
integer, parameter, public qkickmode_none
Definition: kick.F90:169
integer, parameter, public qkickmode_sin
Definition: kick.F90:169
subroutine, public kick_function_get(space, mesh, kick, kick_function, iq, to_interpolate)
Definition: kick.F90:993
subroutine, public kick_write(kick, iunit, out)
Definition: kick.F90:891
integer, parameter, public qkickmode_bessel
Definition: kick.F90:169
subroutine, public lasers_nondipole_laser_field_step(this, field, time)
Retrieves the NDSFA vector_potential correction. The nondipole field is obtained for consecutive time...
Definition: lasers.F90:1154
subroutine, public lasers_set_nondipole_parameters(this, ndfield, nd_integration_time)
Set parameters for nondipole SFA calculation.
Definition: lasers.F90:754
logical function, public lasers_with_nondipole_field(lasers)
Check if a nondipole SFA correction should be computed for the given laser.
Definition: lasers.F90:741
integer, parameter, public e_field_electric
Definition: lasers.F90:177
integer, parameter, public e_field_vector_potential
Definition: lasers.F90:177
integer, parameter, public e_field_scalar_potential
Definition: lasers.F90:177
integer pure elemental function, public laser_kind(laser)
Definition: lasers.F90:717
subroutine, public laser_field(laser, field, time)
Retrieves the value of either the electric or the magnetic field. If the laser is given by a scalar p...
Definition: lasers.F90:1119
integer, parameter, public e_field_magnetic
Definition: lasers.F90:177
integer, parameter, public dft_u_none
Definition: lda_u.F90:201
integer, parameter, public dft_u_acbn0
Definition: lda_u.F90:201
subroutine, public magnetic_local_moments(mesh, st, ions, boundaries, rho, rr, lmm)
Definition: magnetic.F90:259
subroutine, public magnetic_moment(mesh, st, rho, mm)
Definition: magnetic.F90:183
subroutine, public magnetic_total_magnetization(mesh, st, qq, trans_mag)
Definition: magnetic.F90:326
This module is intended to contain "only mathematical" functions and procedures.
Definition: math.F90:115
subroutine, public ylmr_real(xx, li, mi, ylm)
This is a Numerical Recipes-based subroutine computes real spherical harmonics ylm at position (x,...
Definition: math.F90:376
This module defines functions over batches of mesh functions.
Definition: mesh_batch.F90:116
This module defines various routines, operating on mesh functions.
subroutine, public dmf_multipoles(mesh, ff, lmax, multipole, mask)
This routine calculates the multipoles of a function ff.
This module defines the meshes, which are used in Octopus.
Definition: mesh.F90:118
subroutine, public messages_not_implemented(feature, namespace)
Definition: messages.F90:1114
subroutine, public messages_warning(no_lines, all_nodes, namespace)
Definition: messages.F90:538
subroutine, public messages_obsolete_variable(namespace, name, rep)
Definition: messages.F90:1046
character(len=256), dimension(max_lines), public message
to be output by fatal, warning
Definition: messages.F90:161
subroutine, public messages_fatal(no_lines, only_root_writes, namespace)
Definition: messages.F90:415
subroutine, public messages_input_error(namespace, var, details, row, column)
Definition: messages.F90:714
subroutine, public messages_experimental(name, namespace)
Definition: messages.F90:1086
subroutine, public modelmb_sym_all_states(space, mesh, st)
This module contains some common usage patterns of MPI routines.
Definition: mpi_lib.F90:115
logical function mpi_grp_is_root(grp)
Is the current MPI process of grpcomm, root.
Definition: mpi.F90:430
type(mpi_grp_t), public mpi_world
Definition: mpi.F90:266
This module handles the communicators for the various parallelization strategies.
Definition: multicomm.F90:145
integer, parameter, public velocity_gauge_dipole
this module contains the low-level part of the output system
Definition: output_low.F90:115
subroutine, public output_modelmb(outp, namespace, space, dir, gr, ions, iter, st)
this module contains the output system
Definition: output.F90:115
subroutine, public output_all(outp, namespace, space, dir, gr, ions, iter, st, hm, ks)
Definition: output.F90:494
subroutine, public output_scalar_pot(outp, namespace, space, dir, mesh, ions, ext_partners, time)
Definition: output.F90:2478
integer function, public parse_block(namespace, name, blk, check_varinfo_)
Definition: parser.F90:618
subroutine, public profiling_out(label)
Increment out counter and sum up difference between entry and exit time.
Definition: profiling.F90:623
subroutine, public profiling_in(label, exclude)
Increment in counter and save entry time.
Definition: profiling.F90:552
integer, parameter, public restart_gs
Definition: restart.F90:200
subroutine, public restart_init(restart, namespace, data_type, type, mc, ierr, mesh, dir, exact)
Initializes a restart object.
Definition: restart.F90:516
integer, parameter, public restart_proj
Definition: restart.F90:200
integer, parameter, public restart_type_load
Definition: restart.F90:245
subroutine, public restart_end(restart)
Definition: restart.F90:722
subroutine, public zstates_elec_matrix(st1, st2, mesh, aa)
subroutine, public zstates_elec_calc_projections(st, gs_st, namespace, mesh, ik, proj, gs_nst)
This routine computes the projection between two set of states.
This module handles spin dimensions of the states and the k-point distribution.
logical function, public state_kpt_is_local(st, ist, ik)
check whether a given state (ist, ik) is on the local node
subroutine, public states_elec_end(st)
finalize the states_elec_t object
subroutine, public states_elec_deallocate_wfns(st)
Deallocates the KS wavefunctions defined within a states_elec_t structure.
subroutine, public states_elec_allocate_wfns(st, mesh, wfs_type, skip, packed)
Allocates the KS wavefunctions defined within a states_elec_t structure.
subroutine, public states_elec_copy(stout, stin, exclude_wfns, exclude_eigenval, special)
make a (selective) copy of a states_elec_t object
subroutine, public states_elec_look(restart, nik, dim, nst, ierr)
Reads the 'states' file in the restart directory, and finds out the nik, dim, and nst contained in it...
This module handles reading and writing restart information for the states_elec_t.
subroutine, public states_elec_load(restart, namespace, space, st, mesh, kpoints, fixed_occ, ierr, iter, lr, lowest_missing, label, verbose, skip)
returns in ierr: <0 => Fatal error, or nothing read =0 => read all wavefunctions >0 => could only rea...
subroutine, public td_calc_tacc(namespace, space, gr, ions, ext_partners, st, hm, acc, time)
Electronic acceleration (to calculate harmonic spectrum...) It is calculated as:
Definition: td_calc.F90:165
subroutine, public td_calc_ionch(mesh, st, ch, Nch)
Multiple ionization probabilities calculated form the KS orbital densities C. Ullrich,...
Definition: td_calc.F90:317
subroutine, public td_calc_tvel(gr, st, space, kpoints, vel)
Electronic velocity (to calculate harmonic spectrum...) It is calculated as:
Definition: td_calc.F90:285
subroutine, public td_write_coordinates(out_coords, natoms, space, pos, vel, tot_forces, iter)
subroutine, public td_write_sep_coordinates(out_coords, natoms, space, pos, vel, tot_forces, iter, which)
subroutine, public td_write_print_header_init(out)
subroutine, public td_write_print_header_end(out)
subroutine td_write_magnetic_field_box_surface(out_field_surf, st, dim, iter)
Definition: td_write.F90:4103
integer, parameter, public out_total_current
Definition: td_write.F90:201
integer, parameter maxwell_b_field
Definition: td_write.F90:299
integer, parameter, public out_maxwell_max
Definition: td_write.F90:291
integer, parameter, public out_q
Definition: td_write.F90:201
integer, parameter, public out_mxll_field
Definition: td_write.F90:201
integer, parameter out_b_field_surface_y
Definition: td_write.F90:276
subroutine td_write_ionch(out_ionch, mesh, st, iter)
Definition: td_write.F90:2296
integer, parameter, public out_tot_m
Definition: td_write.F90:201
integer, parameter, public out_norm_ks
Definition: td_write.F90:201
integer, parameter out_maxwell_trans_b_field
Definition: td_write.F90:276
integer, parameter, public out_cell_parameters
Definition: td_write.F90:201
subroutine td_write_multipole_r(out_multip, space, mesh, ions, st, lmax, kick, rho, iter, mpi_grp)
Write multipoles to the corresponding file.
Definition: td_write.F90:1578
integer, parameter, public out_proj
Definition: td_write.F90:201
integer, parameter, public out_partial_charges
Definition: td_write.F90:201
integer, parameter, public out_separate_coords
Definition: td_write.F90:201
subroutine td_write_total_current(out_total_current, space, mesh, st, iter)
Definition: td_write.F90:3082
subroutine, public td_write_output(namespace, space, gr, st, hm, ks, outp, ions, ext_partners, iter, dt)
Definition: td_write.F90:1242
subroutine td_write_effective_u(out_coords, lda_u, iter)
Definition: td_write.F90:3406
integer, parameter maxwell_trans_field
Definition: td_write.F90:294
subroutine td_write_acc(out_acc, namespace, space, gr, ions, st, hm, ext_partners, dt, iter)
Definition: td_write.F90:1929
subroutine, public td_write_mxll_init(writ, namespace, iter, dt)
Definition: td_write.F90:3628
subroutine, public td_write_mxll_end(writ)
Definition: td_write.F90:3816
subroutine td_write_mxll_field(out_mxll, space, hm, dt, iter)
Definition: td_write.F90:3317
integer, parameter out_b_field_surface_x
Definition: td_write.F90:276
integer, parameter out_maxwell_long_e_field
Definition: td_write.F90:276
integer, parameter, public out_kp_proj
Definition: td_write.F90:201
integer, parameter, public out_magnets
Definition: td_write.F90:201
subroutine td_write_multipole(out_multip, space, gr, ions, st, lmax, kick, iter)
Top-level routine that write multipoles to file, or files depending on whether a state-resolved outpu...
Definition: td_write.F90:1531
subroutine td_write_electric_field_box_surface(out_field_surf, st, dim, iter)
Definition: td_write.F90:4023
integer, parameter out_e_field_surface_y
Definition: td_write.F90:276
integer, parameter, public out_angular
Definition: td_write.F90:201
subroutine td_write_populations(out_populations, namespace, space, mesh, st, writ, dt, iter)
Definition: td_write.F90:1849
integer, parameter, public out_max
Definition: td_write.F90:201
integer, parameter out_maxwell_long_b_field
Definition: td_write.F90:276
integer, parameter, public out_energy
Definition: td_write.F90:201
integer, parameter, public out_spin
Definition: td_write.F90:201
subroutine td_write_proj(out_proj, space, mesh, ions, st, gs_st, td_start_proj, kick, iter)
Definition: td_write.F90:2390
subroutine td_write_ftchd(out_ftchd, space, mesh, st, kick, iter)
Definition: td_write.F90:1705
subroutine td_write_partial_charges(out_partial_charges, mesh, st, ions, iter)
Definition: td_write.F90:3225
integer, parameter out_dftu_max
For the Maxwell fields we increment in steps of 3 to leave room for x, y, and z output.
Definition: td_write.F90:271
subroutine td_write_laser(out_laser, space, lasers, dt, iter)
Definition: td_write.F90:2030
integer, parameter out_maxwell_total_b_field
Definition: td_write.F90:276
integer, parameter, public out_ftchd
Definition: td_write.F90:201
integer, parameter, public out_separate_velocity
Definition: td_write.F90:201
subroutine td_write_tot_mag(out_magnets, mesh, st, kick, iter)
Definition: td_write.F90:1393
subroutine td_write_q(out_q, space, ks, iter)
Definition: td_write.F90:3274
integer, parameter, public out_floquet
Definition: td_write.F90:201
integer, parameter, public out_acc
Definition: td_write.F90:201
integer, parameter, public out_ion_ch
Definition: td_write.F90:201
integer, parameter maxwell_long_field
Definition: td_write.F90:294
integer, parameter, public out_n_ex
Definition: td_write.F90:201
integer, parameter out_b_field_surface_z
Definition: td_write.F90:276
subroutine td_write_proj_kp(mesh, kpoints, st, gs_st, namespace, iter)
Definition: td_write.F90:2712
integer, parameter, public out_temperature
Definition: td_write.F90:201
subroutine td_write_norm_ks_orbitals(file_handle, grid, kpoints, st, iter)
Write the norm of the KS orbitals to file as a function of time step.
Definition: td_write.F90:3495
subroutine, public td_write_data(writ)
Definition: td_write.F90:1208
subroutine, public td_write_mxll_free_data(writ, namespace, space, gr, st, hm, helmholtz, outp, iter, time)
Definition: td_write.F90:4274
subroutine td_write_total_heat_current(write_obj, space, hm, gr, st, iter)
Definition: td_write.F90:3169
integer, parameter out_e_field_surface_z
Definition: td_write.F90:276
integer, parameter maxwell_total_field
Definition: td_write.F90:294
integer, parameter, public out_coords
Definition: td_write.F90:201
integer, parameter out_maxwell_total_e_field
Definition: td_write.F90:276
integer, parameter, public out_laser
Definition: td_write.F90:201
integer, parameter, public out_eigs
Definition: td_write.F90:201
subroutine td_write_vel(out_vel, gr, st, space, kpoints, iter)
Definition: td_write.F90:1981
subroutine td_write_floquet(namespace, space, hm, ext_partners, mesh, st, iter)
Definition: td_write.F90:2806
integer, parameter, public out_total_heat_current
Definition: td_write.F90:201
integer, parameter out_e_field_surface_x
Definition: td_write.F90:276
subroutine, public td_write_kick(outp, namespace, space, mesh, kick, ions, iter)
Definition: td_write.F90:336
subroutine, public td_write_end(writ)
Definition: td_write.F90:991
subroutine td_write_angular(out_angular, namespace, space, gr, ions, hm, st, kick, iter)
Computes and outputs the orbital angular momentum defined by.
Definition: td_write.F90:1460
subroutine td_write_eigs(out_eigs, st, iter)
Definition: td_write.F90:2235
subroutine calc_projections(mesh, st, gs_st, td_start_proj, projections)
This subroutine calculates:
Definition: td_write.F90:2677
subroutine, public td_write_iter(writ, namespace, space, outp, gr, st, hm, ions, ext_partners, kick, ks, dt, iter, mc, recalculate_gs)
Definition: td_write.F90:1038
subroutine td_write_n_ex(out_nex, outp, namespace, mesh, kpoints, st, gs_st, iter)
This routine computes the total number of excited electrons based on projections on the GS orbitals T...
Definition: td_write.F90:2567
subroutine td_write_fields(out_fields, space, st, iter, dt, e_or_b_field, field_type, idir)
Definition: td_write.F90:4182
subroutine td_write_spin(out_spin, mesh, st, iter)
Definition: td_write.F90:1283
integer, parameter, public out_vel
Definition: td_write.F90:201
integer, parameter, public out_gauge_field
Definition: td_write.F90:201
subroutine td_write_temperature(out_temperature, ions, iter)
Definition: td_write.F90:1812
integer, parameter maxwell_e_field
Definition: td_write.F90:299
integer, parameter, public out_populations
Definition: td_write.F90:201
subroutine, public td_write_mxll_iter(writ, space, gr, st, hm, helmholtz, dt, iter, namespace)
Definition: td_write.F90:3832
subroutine td_write_cell_parameters(file_handle, ions, iter)
Write the cell parameters as a function of time.
Definition: td_write.F90:3564
subroutine td_write_local_magnetic_moments(out_magnets, gr, st, ions, lmm_r, iter)
Definition: td_write.F90:1335
subroutine, public td_write_init(writ, namespace, space, outp, gr, st, hm, ions, ext_partners, ks, ions_move, with_gauge_field, kick, iter, max_iter, dt, mc)
Initialize files to write when prograting in time.
Definition: td_write.F90:374
integer, parameter out_maxwell_energy
Definition: td_write.F90:276
subroutine td_write_energy(out_energy, hm, iter, ke)
Definition: td_write.F90:2152
subroutine td_write_maxwell_energy(out_maxwell_energy, hm, iter)
Definition: td_write.F90:3962
integer, parameter, public out_separate_forces
Definition: td_write.F90:201
integer, parameter out_maxwell_trans_e_field
Definition: td_write.F90:276
type(type_t), parameter, public type_cmplx
Definition: types.F90:134
brief This module defines the class unit_t which is used by the unit_systems_oct_m module.
Definition: unit.F90:132
character(len=20) pure function, public units_abbrev(this)
Definition: unit.F90:223
This module defines the unit system, used for input and output.
type(unit_system_t), public units_out
type(unit_t), public unit_kelvin
For converting energies into temperatures.
type(unit_system_t), public units_inp
the units systems for reading and writing
type(unit_t), public unit_one
some special units required for particular quantities
This module is intended to contain simple general-purpose utility functions and procedures.
Definition: utils.F90:118
character pure function, public index2axis(idir)
Definition: utils.F90:202
subroutine, public v_ks_calculate_current(this, calc_cur)
Definition: v_ks.F90:1454
subroutine, public v_ks_calc(ks, namespace, space, hm, st, ions, ext_partners, calc_eigenval, time, calc_energy, calc_current, force_semilocal)
Definition: v_ks.F90:744
Explicit interfaces to C functions, defined in write_iter_low.cc.
Definition: write_iter.F90:114
Extension of space that contains the knowledge of the spin dimension.
Description of the grid, containing information on derivatives, stencil, and symmetries.
Definition: grid.F90:168
Describes mesh distribution to nodes.
Definition: mesh.F90:186
This is defined even when running serial.
Definition: mpi.F90:142
Stores all communicators and groups.
Definition: multicomm.F90:206
output handler class
Definition: output_low.F90:164
The states_elec_t class contains all electronic wave functions.
Time-dependent Write Properties.
Definition: td_write.F90:317
int true(void)
subroutine dipole_matrix_elements(dir)
Definition: td_write.F90:2511