59 type(output_t),
intent(out) :: outp
60 type(namespace_t),
intent(in) :: namespace
61 class(space_t),
intent(in) :: space
137 'MaxwellOutput',
'OutputFormat',
'MaxwellOutputInterval')
139 do what_i = lbound(outp%what, 1), ubound(outp%what, 1)
141 if (
bitand(outp%how(what_i), option__outputformat__xyz) /= 0)
then
142 message(1) =
"OutputFormat = xyz is not compatible with Maxwell systems"
160 call parse_variable(namespace,
'MaxwellOutputIterDir',
"output_iter", outp%iter_dir)
161 if (any(outp%what) .and. maxval(outp%output_interval) > 0)
then
162 call io_mkdir(outp%iter_dir, namespace)
174 call parse_variable(namespace,
'MaxwellRestartWriteInterval', 50, outp%restart_write_interval)
175 if (outp%restart_write_interval <= 0)
then
176 message(1) =
"MaxwellRestartWriteInterval must be > 0."
180 if (outp%what(option__maxwelloutput__electric_field))
then
181 outp%wfs_list = trim(
"1-3")
184 if (outp%what(option__maxwelloutput__magnetic_field))
then
185 outp%wfs_list = trim(
"1-3")
188 if (outp%what(option__maxwelloutput__trans_electric_field))
then
189 outp%wfs_list = trim(
"1-3")
192 if (outp%what(option__maxwelloutput__trans_magnetic_field))
then
193 outp%wfs_list = trim(
"1-3")
202 subroutine output_mxll(outp, namespace, space, gr_mxll, st_mxll, hm_mxll, helmholtz, time, dir, gr_elec, st_elec, hm_elec)
205 class(
space_t),
intent(in) :: space
208 type(
grid_t),
intent(in) :: gr_mxll
210 real(real64),
intent(in) :: time
211 character(len=*),
intent(in) :: dir
212 type(
grid_t),
optional,
intent(inout) :: gr_elec
218 if (any(outp%what))
then
219 message(1) =
"Info: Writing output to " // trim(dir)
235 if (
present(hm_elec) .and.
present(gr_elec) .and.
present(st_elec))
then
237 call output_current_density(outp, namespace, dir, st_mxll, gr_mxll, hm_mxll, st_elec, gr_elec, hm_elec, time)
248 class(
space_t),
intent(in) :: space
249 character(len=*),
intent(in) :: dir
251 class(
mesh_t),
intent(in) :: mesh
254 character(len=MAX_PATH_LEN) :: fname
256 real(real64),
allocatable :: dtmp(:,:)
261 if (outp%what(option__maxwelloutput__electric_field))
then
263 safe_allocate(dtmp(1:mesh%np, 1:space%dim))
267 mesh, dtmp, fn_unit, ierr)
268 safe_deallocate_a(dtmp)
272 if (outp%what(option__maxwelloutput__magnetic_field))
then
274 safe_allocate(dtmp(1:mesh%np, 1:space%dim))
278 mesh, dtmp, fn_unit, ierr)
279 safe_deallocate_a(dtmp)
290 class(
space_t),
intent(in) :: space
291 character(len=*),
intent(in) :: dir
293 class(
mesh_t),
intent(in) :: mesh
296 real(real64),
allocatable :: energy_density(:), e_energy_density(:), b_energy_density(:)
301 if (outp%what(option__maxwelloutput__maxwell_energy_density))
then
302 safe_allocate(energy_density(1:mesh%np))
303 safe_allocate(e_energy_density(1:mesh%np))
304 safe_allocate(b_energy_density(1:mesh%np))
306 call energy_density_calc(mesh, st, st%rs_state, energy_density, e_energy_density, b_energy_density)
308 call dio_function_output(outp%how(option__maxwelloutput__maxwell_energy_density), dir,
"maxwell_energy_density", &
311 safe_deallocate_a(energy_density)
312 safe_deallocate_a(e_energy_density)
313 safe_deallocate_a(b_energy_density)
324 class(
space_t),
intent(in) :: space
325 character(len=*),
intent(in) :: dir
327 class(
mesh_t),
intent(in) :: mesh
330 character(len=MAX_PATH_LEN) :: fname
332 real(real64),
allocatable :: poynting_vector(:,:), oam(:,:)
336 if (outp%what(option__maxwelloutput__poynting_vector).or.outp%what(option__maxwelloutput__orbital_angular_momentum))
then
340 safe_allocate(poynting_vector(1:mesh%np, 1:space%dim))
343 if(outp%what(option__maxwelloutput__poynting_vector))
then
344 fname =
'poynting_vector'
346 mesh, poynting_vector, fn_unit, ierr)
349 if(outp%what(option__maxwelloutput__orbital_angular_momentum))
then
350 safe_allocate(oam(1:mesh%np, 1:space%dim))
352 fname =
'orbital_angular_momentum'
353 call io_function_output_vector(outp%how(option__maxwelloutput__orbital_angular_momentum), dir, fname, namespace, space, &
354 mesh, oam, fn_unit, ierr)
355 safe_deallocate_a(oam)
358 safe_deallocate_a(poynting_vector)
370 type(
grid_t),
intent(in) :: gr
371 class(
space_t),
intent(in) :: space
372 character(len=*),
intent(in) :: dir
375 character(len=MAX_PATH_LEN) :: fname
378 real(real64),
allocatable :: dtmp(:,:),vtmp(:,:), mag_fromvec(:,:) , delta(:,:)
383 if (outp%what(option__maxwelloutput__vector_potential_mag) .or. &
384 outp%what(option__maxwelloutput__magnetic_field_diff))
then
387 safe_allocate(dtmp(1:gr%np_part, 1:space%dim))
388 safe_allocate(vtmp(1:gr%np_part, 1:space%dim))
391 call helmholtz%get_vector_potential(namespace, vtmp, trans_field=dtmp)
393 if (outp%what(option__maxwelloutput__vector_potential_mag))
then
394 message(1) =
'Vector potential is currently missing surface contributions'
395 message(2) =
'If in doubt, use magnetic_field_diff output which shows deviation of B field'
396 message(3) =
'Large B field deviations mean the calculated vector potential is unreliable'
399 fname =
'vector_potential_mag'
401 space, gr, vtmp, fn_unit, ierr)
404 if (outp%what(option__maxwelloutput__magnetic_field_diff))
then
406 safe_allocate(mag_fromvec(1:gr%np_part, 1:space%dim))
407 safe_allocate(delta(1:gr%np, 1:space%dim))
409 call helmholtz%get_trans_field(namespace, mag_fromvec, vector_potential=vtmp)
412 call helmholtz%apply_inner_stencil_mask(dtmp)
413 delta = dtmp(1:gr%np, 1:space%dim) - mag_fromvec(1:gr%np, 1:space%dim)
414 fname =
'magnetic_field_diff'
416 space, gr, delta, fn_unit, ierr)
417 safe_deallocate_a(mag_fromvec)
418 safe_deallocate_a(delta)
421 safe_deallocate_a(dtmp)
422 safe_deallocate_a(vtmp)
434 class(
space_t),
intent(in) :: space
435 character(len=*),
intent(in) :: dir
437 type(
grid_t),
intent(in) :: gr
439 character(len=MAX_PATH_LEN) :: fname
442 real(real64),
allocatable :: dtmp(:,:)
446 if (outp%what(option__maxwelloutput__trans_electric_field) .or. outp%what(option__maxwelloutput__trans_magnetic_field))
then
447 call helmholtz%get_trans_field(namespace, st%rs_state_trans, total_field=st%rs_state)
451 if (outp%what(option__maxwelloutput__trans_electric_field))
then
453 safe_allocate(dtmp(1:gr%np, 1:space%dim))
455 fname =
'e_field_trans'
457 gr, dtmp, fn_unit, ierr)
458 safe_deallocate_a(dtmp)
462 if (outp%what(option__maxwelloutput__trans_magnetic_field))
then
464 safe_allocate(dtmp(1:gr%np, 1:space%dim))
466 fname =
'b_field_trans'
468 gr, dtmp, fn_unit, ierr)
469 safe_deallocate_a(dtmp)
482 class(
space_t),
intent(in) :: space
483 character(len=*),
intent(in) :: dir
485 type(
grid_t),
intent(in) :: gr
487 character(len=MAX_PATH_LEN) :: fname
490 real(real64),
allocatable :: dtmp(:,:)
494 if (outp%what(option__maxwelloutput__long_electric_field) .or. outp%what(option__maxwelloutput__long_magnetic_field))
then
495 call helmholtz%get_long_field(namespace, st%rs_state_long, total_field=st%rs_state)
499 if (outp%what(option__maxwelloutput__long_electric_field))
then
501 safe_allocate(dtmp(1:gr%np, 1:space%dim))
503 fname =
'e_field_long'
505 gr, dtmp, fn_unit, ierr)
506 safe_deallocate_a(dtmp)
510 if (outp%what(option__maxwelloutput__long_magnetic_field))
then
512 safe_allocate(dtmp(1:gr%np, 1:space%dim))
514 fname =
'b_field_long'
516 gr, dtmp, fn_unit, ierr)
517 safe_deallocate_a(dtmp)
528 class(
space_t),
intent(in) :: space
529 character(len=*),
intent(in) :: dir
531 type(
grid_t),
intent(in) :: gr
535 real(real64),
allocatable :: dtmp_1(:,:), dtmp_2(:)
540 if (outp%what(option__maxwelloutput__div_electric_field))
then
542 safe_allocate(dtmp_1(1:gr%np_part, 1:space%dim))
543 safe_allocate(dtmp_2(1:gr%np))
547 call dio_function_output(outp%how(option__maxwelloutput__div_electric_field), dir,
"e_field_div", namespace, space, &
548 gr, dtmp_2, fn_unit, ierr)
549 safe_deallocate_a(dtmp_1)
550 safe_deallocate_a(dtmp_2)
554 if (outp%what(option__maxwelloutput__div_magnetic_field))
then
557 safe_allocate(dtmp_1(1:gr%np_part, 1:space%dim))
558 safe_allocate(dtmp_2(1:gr%np))
562 call dio_function_output(outp%how(option__maxwelloutput__div_magnetic_field), dir,
"b_field_div", namespace, space, &
563 gr, dtmp_2, fn_unit, ierr)
564 safe_deallocate_a(dtmp_1)
565 safe_deallocate_a(dtmp_2)
576 character(len=*),
intent(in) :: dir
578 type(
grid_t),
intent(in) :: gr
580 message(1) =
"Maxwell-matter coupling potentials not implemented yet."
587 subroutine output_current_density(outp, namespace, dir, st_mxll, gr_mxll, hm_mxll, st_elec, gr_elec, hm_elec, time)
590 character(len=*),
intent(in) :: dir
592 type(
grid_t),
intent(in) :: gr_mxll
595 type(
grid_t),
intent(in) :: gr_elec
597 real(real64),
intent(in) :: time
599 message(1) =
"Current density can not yet be calculated in a Maxwell propagation."
609 class(
space_t),
intent(in) :: space
610 character(len=*),
intent(in) :: dir
612 class(
mesh_t),
intent(in) :: mesh
614 real(real64),
intent(in) :: time
616 character(len=MAX_PATH_LEN) :: fname
618 real(real64),
allocatable :: dtmp(:,:)
624 if (outp%what(option__maxwelloutput__external_current))
then
625 if (hm%current_density_ext_flag)
then
627 safe_allocate(dtmp(1:mesh%np, 1:space%dim))
629 fname =
'external_current'
631 mesh, dtmp, fn_unit, ierr)
632 safe_deallocate_a(dtmp)
642 class(
space_t),
intent(in) :: space
643 character(len=*),
intent(in) :: dir
645 class(
mesh_t),
intent(in) :: mesh
647 real(real64),
intent(in) :: time
648 real(real64),
optional,
intent(in) :: ep_field(:)
649 integer,
optional,
intent(in) :: np
651 real(real64),
allocatable :: ctmp(:,:)
652 character(len=MAX_PATH_LEN) :: fname
653 integer :: ierr, ip, idim, np_, ff_dim
657 safe_allocate(ctmp(1:mesh%np, 1:space%dim))
658 if (outp%what(option__maxwelloutput__total_current_mxll))
then
661 if (
present(ep_field))
then
664 ctmp(ip, idim) =
sqrt(
m_two*ep_field(ip)) * real(st%rs_current_density_t1(ip, idim))
670 ctmp(ip, idim) =
sqrt(
m_two*
p_ep) * real(st%rs_current_density_t1(ip, idim))
676 fname =
'total_current_mxll'
678 mesh, ctmp, fn_unit, ierr)
680 safe_deallocate_a(ctmp)
689 class(
space_t),
intent(in) :: space
690 character(len=*),
intent(in) :: dir
692 type(
grid_t),
intent(in) :: gr
697 real(real64),
allocatable :: dtmp_1(:,:), dtmp_2(:)
702 if (outp%what(option__maxwelloutput__charge_density))
then
704 safe_allocate(dtmp_1(1:gr%np_part,1:space%dim))
705 safe_allocate(dtmp_2(1:gr%np))
708 call dio_function_output(outp%how(option__maxwelloutput__charge_density), dir,
"charge_density", namespace, space, &
709 gr, dtmp_2(:), fn_unit, ierr)
710 safe_deallocate_a(dtmp_1)
711 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)
subroutine, public messages_info(no_lines, iunit, verbose_limit, stress, 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)
this module contains 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
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 get_orbital_angular_momentum(mesh, st, poynting_vector, orbital_angular_momentum)
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.