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