(git:f2099e5)
Loading...
Searching...
No Matches
pao_model.F
Go to the documentation of this file.
1!--------------------------------------------------------------------------------------------------!
2! CP2K: A general program to perform molecular dynamics simulations !
3! Copyright 2000-2026 CP2K developers group <https://cp2k.org> !
4! !
5! SPDX-License-Identifier: GPL-2.0-or-later !
6!--------------------------------------------------------------------------------------------------!
7
8! **************************************************************************************************
9!> \brief Module for equivariant PAO-ML based on PyTorch.
10!> \author Ole Schuett
11! **************************************************************************************************
13 USE omp_lib, ONLY: omp_init_lock,&
14 omp_set_lock,&
15 omp_unset_lock
19 USE cell_types, ONLY: cell_type
20 USE cp_dbcsr_api, ONLY: dbcsr_get_info,&
27 USE kinds, ONLY: default_path_length,&
29 dp,&
30 int_8,&
31 sp
33 USE pao_types, ONLY: pao_env_type,&
36 USE physcon, ONLY: angstrom
39 USE qs_kind_types, ONLY: get_qs_kind,&
41 USE torch_api, ONLY: &
46#include "./base/base_uses.f90"
47
48 IMPLICIT NONE
49
50 PRIVATE
51
53
54CONTAINS
55
56! **************************************************************************************************
57!> \brief Loads a PAO-ML model.
58!> \param pao ...
59!> \param qs_env ...
60!> \param ikind ...
61!> \param pao_model_file ...
62!> \param model ...
63! **************************************************************************************************
64 SUBROUTINE pao_model_load(pao, qs_env, ikind, pao_model_file, model)
65 TYPE(pao_env_type), INTENT(IN) :: pao
66 TYPE(qs_environment_type), INTENT(IN) :: qs_env
67 INTEGER, INTENT(IN) :: ikind
68 CHARACTER(LEN=default_path_length), INTENT(IN) :: pao_model_file
69 TYPE(pao_model_type), INTENT(OUT) :: model
70
71 CHARACTER(len=*), PARAMETER :: routinen = 'pao_model_load'
72
73 CHARACTER(LEN=default_string_length) :: kind_name
74 CHARACTER(LEN=default_string_length), &
75 ALLOCATABLE, DIMENSION(:) :: model_kind_names
76 INTEGER :: handle, jkind, kkind, pao_basis_size, z
77 REAL(dp) :: cutoff_angstrom
78 TYPE(atomic_kind_type), DIMENSION(:), POINTER :: atomic_kind_set
79 TYPE(gto_basis_set_type), POINTER :: basis_set
80 TYPE(qs_kind_type), DIMENSION(:), POINTER :: qs_kind_set
81
82 CALL timeset(routinen, handle)
83 CALL get_qs_env(qs_env, qs_kind_set=qs_kind_set, atomic_kind_set=atomic_kind_set)
84
85 IF (pao%iw > 0) WRITE (pao%iw, '(A)') " PAO| Loading PyTorch model from: "//trim(pao_model_file)
86 CALL torch_model_load(model%torch_model, pao_model_file)
87 CALL torch_model_remap_device_constants(model%torch_model)
88
89 ! Read model attributes.
90 CALL torch_model_get_attr(model%torch_model, "pao_model_version", model%version)
91 CALL torch_model_get_attr(model%torch_model, "kind_name", model%kind_name)
92 CALL torch_model_get_attr(model%torch_model, "atomic_number", model%atomic_number)
93 CALL torch_model_get_attr(model%torch_model, "prim_basis_name", model%prim_basis_name)
94 CALL torch_model_get_attr(model%torch_model, "prim_basis_size", model%prim_basis_size)
95 CALL torch_model_get_attr(model%torch_model, "pao_basis_size", model%pao_basis_size)
96 CALL torch_model_get_attr(model%torch_model, "num_layers", model%num_layers)
97 CALL torch_model_get_attr(model%torch_model, "cutoff", cutoff_angstrom)
98 CALL torch_model_get_attr(model%torch_model, "all_kind_names", model_kind_names)
99 model%cutoff = cutoff_angstrom/angstrom
100
101 ! Freeze model after all attributes have been read.
102 ! TODO Re-enable once the memory leaks of torch::jit::freeze() are fixed.
103 ! https://github.com/pytorch/pytorch/issues/96726
104 ! CALL torch_model_freeze(model%torch_model)
105
106 ! For each of the model's kind names lookup the corresponding atomic kind index.
107 ALLOCATE (model%kinds_mapping(SIZE(atomic_kind_set)))
108 model%kinds_mapping(:) = -1
109 DO jkind = 1, SIZE(atomic_kind_set)
110 DO kkind = 1, SIZE(model_kind_names)
111 IF (trim(atomic_kind_set(jkind)%name) == trim(model_kind_names(kkind))) THEN
112 model%kinds_mapping(jkind) = kkind - 1
113 EXIT
114 END IF
115 END DO
116 IF (model%kinds_mapping(jkind) < 0) THEN
117 CALL cp_abort(__location__, "PAO-ML model lacks kind '"//trim(atomic_kind_set(jkind)%name)//"' .")
118 END IF
119 END DO
120
121 ! Check compatibility
122 CALL get_qs_kind(qs_kind_set(ikind), basis_set=basis_set, pao_basis_size=pao_basis_size)
123 CALL get_atomic_kind(atomic_kind_set(ikind), name=kind_name, z=z)
124 IF (model%version /= 2) THEN
125 cpabort("Model version not supported.")
126 END IF
127 IF (trim(model%kind_name) /= trim(kind_name)) THEN
128 cpabort("Kind name does not match.")
129 END IF
130 IF (model%atomic_number /= z) THEN
131 cpabort("Atomic number does not match.")
132 END IF
133 IF (trim(model%prim_basis_name) /= trim(basis_set%name)) THEN
134 cpabort("Primary basis set name does not match.")
135 END IF
136 IF (model%prim_basis_size /= basis_set%nsgf) THEN
137 cpabort("Primary basis set size does not match.")
138 END IF
139 IF (model%pao_basis_size /= pao_basis_size) THEN
140 cpabort("PAO basis size does not match.")
141 END IF
142
143 CALL omp_init_lock(model%lock)
144 CALL timestop(handle)
145
146 END SUBROUTINE pao_model_load
147
148! **************************************************************************************************
149!> \brief Fills pao%matrix_X based on machine learning predictions
150!> \param pao ...
151!> \param qs_env ...
152! **************************************************************************************************
153 SUBROUTINE pao_model_predict(pao, qs_env)
154 TYPE(pao_env_type), POINTER :: pao
155 TYPE(qs_environment_type), POINTER :: qs_env
156
157 CHARACTER(len=*), PARAMETER :: routinen = 'pao_model_predict'
158
159 INTEGER :: acol, arow, handle, iatom
160 REAL(dp), DIMENSION(:, :), POINTER :: block_x
161 TYPE(dbcsr_iterator_type) :: iter
162
163 CALL timeset(routinen, handle)
164
165!$OMP PARALLEL DEFAULT(NONE) SHARED(pao,qs_env) PRIVATE(iter,arow,acol,iatom,block_X)
166 CALL dbcsr_iterator_start(iter, pao%matrix_X)
167 DO WHILE (dbcsr_iterator_blocks_left(iter))
168 CALL dbcsr_iterator_next_block(iter, arow, acol, block_x)
169 IF (SIZE(block_x) == 0) cycle ! pao disabled for iatom
170 iatom = arow; cpassert(arow == acol)
171 CALL predict_single_atom(pao, qs_env, iatom, block_x=block_x)
172 END DO
173 CALL dbcsr_iterator_stop(iter)
174!$OMP END PARALLEL
175
176 CALL timestop(handle)
177
178 END SUBROUTINE pao_model_predict
179
180! **************************************************************************************************
181!> \brief Calculate forces contributed by machine learning
182!> \param pao ...
183!> \param qs_env ...
184!> \param matrix_G ...
185!> \param forces ...
186! **************************************************************************************************
187 SUBROUTINE pao_model_forces(pao, qs_env, matrix_G, forces)
188 TYPE(pao_env_type), POINTER :: pao
189 TYPE(qs_environment_type), POINTER :: qs_env
190 TYPE(dbcsr_type) :: matrix_g
191 REAL(dp), DIMENSION(:, :), INTENT(INOUT) :: forces
192
193 CHARACTER(len=*), PARAMETER :: routinen = 'pao_model_forces'
194
195 INTEGER :: acol, arow, handle, iatom
196 REAL(dp), DIMENSION(:, :), POINTER :: block_g
197 TYPE(dbcsr_iterator_type) :: iter
198
199 CALL timeset(routinen, handle)
200
201!$OMP PARALLEL DEFAULT(NONE) SHARED(pao,qs_env,matrix_G,forces) PRIVATE(iter,arow,acol,iatom,block_G)
202 CALL dbcsr_iterator_start(iter, matrix_g)
203 DO WHILE (dbcsr_iterator_blocks_left(iter))
204 CALL dbcsr_iterator_next_block(iter, arow, acol, block_g)
205 iatom = arow; cpassert(arow == acol)
206 IF (SIZE(block_g) == 0) cycle ! pao disabled for iatom
207 CALL predict_single_atom(pao, qs_env, iatom, block_g=block_g, forces=forces)
208 END DO
209 CALL dbcsr_iterator_stop(iter)
210!$OMP END PARALLEL
211
212 CALL timestop(handle)
213
214 END SUBROUTINE pao_model_forces
215
216! **************************************************************************************************
217!> \brief Predicts a single block_X.
218!> \param pao ...
219!> \param qs_env ...
220!> \param iatom ...
221!> \param block_X ...
222!> \param block_G ...
223!> \param forces ...
224! **************************************************************************************************
225 SUBROUTINE predict_single_atom(pao, qs_env, iatom, block_X, block_G, forces)
226 TYPE(pao_env_type), INTENT(IN), POINTER :: pao
227 TYPE(qs_environment_type), INTENT(IN), POINTER :: qs_env
228 INTEGER, INTENT(IN) :: iatom
229 REAL(dp), DIMENSION(:, :), OPTIONAL :: block_x, block_g, forces
230
231 INTEGER :: i, iedge, ikind, j, jatom, jcell, jkind, &
232 jneighbor, k, katom, kneighbor, m, n, &
233 natoms, num_edges, num_neighbors
234 INTEGER(kind=int_8), ALLOCATABLE, DIMENSION(:) :: neighbor_atom_types
235 INTEGER(kind=int_8), ALLOCATABLE, DIMENSION(:, :) :: central_edge_index, edge_index
236 INTEGER, ALLOCATABLE, DIMENSION(:) :: neighbor_atom_index
237 INTEGER, DIMENSION(:), POINTER :: blk_sizes_pao, blk_sizes_pri
238 REAL(dp), DIMENSION(3) :: ri, rj, rjk
239 REAL(kind=dp), ALLOCATABLE, DIMENSION(:, :) :: cell_shifts, neighbor_pos
240 REAL(sp), ALLOCATABLE, DIMENSION(:, :) :: edge_vectors
241 REAL(sp), ALLOCATABLE, DIMENSION(:, :, :) :: outer_grad
242 REAL(sp), DIMENSION(:, :), POINTER :: edge_vectors_grad
243 REAL(sp), DIMENSION(:, :, :), POINTER :: predicted_xblock
244 TYPE(atomic_kind_type), DIMENSION(:), POINTER :: atomic_kind_set
245 TYPE(cell_type), POINTER :: cell
246 TYPE(mp_para_env_type), POINTER :: para_env
247 TYPE(pao_model_type), POINTER :: model
248 TYPE(particle_type), DIMENSION(:), POINTER :: particle_set
249 TYPE(qs_kind_type), DIMENSION(:), POINTER :: qs_kind_set
250 TYPE(torch_dict_type) :: model_inputs, model_outputs
251 TYPE(torch_tensor_type) :: atom_types_tensor, central_edge_index_tensor, edge_index_tensor, &
252 edge_vectors_grad_tensor, edge_vectors_tensor, outer_grad_tensor, predicted_xblock_tensor
253
254 CALL dbcsr_get_info(pao%matrix_Y, row_blk_size=blk_sizes_pri, col_blk_size=blk_sizes_pao)
255 n = blk_sizes_pri(iatom) ! size of primary basis
256 m = blk_sizes_pao(iatom) ! size of pao basis
257
258 CALL get_qs_env(qs_env, &
259 para_env=para_env, &
260 cell=cell, &
261 particle_set=particle_set, &
262 atomic_kind_set=atomic_kind_set, &
263 qs_kind_set=qs_kind_set, &
264 natom=natoms)
265
266 CALL get_atomic_kind(particle_set(iatom)%atomic_kind, kind_number=ikind)
267 ri = particle_set(iatom)%r
268 model => pao%models(ikind)
269 cpassert(model%version > 0)
270 CALL omp_set_lock(model%lock) ! TODO: might not be needed for inference.
271
272 ! TODO: this is a quadratic algorithm, use a neighbor-list instead.
273
274 ! Enumerate all neighboring images. TODO: should be all images within num_layers*cutoff.
275 ALLOCATE (cell_shifts(27, 3))
276 jcell = 0
277 DO i = -1, +1
278 DO j = -1, +1
279 DO k = -1, +1
280 jcell = jcell + 1
281 cell_shifts(jcell, :) = i*cell%hmat(:, 1) + j*cell%hmat(:, 2) + k*cell%hmat(:, 3)
282 END DO
283 END DO
284 END DO
285
286 ! Find neighbors, ie. atoms that are reachable within num_layers*cutoff.
287 ! 1st pass to count neighbors.
288 num_neighbors = 1 ! first neighbor is always the central atom
289 DO jatom = 1, natoms
290 DO jcell = 1, 27
291 rj = particle_set(jatom)%r + cell_shifts(jcell, :)
292 IF (norm2(rj - ri) < model%num_layers*model%cutoff .AND. any(rj /= ri)) THEN
293 num_neighbors = num_neighbors + 1
294 END IF
295 END DO
296 END DO
297
298 ! 2nd pass to collect neighbors.
299 ALLOCATE (neighbor_pos(num_neighbors, 3), neighbor_atom_types(num_neighbors), neighbor_atom_index(num_neighbors))
300 num_neighbors = 1 ! first neighbor is always the central atom
301 neighbor_pos(1, :) = ri
302 neighbor_atom_types(1) = model%kinds_mapping(ikind)
303 neighbor_atom_index(1) = iatom
304 DO jatom = 1, natoms
305 DO jcell = 1, 27
306 rj = particle_set(jatom)%r + cell_shifts(jcell, :)
307 jkind = particle_set(jatom)%atomic_kind%kind_number
308 IF (norm2(rj - ri) < model%num_layers*model%cutoff .AND. any(rj /= ri)) THEN
309 num_neighbors = num_neighbors + 1
310 neighbor_pos(num_neighbors, :) = rj
311 neighbor_atom_types(num_neighbors) = model%kinds_mapping(jkind)
312 neighbor_atom_index(num_neighbors) = jatom
313 END IF
314 END DO
315 END DO
316
317 ! Build connectivity graph of neighbors.
318 ! 1st pass to count edges.
319 num_edges = 0
320 DO jneighbor = 1, num_neighbors
321 DO kneighbor = 1, num_neighbors
322 rjk = neighbor_pos(kneighbor, :) - neighbor_pos(jneighbor, :)
323 IF (norm2(rjk) < model%cutoff .AND. jneighbor /= kneighbor) THEN
324 num_edges = num_edges + 1
325 END IF
326 END DO
327 END DO
328
329 ! 2nd pass to collect edges.
330 ALLOCATE (edge_index(num_edges, 2), edge_vectors(3, num_edges)) ! edge_index is transposed
331 num_edges = 0
332 DO jneighbor = 1, num_neighbors
333 DO kneighbor = 1, num_neighbors
334 rjk = neighbor_pos(kneighbor, :) - neighbor_pos(jneighbor, :)
335 IF (norm2(rjk) < model%cutoff .AND. jneighbor /= kneighbor) THEN
336 num_edges = num_edges + 1
337 edge_index(num_edges, :) = [jneighbor - 1, kneighbor - 1]
338 edge_vectors(:, num_edges) = real(rjk*angstrom, kind=sp)
339 END IF
340 END DO
341 END DO
342
343 ALLOCATE (central_edge_index(1, 2))
344 central_edge_index(:, :) = 0
345
346 ! Inference.
347 CALL torch_dict_create(model_inputs)
348
349 CALL torch_tensor_from_array(atom_types_tensor, neighbor_atom_types)
350 CALL torch_dict_insert(model_inputs, "atom_types", atom_types_tensor)
351
352 CALL torch_tensor_from_array(edge_index_tensor, edge_index)
353 CALL torch_dict_insert(model_inputs, "edge_index", edge_index_tensor)
354
355 CALL torch_tensor_from_array(edge_vectors_tensor, edge_vectors, requires_grad=PRESENT(block_g))
356 CALL torch_dict_insert(model_inputs, "edge_vectors", edge_vectors_tensor)
357
358 CALL torch_tensor_from_array(central_edge_index_tensor, central_edge_index)
359 CALL torch_dict_insert(model_inputs, "central_edge_index", central_edge_index_tensor)
360
361 CALL torch_dict_create(model_outputs)
362 CALL torch_model_forward(model%torch_model, model_inputs, model_outputs)
363
364 ! Copy predicted XBlock.
365 NULLIFY (predicted_xblock)
366 CALL torch_dict_get(model_outputs, "xblock", predicted_xblock_tensor)
367 CALL torch_tensor_data_ptr(predicted_xblock_tensor, predicted_xblock)
368 cpassert(SIZE(predicted_xblock, 1) == n)
369 cpassert(SIZE(predicted_xblock, 2) == m)
370 cpassert(SIZE(predicted_xblock, 3) == 1)
371 cpassert(all(predicted_xblock == predicted_xblock)) ! checking for NaNs
372 IF (PRESENT(block_x)) THEN
373 block_x = reshape(predicted_xblock, [n*m, 1])
374 END IF
375
376 ! TURNING POINT (if calc forces) ------------------------------------------
377 IF (PRESENT(block_g)) THEN
378 ALLOCATE (outer_grad(n, m, 1))
379 outer_grad(:, :, :) = real(reshape(block_g, [n, m, 1]), kind=sp)
380 CALL torch_tensor_from_array(outer_grad_tensor, outer_grad)
381 CALL torch_tensor_backward(predicted_xblock_tensor, outer_grad_tensor)
382 CALL torch_tensor_grad(edge_vectors_tensor, edge_vectors_grad_tensor)
383 NULLIFY (edge_vectors_grad)
384 CALL torch_tensor_data_ptr(edge_vectors_grad_tensor, edge_vectors_grad)
385 IF (ASSOCIATED(edge_vectors_grad)) THEN ! Torch may return NULL pointer as gradient.
386 cpassert(SIZE(edge_vectors_grad, 1) == 3 .AND. SIZE(edge_vectors_grad, 2) == num_edges)
387 cpassert(all(edge_vectors_grad == edge_vectors_grad)) ! checking for NaNs
388 DO iedge = 1, num_edges
389 jneighbor = int(edge_index(iedge, 1) + 1)
390 kneighbor = int(edge_index(iedge, 2) + 1)
391 jatom = neighbor_atom_index(jneighbor)
392 katom = neighbor_atom_index(kneighbor)
393 forces(jatom, :) = forces(jatom, :) + edge_vectors_grad(:, iedge)*angstrom
394 forces(katom, :) = forces(katom, :) - edge_vectors_grad(:, iedge)*angstrom
395 END DO
396 END IF
397 CALL torch_tensor_release(outer_grad_tensor)
398 CALL torch_tensor_release(edge_vectors_grad_tensor)
399 END IF
400
401 ! Clean up.
402 CALL torch_tensor_release(atom_types_tensor)
403 CALL torch_tensor_release(edge_index_tensor)
404 CALL torch_tensor_release(edge_vectors_tensor)
405 CALL torch_tensor_release(central_edge_index_tensor)
406 CALL torch_tensor_release(predicted_xblock_tensor)
407 CALL torch_dict_release(model_inputs)
408 CALL torch_dict_release(model_outputs)
409 CALL omp_unset_lock(model%lock)
410
411 END SUBROUTINE predict_single_atom
412
413END MODULE pao_model
Define the atomic kind types and their sub types.
subroutine, public get_atomic_kind(atomic_kind, fist_potential, element_symbol, name, mass, kind_number, natom, atom_list, rcov, rvdw, z, qeff, apol, cpol, mm_radius, shell, shell_active, damping)
Get attributes of an atomic kind.
Handles all functions related to the CELL.
Definition cell_types.F:15
logical function, public dbcsr_iterator_blocks_left(iterator)
...
subroutine, public dbcsr_iterator_stop(iterator)
...
subroutine, public dbcsr_get_info(matrix, nblkrows_total, nblkcols_total, nfullrows_total, nfullcols_total, nblkrows_local, nblkcols_local, nfullrows_local, nfullcols_local, my_prow, my_pcol, local_rows, local_cols, proc_row_dist, proc_col_dist, row_blk_size, col_blk_size, row_blk_offset, col_blk_offset, distribution, name, matrix_type, group)
...
subroutine, public dbcsr_iterator_next_block(iterator, row, column, block, block_number_argument_has_been_removed, row_size, col_size, row_offset, col_offset, transposed)
...
subroutine, public dbcsr_iterator_start(iterator, matrix, shared, dynamic, dynamic_byrows)
...
Defines the basic variable types.
Definition kinds.F:23
integer, parameter, public int_8
Definition kinds.F:54
integer, parameter, public dp
Definition kinds.F:34
integer, parameter, public default_string_length
Definition kinds.F:57
integer, parameter, public default_path_length
Definition kinds.F:58
integer, parameter, public sp
Definition kinds.F:33
Interface to the message passing library MPI.
Module for equivariant PAO-ML based on PyTorch.
Definition pao_model.F:12
subroutine, public pao_model_predict(pao, qs_env)
Fills paomatrix_X based on machine learning predictions.
Definition pao_model.F:154
subroutine, public pao_model_forces(pao, qs_env, matrix_g, forces)
Calculate forces contributed by machine learning.
Definition pao_model.F:188
subroutine, public pao_model_load(pao, qs_env, ikind, pao_model_file, model)
Loads a PAO-ML model.
Definition pao_model.F:65
Types used by the PAO machinery.
Definition pao_types.F:12
Define the data structure for the particle information.
Definition of physical constants:
Definition physcon.F:68
real(kind=dp), parameter, public angstrom
Definition physcon.F:144
subroutine, public get_qs_env(qs_env, atomic_kind_set, qs_kind_set, cell, super_cell, cell_ref, use_ref_cell, kpoints, dft_control, mos, sab_orb, sab_all, qmmm, qmmm_periodic, mimic, sac_ae, sac_ppl, sac_lri, sap_ppnl, sab_vdw, sab_scp, sap_oce, sab_lrc, sab_se, sab_xtbe, sab_tbe, sab_core, sab_xb, sab_xtb_pp, sab_xtb_nonbond, sab_almo, sab_kp, sab_kp_nosym, sab_cneo, particle_set, energy, force, matrix_h, matrix_h_im, matrix_ks, matrix_ks_im, matrix_vxc, run_rtp, rtp, matrix_h_kp, matrix_h_im_kp, matrix_ks_kp, matrix_ks_im_kp, matrix_vxc_kp, kinetic_kp, matrix_s_kp, matrix_w_kp, matrix_s_ri_aux_kp, matrix_s, matrix_s_ri_aux, matrix_w, matrix_p_mp2, matrix_p_mp2_admm, matrix_vhxc, rho, rho_xc, pw_env, ewald_env, ewald_pw, active_space, mpools, input, para_env, blacs_env, scf_control, rel_control, kinetic, qs_charges, vppl, xcint_weights, rho_core, rho_nlcc, rho_nlcc_g, ks_env, ks_qmmm_env, wf_history, scf_env, local_particles, local_molecules, distribution_2d, dbcsr_dist, molecule_kind_set, molecule_set, subsys, cp_subsys, oce, local_rho_set, rho_atom_set, task_list, task_list_soft, rho0_atom_set, rho0_mpole, rhoz_set, rhoz_cneo_set, ecoul_1c, rho0_s_rs, rho0_s_gs, rhoz_cneo_s_rs, rhoz_cneo_s_gs, do_kpoints, has_unit_metric, requires_mo_derivs, mo_derivs, mo_loc_history, nkind, natom, nelectron_total, nelectron_spin, efield, neighbor_list_id, linres_control, xas_env, virial, cp_ddapc_env, cp_ddapc_ewald, outer_scf_history, outer_scf_ihistory, x_data, et_coupling, dftb_potential, results, se_taper, se_store_int_env, se_nddo_mpole, se_nonbond_env, admm_env, lri_env, lri_density, exstate_env, ec_env, harris_env, dispersion_env, gcp_env, vee, rho_external, external_vxc, mask, mp2_env, bs_env, kg_env, wanniercentres, atprop, ls_scf_env, do_transport, transport_env, v_hartree_rspace, s_mstruct_changed, rho_changed, potential_changed, forces_up_to_date, mscfg_env, almo_scf_env, gradient_history, variable_history, embed_pot, spin_embed_pot, polar_env, mos_last_converged, eeq, rhs, do_rixs, tb_tblite)
Get the QUICKSTEP environment.
Define the quickstep kind type and their sub types.
subroutine, public get_qs_kind(qs_kind, basis_set, basis_type, ncgf, nsgf, all_potential, tnadd_potential, gth_potential, sgp_potential, upf_potential, cneo_potential, se_parameter, dftb_parameter, xtb_parameter, dftb3_param, zatom, zeff, elec_conf, mao, lmax_dftb, alpha_core_charge, ccore_charge, core_charge, core_charge_radius, paw_proj_set, paw_atom, hard_radius, hard0_radius, max_rad_local, covalent_radius, vdw_radius, gpw_type_forced, harmonics, max_iso_not0, max_s_harm, grid_atom, ngrid_ang, ngrid_rad, lmax_rho0, dft_plus_u_atom, l_of_dft_plus_u, n_of_dft_plus_u, u_minus_j, hund_j, u_of_dft_plus_u, j_of_dft_plus_u, alpha_of_dft_plus_u, beta_of_dft_plus_u, j0_of_dft_plus_u, occupation_of_dft_plus_u, dispersion, bs_occupation, magnetization, no_optimize, addel, laddel, naddel, orbitals, max_scf, eps_scf, smear, u_ramping, u_minus_j_target, eps_u_ramping, proj_shell_charge, lr_atom, do_mtlr, u_j_loop, ao_coef, init_u_ramping_each_scf, reltmat, ghost, monovalent, floating, name, element_symbol, pao_basis_size, pao_model_file, pao_potentials, pao_descriptors, nelec)
Get attributes of an atomic kind.
subroutine, public torch_dict_release(dict)
Releases a Torch dictionary and all its ressources.
Definition torch_api.F:1842
subroutine, public torch_tensor_backward(tensor, outer_grad)
Runs autograd on a Torch tensor.
Definition torch_api.F:1471
subroutine, public torch_dict_get(dict, key, tensor)
Retrieves a Torch tensor from a Torch dictionary.
Definition torch_api.F:1808
subroutine, public torch_model_load(model, filename)
Loads a Torch model from given "*.pth" file. (In Torch lingo models are called modules).
Definition torch_api.F:1866
subroutine, public torch_model_remap_device_constants(model)
Maps serialized TorchScript device constants to the active Torch device.
Definition torch_api.F:1949
subroutine, public torch_dict_create(dict)
Creates an empty Torch dictionary.
Definition torch_api.F:1725
subroutine, public torch_tensor_grad(tensor, grad)
Returns the gradient of a Torch tensor which was computed by autograd.
Definition torch_api.F:1575
subroutine, public torch_dict_insert(dict, key, tensor)
Inserts a Torch tensor into a Torch dictionary.
Definition torch_api.F:1776
subroutine, public torch_tensor_release(tensor)
Releases a Torch tensor and all its ressources.
Definition torch_api.F:1701
subroutine, public torch_model_forward(model, inputs, outputs)
Evaluates the given Torch model.
Definition torch_api.F:1996
Provides all information about an atomic kind.
Type defining parameters related to the simulation cell.
Definition cell_types.F:60
stores all the informations relevant to an mpi environment
PAO-ML model for a single atomic kind.
Definition pao_types.F:60
Provides all information about a quickstep kind.