7 use,
intrinsic :: iso_fortran_env
45 class(mesh_t),
intent(in ) :: mesh
46 real(real64),
intent(in ) :: positions(:, :)
47 integer(int64),
intent(out) :: indices(:)
50 integer :: n_centroids, ic
51 integer :: ix(size(positions, 1))
52 real(real64) :: chi(size(positions, 1))
56 if (mesh%parallel_in_domains)
then
57 message(1) =
"map_centroid_positions_to_indices is not domain-parallel"
61 n_centroids =
size(positions, 2)
62 assert(
size(indices) == n_centroids)
64 do ic = 1, n_centroids
65 chi = mesh%coord_system%from_cartesian(positions(:, ic))
66 ix = nint(chi / mesh%spacing)
79 type(namespace_t),
intent(in) :: namespace
81 type(electrons_t),
pointer :: sys
83 real(real64),
parameter :: LMM_R_SINGLE_ATOM = 100.0_real64
86 integer :: n_duplicates
88 integer(int64) :: rng_seed
89 integer(int64),
allocatable :: indices(:), unique_indices(:)
90 real(real64),
allocatable :: centroid_positions(:, :)
91 character(len=1),
allocatable :: dummy_species(:)
94 type(isdf_options_t) :: isdf_options
95 logical :: output_cubes
96 real(real64),
allocatable :: phi(:, :)
97 real(real64),
allocatable :: isdf_vectors(:, :)
117 call lcao_run(namespace, sys%space, sys%gr, sys%ions, sys%ext_partners, &
118 sys%st, sys%ks, sys%hm, lmm_r = lmm_r_single_atom)
120 call isdf_options%init(namespace, sys%st)
123 rng_seed = int(101, int64)
124 safe_allocate(centroid_positions(1:sys%space%dim, 1:isdf_options%n_interp))
128 allocate(dummy_species(isdf_options%n_interp), source=
'A')
133 call weighted_kmeans(sys%space, sys%gr, sys%st%rho(1:sys%gr%np, 1), centroid_positions)
141 safe_allocate(indices(1:isdf_options%n_interp))
146 open(newunit=unit, file=
"centroid_indices.dat")
147 write(unit, *)
'N centroids', isdf_options%n_interp
148 do i = 1, isdf_options%n_interp
149 write(unit, *) indices(i)
158 allocate(unique_indices(isdf_options%n_interp))
162 unique_indices(1) = indices(1)
163 do i = 1, isdf_options%n_interp - 1
164 if (indices(i) == indices(i+1))
then
165 n_duplicates = n_duplicates + 1
169 unique_indices(cnt) = indices(i+1)
171 safe_deallocate_a(indices)
172 allocate(indices(cnt), source=unique_indices(1:cnt))
173 deallocate(unique_indices)
175 if (n_duplicates > 0)
then
176 write(
message(1),
'(I0)') n_duplicates
177 message(1) = trim(
message(1)) //
" duplicates found after discretisation of centroid positions"
179 message(2) =
" Removed the duplicate/s and resized 'indices' array to " // trim(
message(2))
185 if (.not. sys%st%parallel_in_states .and. .not. sys%gr%parallel_in_domains)
then
189 sys%gr, sys%st, indices, phi, isdf_vectors)
192 output_cubes = .false.
196 sys%ions, phi, indices, isdf_vectors, output_cubes)
200 safe_deallocate_p(sys)
201 safe_deallocate_a(indices)
This is the common interface to a sorting routine. It performs the shell algorithm,...
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
type(debug_t), save, public debug
character(len= *), parameter, public static_dir
subroutine, public write_standard_xyz_file(namespace, fname, pos, species, header)
Write a standard xyz file with atom labels and positions (in Angstrom).
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)
Serial prototype for benchmarking and validating ISDF implementation.
subroutine, public serial_interpolative_separable_density_fitting_vectors(namespace, mesh, st, int_indices, phi, isdf_vectors)
Compute a set of ISDF interpolation vectors in serial, for code validation.
subroutine, public quantify_error_and_visualise(namespace, st, space, mesh, ions, phi, indices, isdf_vectors, output_cubes)
Wrapper for quantifying the error in the expansion of the product basis.
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)
This module defines the meshes, which are used in Octopus.
integer(int64) function, public mesh_global_index_from_coords(mesh, ix)
This function returns the true global index of the point for a given vector of integer coordinates.
subroutine, public messages_warning(no_lines, all_nodes, namespace)
subroutine, public messages_new_line()
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)
type(mpi_grp_t), public mpi_world
This module is intended to contain "only mathematical" functions and procedures.
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.
Integration tests for ISDF.
subroutine, public test_isdf(namespace)
Set up an electron system, compute some optimal centroid positions, and use these to build a set of I...
subroutine map_centroid_positions_to_indices(mesh, positions, indices)
Helper function: Map centroid positions to indices.
type(type_t), public type_float
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.