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)'
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)
311 tmp_rho = st_rho(1:mesh%np)
314 if (out_dens%write)
then
315 folder =
'local.general/densities/'//trim(lab)//
'.densities/'
316 write(out_name,
'(a,a1,i0,a1,i7.7)') trim(lab),
'.', is,
'.', iter
317 call dio_function_output(how, trim(folder), trim(out_name), namespace, space, mesh, tmp_rho(1:mesh%np), &
318 units_out%length, ierr, pos=ions%pos, atoms=ions%atom)
321 if (out_pot%write)
then
325 folder =
'local.general/potential/'//trim(lab)//
'.potential/'
326 write(out_name,
'(a,i0,a1,i7.7)')
'vh.', is,
'.', iter
328 pos=ions%pos, atoms=ions%atom)
332 st%rho(1:mesh%np, is) = st_rho(1:mesh%np)
334 call v_ks_calc(ks, namespace, space, hm, st, ions, ext_partners, calc_eigenval = .false. , calc_energy = .false.)
335 folder =
'local.general/potential/'//trim(lab)//
'.potential/'
336 write(out_name,
'(a,i0,a1,i7.7)')
'vxc.', is,
'.', iter
338 hm%ks_pot%vxc(:,is),
units_out%length, ierr, pos=ions%pos, atoms=ions%atom)
339 st%rho(:,is) = st_rho(:)
343 if (out_pot%write)
then
344 do is = 1, st%d%nspin
346 call dpoisson_solve(hm%psolver, namespace, hm%ks_pot%vhartree, st%rho(1:mesh%np, is))
347 folder =
'local.general/potential/'
348 write(out_name,
'(a,i0,a1,i7.7)')
'global-vh.', is,
'.', iter
349 call dio_function_output(how, trim(folder), trim(out_name), namespace, space, mesh, hm%ks_pot%vhartree, &
350 units_out%length, ierr, pos=ions%pos, atoms=ions%atom)
352 call v_ks_calc(ks, namespace, space, hm, st, ions, ext_partners, calc_eigenval = .false. , calc_energy = .false.)
353 folder =
'local.general/potential/'
354 write(out_name,
'(a,i0,a1,i7.7)')
'global-vxc.', is,
'.', iter
355 call dio_function_output(how, trim(folder), trim(out_name), namespace, space, mesh, hm%ks_pot%vxc(:,is), &
356 units_out%length, ierr, pos=ions%pos, atoms=ions%atom)
360 safe_deallocate_a(tmp_vh)
361 safe_deallocate_a(st_rho)
362 safe_deallocate_a(tmp_rho)
368 subroutine local_write_energy(out_energy, namespace, space, lab, mesh_mask, mesh, ions, ext_partners, &
369 st, hm, ks, iter, l_start, start)
373 character(len=15),
intent(in) :: lab
374 logical,
intent(in) :: mesh_mask(:)
375 class(
mesh_t),
intent(in) :: mesh
376 type(
ions_t),
intent(inout) :: ions
380 type(
v_ks_t),
intent(inout) :: ks
381 integer,
intent(in) :: iter
382 integer,
intent(in) :: l_start
383 logical,
intent(in) :: start
387 character(len=120) :: aux
388 real(real64) :: geh, gexc, leh, lexc
389 real(real64),
allocatable :: tmp_rhoi(:), st_rho(:)
390 real(real64),
allocatable :: hm_vxc(:), hm_vh(:)
394 safe_allocate(tmp_rhoi(1:mesh%np))
395 safe_allocate(st_rho(1:mesh%np_part))
396 safe_allocate(hm_vxc(1:mesh%np))
397 safe_allocate(hm_vh(1:mesh%np_part))
401 if (iter == l_start .and. start)
then
405 write(aux,
'(a,2x,a)')
'# Domain ID:', trim(lab)
407 write(aux,
'(a)') trim(lab)
411 aux =
'Total Hartree'
413 aux =
'Total Int[n*vxc]'
415 write(aux,
'(a)')
'Int[n*vh]'
417 write(aux,
'(a)')
'Int[n*vxc]'
443 do is = 1, st%d%nspin
445 call dpoisson_solve(hm%psolver, namespace, hm%ks_pot%vhartree, st%rho(1:mesh%np, is))
447 call v_ks_calc(ks, namespace, space, hm, st, ions, ext_partners, calc_eigenval = .false. , calc_energy = .false.)
449 st_rho(:) = st%rho(:, is)
450 hm_vxc(:) = hm%ks_pot%vxc(:, is)
451 hm_vh(:) = hm%ks_pot%vhartree(:)
453 geh =
dmf_integrate(mesh, st_rho(1:mesh%np)*hm_vh(1:mesh%np))
454 gexc =
dmf_integrate(mesh, st_rho(1:mesh%np)*hm_vxc(1:mesh%np))
464 hm%ks_pot%vhartree(:) =
m_zero
467 st%rho(1:mesh%np, is) = st_rho(1:mesh%np)
470 call v_ks_calc(ks, namespace, space, hm, st, ions, ext_partners, &
471 calc_eigenval = .false. , calc_energy = .false.)
472 tmp_rhoi(1:mesh%np) = st%rho(1:mesh%np, is)
474 leh =
dmf_integrate(mesh, tmp_rhoi*hm%ks_pot%vhartree(1:mesh%np))
476 lexc =
dmf_integrate(mesh, tmp_rhoi*hm%ks_pot%vxc(1:mesh%np,is))
503 st%rho(:,is) = st_rho(:)
504 hm%ks_pot%vxc(:,is) = hm_vxc(:)
505 hm%ks_pot%vhartree(:) = hm_vh(:)
511 safe_deallocate_a(hm_vh)
512 safe_deallocate_a(hm_vxc)
513 safe_deallocate_a(st_rho)
514 safe_deallocate_a(tmp_rhoi)
520 subroutine local_write_multipole(out_multip, namespace, lab, ions_mask, mesh_mask, mesh, ions, st, lmax, kick, iter, l_start, &
524 character(len=15),
intent(in) :: lab
525 logical,
intent(in) :: ions_mask(:)
526 logical,
intent(in) :: mesh_mask(:)
527 class(
mesh_t),
intent(in) :: mesh
528 type(
ions_t),
intent(in) :: ions
530 integer,
intent(in) :: lmax
531 type(
kick_t),
intent(in) :: kick
532 integer,
intent(in) :: iter
533 integer,
intent(in) :: l_start
534 logical,
intent(in) :: start
535 integer(int64),
intent(in) :: how
537 integer :: is, ll, mm, add_lm
538 character(len=120) :: aux
539 real(real64) :: ionic_dipole(ions%space%dim), center(mesh%box%dim)
540 real(real64),
allocatable :: multipole(:,:)
541 logical :: use_ionic_dipole
545 if (
mpi_world%is_root().and. iter == l_start .and. start)
then
548 write(aux,
'(a15,i2)')
'# nspin ', st%d%nspin
552 write(aux,
'(a15,i2)')
'# lmax ', lmax
556 call kick_write(kick, out = out_multip%handle)
560 do is = 1, st%d%nspin
561 write(aux,
'(a18,i1,a1)')
'Electronic charge(', is,
')'
564 write(aux,
'(a3,a1,i1,a1)')
'<x>',
'(', is,
')'
566 write(aux,
'(a3,a1,i1,a1)')
'<y>',
'(', is,
')'
568 write(aux,
'(a3,a1,i1,a1)')
'<z>',
'(', is,
')'
573 write(aux,
'(a2,i2,a4,i2,a2,i1,a1)')
'l=', ll,
', m=', mm,
' (', is,
')'
584 do is = 1, st%d%nspin
605 center(1:ions%space%dim) = ions%center_of_mass(mask=ions_mask)
607 safe_allocate(multipole(1:(lmax + 1)**2, 1:st%d%nspin))
610 do is = 1, st%d%nspin
611 call dmf_multipoles(mesh, st%rho(:,is), lmax, multipole(:,is), mask=mesh_mask)
614 do is = 1, st%d%nspin
615 multipole(2:mesh%box%dim+1, is) = multipole(2:mesh%box%dim+1, is) - center(1:mesh%box%dim)*multipole(1, is)
629 if (use_ionic_dipole)
then
631 ionic_dipole(1:ions%space%dim) = ions%dipole(mask=ions_mask) + &
632 p_proton_charge*ions%val_charge(mask=ions_mask)*center(1:ions%space%dim)
634 do is = 1, st%d%nspin
635 multipole(2:ions%space%dim+1, is) = -ionic_dipole(1:ions%space%dim)/st%d%nspin - multipole(2:ions%space%dim+1, is)
642 do is = 1, st%d%nspin
655 if (
bitand(how, option__outputformat__bild) /= 0 .and.
mpi_world%is_root())
then
656 assert(mesh%box%dim == 3)
662 safe_deallocate_a(multipole)
670 real(real64),
intent(in) :: multipoles(:)
671 real(real64),
intent(in) :: center(:)
672 character(15),
intent(in) :: label
673 integer,
intent(in) :: iter
675 integer :: ll, out_bld
676 character(len=80) :: filename, folder
677 real(real64) :: dipolearrow(3,2)
681 write(folder,
'(a,a)')
'local.general/multipoles/',trim(label)
683 write(filename,
'(a,a,a,a,i7.7,a)')trim(folder),
'/',trim(label),
'.',iter,
'.bld'
684 out_bld =
io_open(trim(filename), namespace, action=
'write')
686 write(out_bld,
'(a,a,a,i7)')
'.comment ** Arrow for the dipole moment centered at the center of mass for ', &
687 trim(label),
' domain and iteration number: ',iter
688 write(out_bld,
'(a)')
''
689 write(out_bld,
'(a)')
'.color red'
695 write(out_bld,
'(a,6(f12.6,2x),a)')
'.arrow ',(dipolearrow(ll,1), ll= 1, 3), &
696 (dipolearrow(ll,2), ll= 1, 3),
' 0.1 0.5 0.90'
704 type(c_ptr),
intent(inout) :: out
708 call write_iter_string(out,
'################################################################################')
719 type(c_ptr),
intent(inout) :: out
723 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)
construct path name from given name and 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.
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)
type(mpi_grp_t), public mpi_world
subroutine, public dpoisson_solve(this, namespace, pot, rho, all_nodes, kernel, reset)
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.
subroutine, public write_iter_header(out, string)
subroutine, public write_iter_string(out, string)
subroutine, public write_iter_init(out, iter, factor, file)
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.