59 integer,
parameter :: &
60 LOCAL_OUT_MULTIPOLES = 1, &
69 logical :: write = .false.
74 type(local_write_prop_t),
allocatable :: out(:)
83 type(local_write_t),
intent(in) :: writ
94 type(local_write_t),
intent(inout) :: writ
95 type(namespace_t),
intent(in) :: namespace
96 character(len=15),
intent(in) :: lab
97 integer,
intent(in) :: iter
98 real(real64),
intent(in) :: dt
100 integer :: first, flags, iout, default
134 default = 2**(local_out_multipoles - 1)
144 writ%out(iout)%write = (
bitand(flags, 2**(iout - 1)) /= 0)
171 if (writ%lmax < 0)
then
172 write(
message(1),
'(a,i6,a)')
"Input: '", writ%lmax,
"' is not a valid LDMultipoleLmax."
173 message(2) =
'(Must be LDMultipoleLmax >= 0)'
177 call io_mkdir(
'local.general', namespace)
180 if (writ%out(local_out_multipoles)%write)
then
181 call io_mkdir(
'local.general/multipoles', namespace)
183 trim(
io_workpath(
"local.general/multipoles/"//trim(lab)//
".multipoles", namespace)))
187 call io_mkdir(
'local.general/potential', namespace)
189 trim(
io_workpath(
"local.general/potential/"//trim(lab)//
".potential", namespace)))
193 call io_mkdir(
'local.general/densities', namespace)
195 trim(
io_workpath(
"local.general/densities/"//trim(lab)//
".densities", namespace)))
199 call io_mkdir(
'local.general/energy', namespace)
201 trim(
io_workpath(
"local.general/energy/"//trim(lab)//
".energy", namespace)))
218 if (writ%out(iout)%write)
then
223 safe_deallocate_a(writ%out)
229 subroutine local_write_iter(writ, namespace, space, lab, ions_mask, mesh_mask, mesh, st, hm, ks, &
230 ions, ext_partners, kick, iter, l_start, ldoverwrite)
234 character(len=15),
intent(in) :: lab
235 logical,
intent(in) :: ions_mask(:)
236 logical,
intent(in) :: mesh_mask(:)
237 class(
mesh_t),
intent(in) :: mesh
240 type(
v_ks_t),
intent(inout) :: ks
241 type(
ions_t),
intent(inout) :: ions
243 type(
kick_t),
intent(inout) :: kick
244 integer,
intent(in) :: iter
245 integer,
intent(in) :: l_start
246 logical,
intent(in) :: ldoverwrite
252 if (writ%out(local_out_multipoles)%write)
then
253 call local_write_multipole(writ%out(local_out_multipoles), namespace, lab, ions_mask, mesh_mask, mesh, ions, st, &
254 writ%lmax, kick, iter, l_start, ldoverwrite, writ%how)
262 mesh, ions, ext_partners, st, hm, ks, iter, writ%how)
267 ext_partners, st, hm, ks, iter, l_start, ldoverwrite)
278 subroutine local_write_density(out_dens, namespace, space, out_pot, lab, mesh_mask, mesh, ions, &
279 ext_partners, st, hm, ks, iter, how)
284 character(len=15),
intent(in) :: lab
285 logical,
intent(in) :: mesh_mask(:)
286 class(
mesh_t),
intent(in) :: mesh
287 type(
ions_t),
intent(inout) :: ions
291 type(
v_ks_t),
intent(inout) :: ks
292 integer,
intent(in) :: iter
293 integer(int64),
intent(in) :: how
296 character(len=120) :: folder, out_name
297 real(real64),
allocatable :: tmp_rho(:), st_rho(:)
298 real(real64),
allocatable :: tmp_vh(:)
302 safe_allocate(tmp_rho(1:mesh%np))
303 safe_allocate(st_rho(1:mesh%np_part))
304 safe_allocate(tmp_vh(1:mesh%np))
307 do is = 1, st%d%nspin
308 st_rho(:) = st%rho(:, is)
315 if (out_dens%write)
then
316 folder =
'local.general/densities/'//trim(lab)//
'.densities/'
317 write(out_name,
'(a,a1,i0,a1,i7.7)') trim(lab),
'.', is,
'.', iter
318 call dio_function_output(how, trim(folder), trim(out_name), namespace, space, mesh, tmp_rho(1:mesh%np), &
319 units_out%length, ierr, pos=ions%pos, atoms=ions%atom)
322 if (out_pot%write)
then
326 folder =
'local.general/potential/'//trim(lab)//
'.potential/'
327 write(out_name,
'(a,i0,a1,i7.7)')
'vh.', is,
'.', iter
329 pos=ions%pos, atoms=ions%atom)
332 st%rho(:, is) = st_rho
336 call v_ks_calc(ks, namespace, space, hm, st, ions, ext_partners, calc_eigenval = .false. , calc_energy = .false.)
337 folder =
'local.general/potential/'//trim(lab)//
'.potential/'
338 write(out_name,
'(a,i0,a1,i7.7)')
'vxc.', is,
'.', iter
339 call dio_function_output(how, trim(folder), trim(out_name), namespace, space, mesh, hm%vxc(:,is),
units_out%length, ierr, &
340 pos=ions%pos, atoms=ions%atom)
341 st%rho(:,is) = st_rho(:)
345 if (out_pot%write)
then
346 do is = 1, st%d%nspin
348 call dpoisson_solve(hm%psolver, namespace, hm%vhartree, st%rho(1:mesh%np, is))
349 folder =
'local.general/potential/'
350 write(out_name,
'(a,i0,a1,i7.7)')
'global-vh.', is,
'.', iter
352 pos=ions%pos, atoms=ions%atom)
354 call v_ks_calc(ks, namespace, space, hm, st, ions, ext_partners, calc_eigenval = .false. , calc_energy = .false.)
355 folder =
'local.general/potential/'
356 write(out_name,
'(a,i0,a1,i7.7)')
'global-vxc.', is,
'.', iter
357 call dio_function_output(how, trim(folder), trim(out_name), namespace, space, mesh, hm%vxc(:,is),
units_out%length, ierr, &
358 pos=ions%pos, atoms=ions%atom)
362 safe_deallocate_a(tmp_vh)
363 safe_deallocate_a(st_rho)
364 safe_deallocate_a(tmp_rho)
370 subroutine local_write_energy(out_energy, namespace, space, lab, mesh_mask, mesh, ions, ext_partners, &
371 st, hm, ks, iter, l_start, start)
375 character(len=15),
intent(in) :: lab
376 logical,
intent(in) :: mesh_mask(:)
377 class(
mesh_t),
intent(in) :: mesh
378 type(
ions_t),
intent(inout) :: ions
382 type(
v_ks_t),
intent(inout) :: ks
383 integer,
intent(in) :: iter
384 integer,
intent(in) :: l_start
385 logical,
intent(in) :: start
389 character(len=120) :: aux
390 real(real64) :: geh, gexc, leh, lexc
391 real(real64),
allocatable :: tmp_rhoi(:), st_rho(:)
392 real(real64),
allocatable :: hm_vxc(:), hm_vh(:)
396 safe_allocate(tmp_rhoi(1:mesh%np))
397 safe_allocate(st_rho(1:mesh%np_part))
398 safe_allocate(hm_vxc(1:mesh%np))
399 safe_allocate(hm_vh(1:mesh%np_part))
403 if (iter == l_start .and. start)
then
407 write(aux,
'(a,2x,a)')
'# Domain ID:', trim(lab)
409 write(aux,
'(a)') trim(lab)
413 aux =
'Total Hartree'
415 aux =
'Total Int[n*vxc]'
417 write(aux,
'(a)')
'Int[n*vh]'
419 write(aux,
'(a)')
'Int[n*vxc]'
445 do is = 1, st%d%nspin
447 call dpoisson_solve(hm%psolver, namespace, hm%vhartree, st%rho(1:mesh%np, is))
449 call v_ks_calc(ks, namespace, space, hm, st, ions, ext_partners, calc_eigenval = .false. , calc_energy = .false.)
451 st_rho(:) = st%rho(:, is)
452 hm_vxc(:) = hm%vxc(:, is)
453 hm_vh(:) = hm%vhartree(:)
455 geh =
dmf_integrate(mesh, st_rho(1:mesh%np)*hm%vhartree(1:mesh%np))
456 gexc =
dmf_integrate(mesh, st_rho(1:mesh%np)*hm_vxc(1:mesh%np))
468 st%rho(:, is) = st_rho
473 call v_ks_calc(ks, namespace, space, hm, st, ions, ext_partners, &
474 calc_eigenval = .false. , calc_energy = .false.)
475 tmp_rhoi(1:mesh%np) = st%rho(1:mesh%np, is)
506 st%rho(:,is) = st_rho(:)
507 hm%vxc(:,is) = hm_vxc(:)
508 hm%vhartree(:) = hm_vh(:)
514 safe_deallocate_a(hm_vh)
515 safe_deallocate_a(hm_vxc)
516 safe_deallocate_a(st_rho)
517 safe_deallocate_a(tmp_rhoi)
523 subroutine local_write_multipole(out_multip, namespace, lab, ions_mask, mesh_mask, mesh, ions, st, lmax, kick, iter, l_start, &
527 character(len=15),
intent(in) :: lab
528 logical,
intent(in) :: ions_mask(:)
529 logical,
intent(in) :: mesh_mask(:)
530 class(
mesh_t),
intent(in) :: mesh
531 type(
ions_t),
intent(in) :: ions
533 integer,
intent(in) :: lmax
534 type(
kick_t),
intent(in) :: kick
535 integer,
intent(in) :: iter
536 integer,
intent(in) :: l_start
537 logical,
intent(in) :: start
538 integer(int64),
intent(in) :: how
540 integer :: is, ll, mm, add_lm
541 character(len=120) :: aux
542 real(real64) :: ionic_dipole(ions%space%dim), center(mesh%box%dim)
543 real(real64),
allocatable :: multipole(:,:)
544 logical :: use_ionic_dipole
551 write(aux,
'(a15,i2)')
'# nspin ', st%d%nspin
555 write(aux,
'(a15,i2)')
'# lmax ', lmax
559 call kick_write(kick, out = out_multip%handle)
563 do is = 1, st%d%nspin
564 write(aux,
'(a18,i1,a1)')
'Electronic charge(', is,
')'
567 write(aux,
'(a3,a1,i1,a1)')
'<x>',
'(', is,
')'
569 write(aux,
'(a3,a1,i1,a1)')
'<y>',
'(', is,
')'
571 write(aux,
'(a3,a1,i1,a1)')
'<z>',
'(', is,
')'
576 write(aux,
'(a2,i2,a4,i2,a2,i1,a1)')
'l=', ll,
', m=', mm,
' (', is,
')'
587 do is = 1, st%d%nspin
608 center(1:ions%space%dim) = ions%center_of_mass(mask=ions_mask)
610 safe_allocate(multipole(1:(lmax + 1)**2, 1:st%d%nspin))
613 do is = 1, st%d%nspin
614 call dmf_multipoles(mesh, st%rho(:,is), lmax, multipole(:,is), mask=mesh_mask)
617 do is = 1, st%d%nspin
618 multipole(2:mesh%box%dim+1, is) = multipole(2:mesh%box%dim+1, is) - center(1:mesh%box%dim)*multipole(1, is)
632 if (use_ionic_dipole)
then
634 ionic_dipole(1:ions%space%dim) = ions%dipole(mask=ions_mask) + &
635 p_proton_charge*ions%val_charge(mask=ions_mask)*center(1:ions%space%dim)
637 do is = 1, st%d%nspin
638 multipole(2:ions%space%dim+1, is) = -ionic_dipole(1:ions%space%dim)/st%d%nspin - multipole(2:ions%space%dim+1, is)
645 do is = 1, st%d%nspin
659 assert(mesh%box%dim == 3)
665 safe_deallocate_a(multipole)
673 real(real64),
intent(in) :: multipoles(:)
674 real(real64),
intent(in) :: center(:)
675 character(15),
intent(in) :: label
676 integer,
intent(in) :: iter
678 integer :: ll, out_bld
679 character(len=80) :: filename, folder
680 real(real64) :: dipolearrow(3,2)
684 write(folder,
'(a,a)')
'local.general/multipoles/',trim(label)
686 write(filename,
'(a,a,a,a,i7.7,a)')trim(folder),
'/',trim(label),
'.',iter,
'.bld'
687 out_bld =
io_open(trim(filename), namespace, action=
'write')
689 write(out_bld,
'(a,a,a,i7)')
'.comment ** Arrow for the dipole moment centered at the center of mass for ', &
690 trim(label),
' domain and iteration number: ',iter
691 write(out_bld,
'(a)')
''
692 write(out_bld,
'(a)')
'.color red'
698 write(out_bld,
'(a,6(f12.6,2x),a)')
'.arrow ',(dipolearrow(ll,1), ll= 1, 3), &
699 (dipolearrow(ll,2), ll= 1, 3),
' 0.1 0.5 0.90'
707 type(c_ptr),
intent(inout) :: out
711 call write_iter_string(out,
'################################################################################')
722 type(c_ptr),
intent(inout) :: out
726 call write_iter_string(out,
'################################################################################')
Sets the iteration number to the C object.
Writes to the corresponding file and adds one to the iteration. Must be called after write_iter_init(...
real(real64), parameter, public m_two
real(real64), parameter, public p_proton_charge
real(real64), parameter, public m_zero
This module defines classes and functions for interaction partners.
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_close(iunit, grp)
character(len=max_path_len) function, public io_workpath(path, namespace)
subroutine, public io_mkdir(fname, namespace, parents)
integer function, public io_open(file, namespace, action, status, form, position, die, recl, grp)
subroutine, public kick_write(kick, iunit, out)
integer, parameter local_out_potential
subroutine local_write_print_header_init(out)
subroutine, public local_write_init(writ, namespace, lab, iter, dt)
subroutine, public local_write_end(writ)
integer, parameter local_out_energy
logical function, public local_write_check_hm(writ)
subroutine local_write_print_header_end(out)
integer, parameter local_out_density
integer, parameter local_out_max
subroutine local_write_density(out_dens, namespace, space, out_pot, lab, mesh_mask, mesh, ions, ext_partners, st, hm, ks, iter, how)
subroutine out_bld_multipoles(namespace, multipoles, center, label, iter)
subroutine local_write_multipole(out_multip, namespace, lab, ions_mask, mesh_mask, mesh, ions, st, lmax, kick, iter, l_start, start, how)
subroutine local_write_energy(out_energy, namespace, space, lab, mesh_mask, mesh, ions, ext_partners, st, hm, ks, iter, l_start, start)
subroutine, public local_write_iter(writ, namespace, space, lab, ions_mask, mesh_mask, mesh, st, hm, ks, ions, ext_partners, kick, iter, l_start, ldoverwrite)
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.
real(real64) function, public dmf_integrate(mesh, ff, mask, reduce)
Integrate a function on the mesh.
This module defines the meshes, which are used in Octopus.
subroutine, public messages_obsolete_variable(namespace, name, rep)
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_input_error(namespace, var, details, row, column)
logical function mpi_grp_is_root(grp)
Is the current MPI process of grpcomm, root.
type(mpi_grp_t), public mpi_world
subroutine, public dpoisson_solve(this, namespace, pot, rho, all_nodes, kernel)
Calculates the Poisson equation. Given the density returns the corresponding potential.
subroutine, public profiling_out(label)
Increment out counter and sum up difference between entry and exit time.
subroutine, public profiling_in(label, exclude)
Increment in counter and save entry time.
brief This module defines the class unit_t which is used by the unit_systems_oct_m module.
character(len=20) pure function, public units_abbrev(this)
This module defines the unit system, used for input and output.
type(unit_system_t), public units_out
subroutine, public v_ks_calc(ks, namespace, space, hm, st, ions, ext_partners, calc_eigenval, time, calc_energy, calc_current, force_semilocal)
Explicit interfaces to C functions, defined in write_iter_low.cc.
Extension of space that contains the knowledge of the spin dimension.
Describes mesh distribution to nodes.
The states_elec_t class contains all electronic wave functions.