22 use,
intrinsic :: iso_fortran_env
47 subroutine write_xyz(namespace, fname, position, species)
48 type(namespace_t),
intent(in) :: namespace
49 character(len=*),
intent(in) :: fname
50 real(real64),
intent(in) :: position(:, :)
51 character(len=*),
intent(in) :: species(:)
53 integer :: iunit, iatom
55 iunit =
io_open(trim(fname)//
'.xyz', namespace, action=
'write', position=
'asis')
58 write(iunit,
'(i6)')
size(position, 2)
61 do iatom = 1,
size(position, 2)
62 write(iunit,
'(A, 1X, 3(F11.6, 1X))') trim(species(iatom)), position(:, iatom) /
unit_angstrom%factor
75 type(namespace_t),
intent(in) :: namespace
77 type(electrons_t),
pointer :: sys
81 integer :: n_centroids
82 real(real64) :: inertia
83 integer(int64),
allocatable :: seeds(:)
84 real(real64),
allocatable :: centroids(:, :)
85 character(len=1),
allocatable :: dummy_species(:)
97 call lcao_run(namespace, sys%space, sys%gr, sys%ions, sys%ext_partners, &
105 sys%st%rho(:, 1),
unit_one, ierr, pos=sys%ions%pos, atoms=sys%ions%atom)
110 allocate(dummy_species(n_centroids), source=
'A')
112 allocate(seeds(1), source=int(101, int64))
113 safe_allocate(centroids(1:sys%space%dim, 1:n_centroids))
118 call weighted_kmeans(sys%space, sys%gr, sys%st%rho(1:sys%gr%np, 1), centroids, inertia=inertia)
119 write(
message(1),
'(a, f18.12)')
"test_weighted_kmeans: inertia", inertia
127 deallocate(dummy_species)
128 safe_deallocate_a(centroids)
130 safe_deallocate_p(sys)
This module handles the calculation mode.
type(calc_mode_par_t), public calc_mode_par
Singleton instance of parallel calculation mode.
integer, parameter, public p_strategy_states
parallelization in states
real(real64), parameter, public lmm_r_single_atom
Default local magnetic moments sphere radius for an isolated system.
character(len= *), parameter, public static_dir
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)
subroutine, public io_mkdir(fname, namespace, parents)
integer function, public io_open(file, namespace, action, status, form, position, die, recl, grp)
subroutine, public weighted_kmeans(space, mesh, weight, centroids, n_iter, centroid_tol, discretize, inertia)
Weighted K-means clustering.
subroutine, public sample_initial_centroids(mesh, centroids, seed_value)
Sample initial centroids from the full mesh.
subroutine, public lcao_run(namespace, space, gr, ions, ext_partners, st, ks, hm, st_start, lmm_r)
character(len=256), dimension(max_lines), public message
to be output by fatal, warning
subroutine, public messages_info(no_lines, iunit, debug_only, stress, all_nodes, namespace)
type(mpi_grp_t), public mpi_world
subroutine, public states_elec_deallocate_wfns(st)
Deallocates the KS wavefunctions defined within a states_elec_t structure.
subroutine, public states_elec_allocate_wfns(st, mesh, wfs_type, skip, packed)
Allocates the KS wavefunctions defined within a states_elec_t structure.
subroutine write_xyz(namespace, fname, position, species)
Simplified xyz output for finite systems.
subroutine, public test_weighted_kmeans(namespace)
Test weighted kmeans algorithm for a finite system.
This module defines the unit system, used for input and output.
type(unit_t), public unit_angstrom
For XYZ files.
type(unit_t), public unit_one
some special units required for particular quantities
Class describing the electron system.