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
320 real(real64),
intent(in) :: c_factor
323 character(len=MAX_PATH_LEN) :: fname
325 real(real64),
allocatable :: poynting_vector(:,:), oam(:,:)
329 if (outp%what(option__maxwelloutput__poynting_vector).or.outp%what(option__maxwelloutput__orbital_angular_momentum))
then
333 safe_allocate(poynting_vector(1:mesh%np, 1:space%dim))
334 call get_poynting_vector(mesh, st, st%rs_state, st%rs_sign, c_factor, poynting_vector, st%ep, st%mu)
336 if(outp%what(option__maxwelloutput__poynting_vector))
then
337 fname =
'poynting_vector'
339 mesh, poynting_vector, fn_unit, ierr)
342 if(outp%what(option__maxwelloutput__orbital_angular_momentum))
then
343 safe_allocate(oam(1:mesh%np, 1:space%dim))
345 fname =
'orbital_angular_momentum'
346 call io_function_output_vector(outp%how(option__maxwelloutput__orbital_angular_momentum), dir, fname, namespace, space, &
347 mesh, oam, fn_unit, ierr)
348 safe_deallocate_a(oam)
351 safe_deallocate_a(poynting_vector)
363 type(
grid_t),
intent(in) :: gr
364 class(
space_t),
intent(in) :: space
365 character(len=*),
intent(in) :: dir
368 character(len=MAX_PATH_LEN) :: fname
371 real(real64),
allocatable :: dtmp(:,:),vtmp(:,:), mag_fromvec(:,:) , delta(:,:)
376 if (outp%what(option__maxwelloutput__vector_potential_mag) .or. &
377 outp%what(option__maxwelloutput__magnetic_field_diff))
then
380 safe_allocate(dtmp(1:gr%np_part, 1:space%dim))
381 safe_allocate(vtmp(1:gr%np_part, 1:space%dim))
384 call helmholtz%get_vector_potential(namespace, vtmp, trans_field=dtmp)
386 if (outp%what(option__maxwelloutput__vector_potential_mag))
then
387 message(1) =
'Vector potential is currently missing surface contributions'
388 message(2) =
'If in doubt, use magnetic_field_diff output which shows deviation of B field'
389 message(3) =
'Large B field deviations mean the calculated vector potential is unreliable'
392 fname =
'vector_potential_mag'
394 space, gr, vtmp, fn_unit, ierr)
397 if (outp%what(option__maxwelloutput__magnetic_field_diff))
then
399 safe_allocate(mag_fromvec(1:gr%np_part, 1:space%dim))
400 safe_allocate(delta(1:gr%np, 1:space%dim))
402 call helmholtz%get_trans_field(namespace, mag_fromvec, vector_potential=vtmp)
405 call helmholtz%apply_inner_stencil_mask(dtmp)
406 delta = dtmp(1:gr%np, 1:space%dim) - mag_fromvec(1:gr%np, 1:space%dim)
407 fname =
'magnetic_field_diff'
409 space, gr, delta, fn_unit, ierr)
410 safe_deallocate_a(mag_fromvec)
411 safe_deallocate_a(delta)
414 safe_deallocate_a(dtmp)
415 safe_deallocate_a(vtmp)
427 class(
space_t),
intent(in) :: space
428 character(len=*),
intent(in) :: dir
430 type(
grid_t),
intent(in) :: gr
432 character(len=MAX_PATH_LEN) :: fname
435 real(real64),
allocatable :: dtmp(:,:)
439 if (outp%what(option__maxwelloutput__trans_electric_field) .or. outp%what(option__maxwelloutput__trans_magnetic_field))
then
440 call helmholtz%get_trans_field(namespace, st%rs_state_trans, total_field=st%rs_state)
444 if (outp%what(option__maxwelloutput__trans_electric_field))
then
446 safe_allocate(dtmp(1:gr%np, 1:space%dim))
448 fname =
'e_field_trans'
450 gr, dtmp, fn_unit, ierr)
451 safe_deallocate_a(dtmp)
455 if (outp%what(option__maxwelloutput__trans_magnetic_field))
then
457 safe_allocate(dtmp(1:gr%np, 1:space%dim))
459 fname =
'b_field_trans'
461 gr, dtmp, fn_unit, ierr)
462 safe_deallocate_a(dtmp)
475 class(
space_t),
intent(in) :: space
476 character(len=*),
intent(in) :: dir
478 type(
grid_t),
intent(in) :: gr
480 character(len=MAX_PATH_LEN) :: fname
483 real(real64),
allocatable :: dtmp(:,:)
487 if (outp%what(option__maxwelloutput__long_electric_field) .or. outp%what(option__maxwelloutput__long_magnetic_field))
then
488 call helmholtz%get_long_field(namespace, st%rs_state_long, total_field=st%rs_state)
492 if (outp%what(option__maxwelloutput__long_electric_field))
then
494 safe_allocate(dtmp(1:gr%np, 1:space%dim))
496 fname =
'e_field_long'
498 gr, dtmp, fn_unit, ierr)
499 safe_deallocate_a(dtmp)
503 if (outp%what(option__maxwelloutput__long_magnetic_field))
then
505 safe_allocate(dtmp(1:gr%np, 1:space%dim))
507 fname =
'b_field_long'
509 gr, dtmp, fn_unit, ierr)
510 safe_deallocate_a(dtmp)
521 class(
space_t),
intent(in) :: space
522 character(len=*),
intent(in) :: dir
524 type(
grid_t),
intent(in) :: gr
528 real(real64),
allocatable :: dtmp_1(:,:), dtmp_2(:)
533 if (outp%what(option__maxwelloutput__div_electric_field))
then
535 safe_allocate(dtmp_1(1:gr%np_part, 1:space%dim))
536 safe_allocate(dtmp_2(1:gr%np))
540 call dio_function_output(outp%how(option__maxwelloutput__div_electric_field), dir,
"e_field_div", namespace, space, &
541 gr, dtmp_2, fn_unit, ierr)
542 safe_deallocate_a(dtmp_1)
543 safe_deallocate_a(dtmp_2)
547 if (outp%what(option__maxwelloutput__div_magnetic_field))
then
550 safe_allocate(dtmp_1(1:gr%np_part, 1:space%dim))
551 safe_allocate(dtmp_2(1:gr%np))
555 call dio_function_output(outp%how(option__maxwelloutput__div_magnetic_field), dir,
"b_field_div", namespace, space, &
556 gr, dtmp_2, fn_unit, ierr)
557 safe_deallocate_a(dtmp_1)
558 safe_deallocate_a(dtmp_2)
569 character(len=*),
intent(in) :: dir
571 type(
grid_t),
intent(in) :: gr
573 message(1) =
"Maxwell-matter coupling potentials not implemented yet."
580 subroutine output_current_density(outp, namespace, dir, st_mxll, gr_mxll, hm_mxll, st_elec, gr_elec, hm_elec, time)
583 character(len=*),
intent(in) :: dir
585 type(
grid_t),
intent(in) :: gr_mxll
588 type(
grid_t),
intent(in) :: gr_elec
590 real(real64),
intent(in) :: time
592 message(1) =
"Current density can not yet be calculated in a Maxwell propagation."
602 class(
space_t),
intent(in) :: space
603 character(len=*),
intent(in) :: dir
605 class(
mesh_t),
intent(in) :: mesh
607 real(real64),
intent(in) :: time
609 character(len=MAX_PATH_LEN) :: fname
611 real(real64),
allocatable :: dtmp(:,:)
617 if (outp%what(option__maxwelloutput__external_current))
then
618 if (hm%current_density_ext_flag)
then
620 safe_allocate(dtmp(1:mesh%np, 1:space%dim))
622 fname =
'external_current'
624 mesh, dtmp, fn_unit, ierr)
625 safe_deallocate_a(dtmp)
635 class(
space_t),
intent(in) :: space
636 character(len=*),
intent(in) :: dir
640 real(real64),
intent(in) :: time
641 real(real64),
contiguous,
optional,
intent(in) :: ep_field(:)
642 integer,
optional,
intent(in) :: np
644 real(real64),
allocatable :: ctmp(:,:)
645 character(len=MAX_PATH_LEN) :: fname
646 integer :: ierr, ip, idim, np_, ff_dim
650 safe_allocate(ctmp(1:mesh%np, 1:space%dim))
651 if (outp%what(option__maxwelloutput__total_current_mxll))
then
654 if (
present(ep_field))
then
657 ctmp(ip, idim) =
sqrt(
m_two*ep_field(ip)) * real(st%rs_current_density_t1(ip, idim))
663 ctmp(ip, idim) =
sqrt(
m_two*
p_ep) * real(st%rs_current_density_t1(ip, idim))
669 fname =
'total_current_mxll'
671 mesh, ctmp, fn_unit, ierr)
673 safe_deallocate_a(ctmp)
682 class(
space_t),
intent(in) :: space
683 character(len=*),
intent(in) :: dir
685 type(
grid_t),
intent(in) :: gr
690 real(real64),
allocatable :: dtmp_1(:,:), dtmp_2(:)
695 if (outp%what(option__maxwelloutput__charge_density))
then
697 safe_allocate(dtmp_1(1:gr%np_part,1:space%dim))
698 safe_allocate(dtmp_2(1:gr%np))
701 call dio_function_output(outp%how(option__maxwelloutput__charge_density), dir,
"charge_density", namespace, space, &
702 gr, dtmp_2(:), fn_unit, ierr)
703 safe_deallocate_a(dtmp_1)
704 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_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_poynting_vector_orbital_angular_momentum(outp, namespace, space, dir, st, mesh, c_factor)
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)
/* To use the profiling module, call profiling_in and profiling_out with the label of the region as a...
subroutine, public get_poynting_vector(mesh, st, rs_state, rs_sign, c_factor, poynting_vector, ep_field, mu_field)
Poynting vector (1/mu) E x B of the Riemann-Silberstein state. The field propagates with the curl pre...
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_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.