59 type(output_t),
intent(out) :: outp
60 type(namespace_t),
intent(in) :: namespace
61 class(space_t),
intent(in) :: space
136 'MaxwellOutput',
'OutputFormat',
'MaxwellOutputInterval')
138 do what_i = lbound(outp%what, 1), ubound(outp%what, 1)
140 if (
bitand(outp%how(what_i), option__outputformat__xyz) /= 0)
then
141 message(1) =
"OutputFormat = xyz is not compatible with Maxwell systems"
159 call parse_variable(namespace,
'MaxwellOutputIterDir',
"output_iter", outp%iter_dir)
160 if (any(outp%what) .and. maxval(outp%output_interval) > 0)
then
161 call io_mkdir(outp%iter_dir, namespace)
166 write(
message(1),
'(a)')
'Input variable MaxwellRestartWriteInterval is obsolete.'
167 write(
message(2),
'(a)')
'Restart files are now written in periods of the wallclock time'
168 write(
message(3),
'(a)')
'given by RestartWallTimePeriod, so you can simply delete this variable.'
172 if (outp%what(option__maxwelloutput__electric_field))
then
173 outp%wfs_list = trim(
"1-3")
176 if (outp%what(option__maxwelloutput__magnetic_field))
then
177 outp%wfs_list = trim(
"1-3")
180 if (outp%what(option__maxwelloutput__trans_electric_field))
then
181 outp%wfs_list = trim(
"1-3")
184 if (outp%what(option__maxwelloutput__trans_magnetic_field))
then
185 outp%wfs_list = trim(
"1-3")
194 subroutine output_mxll(outp, namespace, space, gr_mxll, st_mxll, hm_mxll, helmholtz, time, dir, gr_elec, st_elec, hm_elec)
197 class(
space_t),
intent(in) :: space
200 type(
grid_t),
intent(in) :: gr_mxll
202 real(real64),
intent(in) :: time
203 character(len=*),
intent(in) :: dir
204 type(
grid_t),
optional,
intent(inout) :: gr_elec
210 if (any(outp%what))
then
211 message(1) =
"Info: Writing output to " // trim(dir)
227 if (
present(hm_elec) .and.
present(gr_elec) .and.
present(st_elec))
then
229 call output_current_density(outp, namespace, dir, st_mxll, gr_mxll, hm_mxll, st_elec, gr_elec, hm_elec, time)
240 class(
space_t),
intent(in) :: space
241 character(len=*),
intent(in) :: dir
243 class(
mesh_t),
intent(in) :: mesh
246 character(len=MAX_PATH_LEN) :: fname
248 real(real64),
allocatable :: dtmp(:,:)
253 if (outp%what(option__maxwelloutput__electric_field))
then
255 safe_allocate(dtmp(1:mesh%np, 1:space%dim))
259 mesh, dtmp, fn_unit, ierr)
260 safe_deallocate_a(dtmp)
264 if (outp%what(option__maxwelloutput__magnetic_field))
then
266 safe_allocate(dtmp(1:mesh%np, 1:space%dim))
270 mesh, dtmp, fn_unit, ierr)
271 safe_deallocate_a(dtmp)
282 class(
space_t),
intent(in) :: space
283 character(len=*),
intent(in) :: dir
285 class(
mesh_t),
intent(in) :: mesh
288 real(real64),
allocatable :: energy_density(:), e_energy_density(:), b_energy_density(:)
293 if (outp%what(option__maxwelloutput__maxwell_energy_density))
then
294 safe_allocate(energy_density(1:mesh%np))
295 safe_allocate(e_energy_density(1:mesh%np))
296 safe_allocate(b_energy_density(1:mesh%np))
298 call energy_density_calc(mesh, st, st%rs_state, energy_density, e_energy_density, b_energy_density)
300 call dio_function_output(outp%how(option__maxwelloutput__maxwell_energy_density), dir,
"maxwell_energy_density", &
303 safe_deallocate_a(energy_density)
304 safe_deallocate_a(e_energy_density)
305 safe_deallocate_a(b_energy_density)
316 class(
space_t),
intent(in) :: space
317 character(len=*),
intent(in) :: dir
319 class(
mesh_t),
intent(in) :: mesh
322 character(len=MAX_PATH_LEN) :: fname
324 real(real64),
allocatable :: poynting_vector(:,:), oam(:,:)
328 if (outp%what(option__maxwelloutput__poynting_vector).or.outp%what(option__maxwelloutput__orbital_angular_momentum))
then
332 safe_allocate(poynting_vector(1:mesh%np, 1:space%dim))
335 if(outp%what(option__maxwelloutput__poynting_vector))
then
336 fname =
'poynting_vector'
338 mesh, poynting_vector, fn_unit, ierr)
341 if(outp%what(option__maxwelloutput__orbital_angular_momentum))
then
342 safe_allocate(oam(1:mesh%np, 1:space%dim))
344 fname =
'orbital_angular_momentum'
345 call io_function_output_vector(outp%how(option__maxwelloutput__orbital_angular_momentum), dir, fname, namespace, space, &
346 mesh, oam, fn_unit, ierr)
347 safe_deallocate_a(oam)
350 safe_deallocate_a(poynting_vector)
362 type(
grid_t),
intent(in) :: gr
363 class(
space_t),
intent(in) :: space
364 character(len=*),
intent(in) :: dir
367 character(len=MAX_PATH_LEN) :: fname
370 real(real64),
allocatable :: dtmp(:,:),vtmp(:,:), mag_fromvec(:,:) , delta(:,:)
375 if (outp%what(option__maxwelloutput__vector_potential_mag) .or. &
376 outp%what(option__maxwelloutput__magnetic_field_diff))
then
379 safe_allocate(dtmp(1:gr%np_part, 1:space%dim))
380 safe_allocate(vtmp(1:gr%np_part, 1:space%dim))
383 call helmholtz%get_vector_potential(namespace, vtmp, trans_field=dtmp)
385 if (outp%what(option__maxwelloutput__vector_potential_mag))
then
386 message(1) =
'Vector potential is currently missing surface contributions'
387 message(2) =
'If in doubt, use magnetic_field_diff output which shows deviation of B field'
388 message(3) =
'Large B field deviations mean the calculated vector potential is unreliable'
391 fname =
'vector_potential_mag'
393 space, gr, vtmp, fn_unit, ierr)
396 if (outp%what(option__maxwelloutput__magnetic_field_diff))
then
398 safe_allocate(mag_fromvec(1:gr%np_part, 1:space%dim))
399 safe_allocate(delta(1:gr%np, 1:space%dim))
401 call helmholtz%get_trans_field(namespace, mag_fromvec, vector_potential=vtmp)
404 call helmholtz%apply_inner_stencil_mask(dtmp)
405 delta = dtmp(1:gr%np, 1:space%dim) - mag_fromvec(1:gr%np, 1:space%dim)
406 fname =
'magnetic_field_diff'
408 space, gr, delta, fn_unit, ierr)
409 safe_deallocate_a(mag_fromvec)
410 safe_deallocate_a(delta)
413 safe_deallocate_a(dtmp)
414 safe_deallocate_a(vtmp)
426 class(
space_t),
intent(in) :: space
427 character(len=*),
intent(in) :: dir
429 type(
grid_t),
intent(in) :: gr
431 character(len=MAX_PATH_LEN) :: fname
434 real(real64),
allocatable :: dtmp(:,:)
438 if (outp%what(option__maxwelloutput__trans_electric_field) .or. outp%what(option__maxwelloutput__trans_magnetic_field))
then
439 call helmholtz%get_trans_field(namespace, st%rs_state_trans, total_field=st%rs_state)
443 if (outp%what(option__maxwelloutput__trans_electric_field))
then
445 safe_allocate(dtmp(1:gr%np, 1:space%dim))
447 fname =
'e_field_trans'
449 gr, dtmp, fn_unit, ierr)
450 safe_deallocate_a(dtmp)
454 if (outp%what(option__maxwelloutput__trans_magnetic_field))
then
456 safe_allocate(dtmp(1:gr%np, 1:space%dim))
458 fname =
'b_field_trans'
460 gr, dtmp, fn_unit, ierr)
461 safe_deallocate_a(dtmp)
474 class(
space_t),
intent(in) :: space
475 character(len=*),
intent(in) :: dir
477 type(
grid_t),
intent(in) :: gr
479 character(len=MAX_PATH_LEN) :: fname
482 real(real64),
allocatable :: dtmp(:,:)
486 if (outp%what(option__maxwelloutput__long_electric_field) .or. outp%what(option__maxwelloutput__long_magnetic_field))
then
487 call helmholtz%get_long_field(namespace, st%rs_state_long, total_field=st%rs_state)
491 if (outp%what(option__maxwelloutput__long_electric_field))
then
493 safe_allocate(dtmp(1:gr%np, 1:space%dim))
495 fname =
'e_field_long'
497 gr, dtmp, fn_unit, ierr)
498 safe_deallocate_a(dtmp)
502 if (outp%what(option__maxwelloutput__long_magnetic_field))
then
504 safe_allocate(dtmp(1:gr%np, 1:space%dim))
506 fname =
'b_field_long'
508 gr, dtmp, fn_unit, ierr)
509 safe_deallocate_a(dtmp)
520 class(
space_t),
intent(in) :: space
521 character(len=*),
intent(in) :: dir
523 type(
grid_t),
intent(in) :: gr
527 real(real64),
allocatable :: dtmp_1(:,:), dtmp_2(:)
532 if (outp%what(option__maxwelloutput__div_electric_field))
then
534 safe_allocate(dtmp_1(1:gr%np_part, 1:space%dim))
535 safe_allocate(dtmp_2(1:gr%np))
539 call dio_function_output(outp%how(option__maxwelloutput__div_electric_field), dir,
"e_field_div", namespace, space, &
540 gr, dtmp_2, fn_unit, ierr)
541 safe_deallocate_a(dtmp_1)
542 safe_deallocate_a(dtmp_2)
546 if (outp%what(option__maxwelloutput__div_magnetic_field))
then
549 safe_allocate(dtmp_1(1:gr%np_part, 1:space%dim))
550 safe_allocate(dtmp_2(1:gr%np))
554 call dio_function_output(outp%how(option__maxwelloutput__div_magnetic_field), dir,
"b_field_div", namespace, space, &
555 gr, dtmp_2, fn_unit, ierr)
556 safe_deallocate_a(dtmp_1)
557 safe_deallocate_a(dtmp_2)
568 character(len=*),
intent(in) :: dir
570 type(
grid_t),
intent(in) :: gr
572 message(1) =
"Maxwell-matter coupling potentials not implemented yet."
579 subroutine output_current_density(outp, namespace, dir, st_mxll, gr_mxll, hm_mxll, st_elec, gr_elec, hm_elec, time)
582 character(len=*),
intent(in) :: dir
584 type(
grid_t),
intent(in) :: gr_mxll
587 type(
grid_t),
intent(in) :: gr_elec
589 real(real64),
intent(in) :: time
591 message(1) =
"Current density can not yet be calculated in a Maxwell propagation."
601 class(
space_t),
intent(in) :: space
602 character(len=*),
intent(in) :: dir
604 class(
mesh_t),
intent(in) :: mesh
606 real(real64),
intent(in) :: time
608 character(len=MAX_PATH_LEN) :: fname
610 real(real64),
allocatable :: dtmp(:,:)
616 if (outp%what(option__maxwelloutput__external_current))
then
617 if (hm%current_density_ext_flag)
then
619 safe_allocate(dtmp(1:mesh%np, 1:space%dim))
621 fname =
'external_current'
623 mesh, dtmp, fn_unit, ierr)
624 safe_deallocate_a(dtmp)
634 class(
space_t),
intent(in) :: space
635 character(len=*),
intent(in) :: dir
637 class(
mesh_t),
intent(in) :: mesh
639 real(real64),
intent(in) :: time
640 real(real64),
optional,
intent(in) :: ep_field(:)
641 integer,
optional,
intent(in) :: np
643 real(real64),
allocatable :: ctmp(:,:)
644 character(len=MAX_PATH_LEN) :: fname
645 integer :: ierr, ip, idim, np_, ff_dim
649 safe_allocate(ctmp(1:mesh%np, 1:space%dim))
650 if (outp%what(option__maxwelloutput__total_current_mxll))
then
653 if (
present(ep_field))
then
656 ctmp(ip, idim) =
sqrt(
m_two*ep_field(ip)) * real(st%rs_current_density_t1(ip, idim))
662 ctmp(ip, idim) =
sqrt(
m_two*
p_ep) * real(st%rs_current_density_t1(ip, idim))
668 fname =
'total_current_mxll'
670 mesh, ctmp, fn_unit, ierr)
672 safe_deallocate_a(ctmp)
681 class(
space_t),
intent(in) :: space
682 character(len=*),
intent(in) :: dir
684 type(
grid_t),
intent(in) :: gr
689 real(real64),
allocatable :: dtmp_1(:,:), dtmp_2(:)
694 if (outp%what(option__maxwelloutput__charge_density))
then
696 safe_allocate(dtmp_1(1:gr%np_part,1:space%dim))
697 safe_allocate(dtmp_2(1:gr%np))
700 call dio_function_output(outp%how(option__maxwelloutput__charge_density), dir,
"charge_density", namespace, space, &
701 gr, dtmp_2(:), fn_unit, ierr)
702 safe_deallocate_a(dtmp_1)
703 safe_deallocate_a(dtmp_2)
subroutine, public energy_density_calc(mesh, st, rs_field, energy_dens, e_energy_dens, b_energy_dens, plane_waves_check, rs_field_plane_waves, energy_dens_plane_waves)
subroutine, public external_current_calculation(st, space, mesh, time, current)
real(real64), parameter, public m_two
real(real64), parameter, public m_zero
real(real64), parameter, public p_ep
This module implements the underlying real-space grid.
The Helmholtz decomposition is intended to contain "only mathematical" functions and procedures to co...
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)
subroutine, public dio_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_mkdir(fname, namespace, parents)
This module defines the meshes, which are used in Octopus.
subroutine, public messages_warning(no_lines, all_nodes, namespace)
character(len=256), dimension(max_lines), public message
to be output by fatal, warning
subroutine, public messages_fatal(no_lines, only_root_writes, namespace)
subroutine, public messages_info(no_lines, iunit, debug_only, stress, all_nodes, namespace)
this module contains the low-level part of the output system
subroutine output_total_current_mxll(outp, namespace, space, dir, st, mesh, hm, time, ep_field, np)
subroutine output_states_mxll(outp, namespace, space, dir, st, mesh)
subroutine output_current_density(outp, namespace, dir, st_mxll, gr_mxll, hm_mxll, st_elec, gr_elec, hm_elec, time)
subroutine output_poynting_vector_orbital_angular_momentum(outp, namespace, space, dir, st, mesh)
subroutine output_external_current_density(outp, namespace, space, dir, st, mesh, hm, time)
subroutine, public output_mxll_init(outp, namespace, space)
subroutine output_coupling_potentials(outp, namespace, dir, hm, gr)
subroutine output_transverse_rs_state(helmholtz, outp, namespace, space, dir, st, gr)
subroutine output_energy_density_mxll(outp, namespace, space, dir, st, mesh)
subroutine output_longitudinal_rs_state(helmholtz, outp, namespace, space, dir, st, gr)
subroutine, public output_mxll(outp, namespace, space, gr_mxll, st_mxll, hm_mxll, helmholtz, time, dir, gr_elec, st_elec, hm_elec)
subroutine output_vector_potential_mag(outp, helmholtz, namespace, gr, space, dir, st)
subroutine output_divergence_rs_state(outp, namespace, space, dir, st, gr)
subroutine output_charge_density_mxll(outp, namespace, space, dir, st, gr, hm)
this module contains the output system
logical function, public parse_is_defined(namespace, name)
subroutine, public get_orbital_angular_momentum(mesh, poynting_vector, orbital_angular_momentum)
subroutine, public get_electric_field_state(rs_state, mesh, electric_field, ep_field, np)
subroutine, public get_poynting_vector(mesh, st, rs_state, rs_sign, poynting_vector, ep_field, mu_field)
subroutine, public get_divergence_field(gr, field, field_div, charge_density)
subroutine, public get_magnetic_field_state(rs_state, mesh, rs_sign, magnetic_field, mu_field, np)
subroutine, public add_last_slash(str)
Adds a '/' in the end of the string, only if it missing. Useful for directories.
brief This module defines the class unit_t which is used by the unit_systems_oct_m module.
This module defines the unit system, used for input and output.
type(unit_system_t), public units_out
type(unit_t), public unit_one
some special units required for particular quantities
Description of the grid, containing information on derivatives, stencil, and symmetries.
Describes mesh distribution to nodes.
The states_elec_t class contains all electronic wave functions.