SIRIUS 7.5.0
Electronic structure library and applications
unit_cell.hpp
Go to the documentation of this file.
1// Copyright (c) 2013-2021 Anton Kozhevnikov, Thomas Schulthess
2// All rights reserved.
3//
4// Redistribution and use in source and binary forms, with or without modification, are permitted provided that
5// the following conditions are met:
6//
7// 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the
8// following disclaimer.
9// 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions
10// and the following disclaimer in the documentation and/or other materials provided with the distribution.
11//
12// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED
13// WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
14// PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
15// ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
16// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
17// CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
18// OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
19
20/** \file unit_cell.hpp
21 *
22 * \brief Contains definition and partial implementation of sirius::Unit_cell class.
23 */
24
25#ifndef __UNIT_CELL_HPP__
26#define __UNIT_CELL_HPP__
27
28#include <algorithm>
29#include "atom.hpp"
30#include "core/mpi/mpi_grid.hpp"
31#include "core/json.hpp"
33
34namespace sirius {
35
36using json = nlohmann::json;
37
38/* forward declaration */
39class Crystal_symmetry;
40
41/// Representation of a unit cell.
43{
44 private:
45 /// Basic parameters of the simulation.
47
48 /// Mapping between atom type label and an ordered internal id in the range [0, \f$ N_{types} \f$).
49 std::map<std::string, int> atom_type_id_map_;
50
51 /// List of atom types.
52 std::vector<std::shared_ptr<Atom_type>> atom_types_;
53
54 /// List of atom classes.
55 std::vector<std::shared_ptr<Atom_symmetry_class>> atom_symmetry_classes_;
56
57 /// List of atoms.
58 std::vector<std::shared_ptr<Atom>> atoms_;
59
60 /// Split index of atoms.
62
63 /// Global index of atom by index of PAW atom.
64 std::vector<int> paw_atom_index_;
65
66 /// Split index of PAW atoms.
68
69 /// Split index of atom symmetry classes.
71
72 /// Bravais lattice vectors in column order.
73 /** The following convention is used to transform fractional coordinates to Cartesian:
74 * \f[
75 * \vec v_{C} = {\bf L} \vec v_{f}
76 * \f]
77 */
79
80 /// Inverse matrix of Bravais lattice vectors.
81 /** This matrix is used to find fractional coordinates by Cartesian coordinates:
82 * \f[
83 * \vec v_{f} = {\bf L}^{-1} \vec v_{C}
84 * \f]
85 */
87
88 /// Reciprocal lattice vectors in column order.
89 /** The following convention is used:
90 * \f[
91 * \vec a_{i} \vec b_{j} = 2 \pi \delta_{ij}
92 * \f]
93 * or in matrix notation
94 * \f[
95 * {\bf A} {\bf B}^{T} = 2 \pi {\bf I}
96 * \f]
97 */
99
100 /// Volume \f$ \Omega \f$ of the unit cell. Volume of Brillouin zone is then \f$ (2\Pi)^3 / \Omega \f$.
101 double omega_{0};
102
103 /// Total volume of the muffin-tin spheres.
104 double volume_mt_{0};
105
106 /// Volume of the interstitial region.
107 double volume_it_{0};
108
109 /// List of equivalent atoms, provided externally.
110 std::vector<int> equivalent_atoms_;
111
112 /// List of nearest neighbours for each atom.
113 std::vector<std::vector<nearest_neighbour_descriptor>> nearest_neighbours_;
114
115 std::unique_ptr<Crystal_symmetry> symmetry_;
116
117 /// Atomic coordinates in GPU-friendly ordering packed in arrays for each atom type.
118 std::vector<sddk::mdarray<double, 2>> atom_coord_;
119
120 mpi::Communicator const& comm_;
121
122 std::pair<int, std::vector<int>> num_hubbard_wf_;
123
124 /// Check if MT spheres overlap
125 inline bool check_mt_overlap(int& ia__, int& ja__);
126
127 int next_atom_type_id(std::string label__);
128
129 public:
130 Unit_cell(Simulation_parameters const& parameters__, mpi::Communicator const& comm__);
131
132 ~Unit_cell();
133
134 /// Initialize the unit cell data
135 /** Several things must be done during this phase:
136 * 1. Compute number of electrons
137 * 2. Compute MT basis function indices
138 * 3. [if needed] Scale MT radii
139 * 4. Check MT overlap
140 * 5. Create radial grid for each atom type
141 * 6. Find symmetry and assign symmetry class to each atom
142 * 7. Create split indices for atoms and atom classes */
143 void initialize();
144
145 /// Add new atom type to the list of atom types and read necessary data from the .json file
146 Atom_type& add_atom_type(const std::string label__, const std::string file_name__ = "");
147
148 /// Add new atom to the list of atom types.
149 void add_atom(const std::string label, r3::vector<double> position, r3::vector<double> vector_field);
150
151 /// Add new atom without vector field to the list of atom types.
152 void add_atom(const std::string label, r3::vector<double> position)
153 {
154 add_atom(label, position, {0, 0, 0});
155 }
156
157 /// Add PAW atoms.
158 void init_paw();
159
160 /// Return number of atoms with PAW pseudopotential.
161 int num_paw_atoms() const
162 {
163 return static_cast<int>(paw_atom_index_.size());
164 }
165
166 inline auto const& paw_atoms() const
167 {
168 return paw_atom_index_;
169 }
170
171 /// Get split index of PAW atoms.
172 inline auto const& spl_num_paw_atoms() const
173 {
174 return spl_num_paw_atoms_;
175 }
176
177 inline auto spl_num_paw_atoms(paw_atom_index_t::local idx__) const
178 {
179 return spl_num_paw_atoms_.global_index(idx__);
180 }
181
182 /// Return global index of atom by the index in the list of PAW atoms.
183 inline auto paw_atom_index(paw_atom_index_t::global ipaw__) const
184 {
185 return typename atom_index_t::global(paw_atom_index_[ipaw__]);
186 }
187
188 /// Print basic info.
189 void print_info(std::ostream& out__, int verbosity__) const;
190
191 void print_geometry_info(std::ostream& out__, int verbosity__) const;
192
193 void print_nearest_neighbours(std::ostream& out__) const;
194
195 unit_cell_parameters_descriptor unit_cell_parameters();
196
197 /// Get crystal symmetries and equivalent atoms.
198 /** Makes a call to spglib providing the basic unit cell information: lattice vectors and atomic types
199 * and positions. Gets back symmetry operations and a table of equivalent atoms. The table of equivalent
200 * atoms is then used to make a list of atom symmetry classes and related data. */
201 void get_symmetry();
202
203 /// Write structure to CIF file.
204 void write_cif();
205
206 /// Write structure to JSON file.
207 json serialize(bool cart_pos__ = false) const;
208
209 /// Set matrix of lattice vectors.
210 /** Initializes lattice vectors, inverse lattice vector matrix, reciprocal lattice vectors and the
211 * unit cell volume. */
212 void set_lattice_vectors(r3::matrix<double> lattice_vectors__);
213
214 /// Set lattice vectors.
216
217 /// Find the cluster of nearest neighbours around each atom
218 void find_nearest_neighbours(double cluster_radius);
219
220 bool is_point_in_mt(r3::vector<double> vc, int& ja, int& jr, double& dr, double tp[2]) const;
221
222 void generate_radial_functions(std::ostream& out__);
223
224 void generate_radial_integrals();
225
226 /// Get a simple simple chemical formula bases on the total unit cell.
227 /** Atoms of each type are counted and packed in a string. For example, O2Ni2 or La2O4Cu */
228 std::string chemical_formula();
229
230 /// Update the parameters that depend on atomic positions or lattice vectors.
231 void update();
232
233 /// Import unit cell description from the input data structure.
234 /** Set lattice vectors, atom types and coordinates of atoms. The "atom_coordinate_units" parameter by default
235 * is assumed to be "lattice" which means that the atomic coordinates are provided in lattice (fractional) units.
236 * It can also be specified in "A" or "au" which means that the input atomic coordinates are Cartesian and
237 * provided in Angstroms or atomic units of length. This is useful in setting up the molecule calculation. */
238 void import(config_t::unit_cell_t const& inp__);
239
240 /// Get atom ID (global index) by it's position in fractional coordinates.
242
243 /// Find the minimum bond length.
244 /** This is useful to check the sanity of the crystal structure. */
245 double min_bond_length() const;
246
247 /// Automatically determine new muffin-tin radii as a half distance between neighbor atoms.
248 /** In order to guarantee a unique solution muffin-tin radii are dermined as a half distance
249 * bethween nearest atoms. Initial values of the muffin-tin radii are ignored. */
250 std::vector<double> find_mt_radii(int auto_rmt__, bool inflate__);
251
252 /// Get the total number of pseudo atomic wave-functions.
253 std::pair<int, std::vector<int>> num_ps_atomic_wf() const;
254
255 /// Return number of Hubbard wave-functions.
256 auto const& num_hubbard_wf() const
257 {
258 return num_hubbard_wf_;
259 }
260
261 /// Get Cartesian coordinates of the vector by its fractional coordinates.
262 template <typename T>
264 {
265 return dot(lattice_vectors_ , a__);
266 }
267
268 /// Get fractional coordinates of the vector by its Cartesian coordinates.
270 {
271 return dot(inverse_lattice_vectors_ , a__);
272 }
273
274 /// Unit cell volume.
275 inline double omega() const
276 {
277 return omega_;
278 }
279
280 /// Number of atom types.
281 inline int num_atom_types() const
282 {
283 assert(atom_types_.size() == atom_type_id_map_.size());
284 return static_cast<int>(atom_types_.size());
285 }
286
287 /// Return atom type instance by id.
288 inline Atom_type& atom_type(int id__)
289 {
290 assert(id__ >= 0 && id__ < (int)atom_types_.size());
291 return *atom_types_[id__];
292 }
293
294 /// Return const atom type instance by id.
295 inline Atom_type const& atom_type(int id__) const
296 {
297 assert(id__ >= 0 && id__ < (int)atom_types_.size());
298 return *atom_types_[id__];
299 }
300
301 /// Return const atom type instance by label.
302 inline auto const& atom_type(std::string const label__) const
303 {
304 if (!atom_type_id_map_.count(label__)) {
305 std::stringstream s;
306 s << "atom type " << label__ << " is not found";
307 RTE_THROW(s);
308 }
309 int id = atom_type_id_map_.at(label__);
310 return atom_type(id);
311 }
312
313 /// Return atom type instance by label.
314 inline auto& atom_type(std::string const label__)
315 {
316 return const_cast<Atom_type&>(reinterpret_cast<Unit_cell const&>(*this).atom_type(label__));
317 }
318
319 /// Number of atom symmetry classes.
320 inline int num_atom_symmetry_classes() const
321 {
322 return static_cast<int>(atom_symmetry_classes_.size());
323 }
324
325 /// Return const symmetry class instance by class id.
326 inline Atom_symmetry_class const& atom_symmetry_class(int id__) const
327 {
328 return *atom_symmetry_classes_[id__];
329 }
330
331 /// Return symmetry class instance by class id.
333 {
334 return *atom_symmetry_classes_[id__];
335 }
336
337 /// Number of atoms in the unit cell.
338 inline int num_atoms() const
339 {
340 return static_cast<int>(atoms_.size());
341 }
342
343 /// Return const atom instance by id.
344 inline Atom const& atom(int id__) const
345 {
346 assert(id__ >= 0 && id__ < (int)atoms_.size());
347 return *atoms_[id__];
348 }
349
350 /// Return atom instance by id.
351 inline Atom& atom(int id__)
352 {
353 assert(id__ >= 0 && id__ < (int)atoms_.size());
354 return *atoms_[id__];
355 }
356
357 /// Total nuclear charge.
358 inline int total_nuclear_charge() const
359 {
360 int result{0};
361 for (int iat = 0; iat < num_atom_types(); iat++) {
362 int nat = atom_type(iat).num_atoms();
363 result += nat * atom_type(iat).zn();
364 }
365 return result;
366 }
367
368 /// Total number of electrons (core + valence).
369 inline double num_electrons() const
370 {
371 return this->num_core_electrons() + this->num_valence_electrons();
372 }
373
374 /// Number of valence electrons.
375 inline double num_valence_electrons() const
376 {
377 double result{0};
378 for (int iat = 0; iat < num_atom_types(); iat++) {
379 int nat = atom_type(iat).num_atoms();
380 result += nat * atom_type(iat).num_valence_electrons();
381 }
382 return result;
383 }
384
385 /// Number of core electrons.
386 inline double num_core_electrons() const
387 {
388 double result{0};
389 for (int iat = 0; iat < num_atom_types(); iat++) {
390 int nat = atom_type(iat).num_atoms();
391 result += nat * atom_type(iat).num_core_electrons();
392 }
393 return result;
394 }
395
396 /// Maximum number of muffin-tin points among all atom types.
397 inline int max_num_mt_points() const
398 {
399 int result{0};
400 for (int iat = 0; iat < num_atom_types(); iat++) {
401 result = std::max(result, atom_type(iat).num_mt_points());
402 }
403 return result;
404 }
405
406 /// Total number of the augmented wave basis functions over all atoms.
407 /** This is equal to the total number of matching coefficients for each plane-wave. */
408 inline int mt_aw_basis_size() const
409 {
410 int result{0};
411 for (int iat = 0; iat < num_atom_types(); iat++) {
412 int nat = atom_type(iat).num_atoms();
413 result += nat * atom_type(iat).mt_aw_basis_size();
414 }
415 return result;
416 }
417
418 /// Total number of local orbital basis functions over all atoms.
419 inline int mt_lo_basis_size() const
420 {
421 int result{0};
422 for (int iat = 0; iat < num_atom_types(); iat++) {
423 int nat = atom_type(iat).num_atoms();
424 result += nat * atom_type(iat).mt_lo_basis_size();
425 }
426 return result;
427 }
428
429 /// Maximum number of basis functions among all atom types.
430 inline int max_mt_basis_size() const
431 {
432 int result{0};
433 for (int iat = 0; iat < num_atom_types(); iat++) {
434 result = std::max(result, atom_type(iat).mt_basis_size());
435 }
436 return result;
437 }
438
439 /// Maximum number of radial functions among all atom types.
440 inline int max_mt_radial_basis_size() const
441 {
442 int result{0};
443 for (int iat = 0; iat < num_atom_types(); iat++) {
444 result = std::max(result, atom_type(iat).mt_radial_basis_size());
445 }
446 return result;
447 }
448
449 /// Minimum muffin-tin radius.
450 inline double min_mt_radius() const
451 {
452 double result{1e100};
453 for (int iat = 0; iat < num_atom_types(); iat++) {
454 result = std::min(result, atom_type(iat).mt_radius());
455 }
456 return result;
457 }
458
459 /// Maximum muffin-tin radius.
460 inline double max_mt_radius() const
461 {
462 double result{0};
463 for (int iat = 0; iat < num_atom_types(); iat++) {
464 result = std::max(result, atom_type(iat).mt_radius());
465 }
466 return result;
467 }
468
469 /// Maximum number of AW basis functions among all atom types.
470 inline int max_mt_aw_basis_size() const
471 {
472 int result{0};
473 for (int iat = 0; iat < num_atom_types(); iat++) {
474 result = std::max(result, atom_type(iat).mt_aw_basis_size());
475 }
476 return result;
477 }
478
479 /// Maximum local orbital basis size among all atoms.
480 inline int max_mt_lo_basis_size() const
481 {
482 int result{0};
483 for (int iat = 0; iat < num_atom_types(); iat++) {
484 result = std::max(result, atom_type(iat).mt_lo_basis_size());
485 }
486 return result;
487 }
488
489 /// Maximum number of atoms across all atom types.
490 inline auto max_num_atoms() const
491 {
492 int max_na{0};
493 for (int iat = 0; iat < this->num_atom_types(); iat++) {
494 max_na = std::max(max_na, this->atom_type(iat).num_atoms());
495 }
496 return max_na;
497 }
498
499 void set_equivalent_atoms(int const* equivalent_atoms__)
500 {
502 std::copy(equivalent_atoms__, equivalent_atoms__ + num_atoms(), equivalent_atoms_.begin());
503 }
504
505 inline auto const& spl_num_atoms() const
506 {
507 return spl_num_atoms_;
508 }
509
510 inline auto const& spl_num_atom_symmetry_classes() const
511 {
513 }
514
515 inline double volume_mt() const
516 {
517 return volume_mt_;
518 }
519
520 inline double volume_it() const
521 {
522 return volume_it_;
523 }
524
525 /// Maximum orbital quantum number of radial functions between all atom types.
526 inline int lmax() const
527 {
528 int l{-1};
529 for (int iat = 0; iat < this->num_atom_types(); iat++) {
530 l = std::max(l, this->atom_type(iat).indexr().lmax());
531 }
532 return l;
533 }
534
535 inline int lmax_apw() const
536 {
537 int lmax{-1};
538 for (int iat = 0; iat < this->num_atom_types(); iat++) {
539 lmax = std::max(lmax, this->atom_type(iat).lmax_apw());
540 }
541 return lmax;
542 }
543
544 inline int num_nearest_neighbours(int ia) const
545 {
546 return static_cast<int>(nearest_neighbours_[ia].size());
547 }
548
549 inline auto const& nearest_neighbour(int i, int ia) const
550 {
551 return nearest_neighbours_[ia][i];
552 }
553
554 inline auto const& symmetry() const
555 {
556 RTE_ASSERT(symmetry_ != nullptr);
557 return *symmetry_;
558 }
559
560 inline auto const& lattice_vectors() const
561 {
562 return lattice_vectors_;
563 }
564
565 inline auto const& inverse_lattice_vectors() const
566 {
568 }
569
570 inline auto const& reciprocal_lattice_vectors() const
571 {
573 }
574
575 /// Return a single lattice vector.
576 inline auto lattice_vector(int idx__) const
577 {
578 return r3::vector<double>(lattice_vectors_(0, idx__), lattice_vectors_(1, idx__), lattice_vectors_(2, idx__));
579 }
580
581 auto const& parameters() const
582 {
583 return parameters_;
584 }
585
586 auto const& comm() const
587 {
588 return comm_;
589 }
590
591 inline auto const& atom_coord(int iat__) const
592 {
593 return atom_coord_[iat__];
594 }
595
596 /// Return 'True' if at least one atom in the unit cell has an augmentation charge.
597 inline bool augment() const
598 {
599 bool a{false};
600 for (auto iat = 0; iat < num_atom_types(); iat++) {
601 a |= atom_type(iat).augment();
602 }
603 return a;
604 }
605};
606
607} // namespace sirius
608
609#endif // __UNIT_CELL_HPP__
Contains declaration and partial implementation of sirius::Atom class.
namespace for Niels Lohmann
Data and methods specific to the symmetry class of the atom.
Defines the properties of atom type.
Definition: atom_type.hpp:93
int zn() const
Return ionic charge (as positive integer).
Definition: atom_type.hpp:681
int num_atoms() const
Return number of atoms of a given type.
Definition: atom_type.hpp:934
bool augment() const
Return true if this atom type has an augementation charge.
Definition: atom_type.hpp:569
Data and methods specific to the actual atom in the unit cell.
Definition: atom.hpp:37
Set of basic parameters of a simulation.
Representation of a unit cell.
Definition: unit_cell.hpp:43
splindex_block< atom_index_t > spl_num_atoms_
Split index of atoms.
Definition: unit_cell.hpp:61
int mt_aw_basis_size() const
Total number of the augmented wave basis functions over all atoms.
Definition: unit_cell.hpp:408
double omega() const
Unit cell volume.
Definition: unit_cell.hpp:275
splindex_block< paw_atom_index_t > spl_num_paw_atoms_
Split index of PAW atoms.
Definition: unit_cell.hpp:67
auto const & num_hubbard_wf() const
Return number of Hubbard wave-functions.
Definition: unit_cell.hpp:256
std::vector< int > paw_atom_index_
Global index of atom by index of PAW atom.
Definition: unit_cell.hpp:64
r3::matrix< double > reciprocal_lattice_vectors_
Reciprocal lattice vectors in column order.
Definition: unit_cell.hpp:98
int max_num_mt_points() const
Maximum number of muffin-tin points among all atom types.
Definition: unit_cell.hpp:397
Atom const & atom(int id__) const
Return const atom instance by id.
Definition: unit_cell.hpp:344
int mt_lo_basis_size() const
Total number of local orbital basis functions over all atoms.
Definition: unit_cell.hpp:419
void print_info(std::ostream &out__, int verbosity__) const
Print basic info.
Definition: unit_cell.cpp:170
auto get_fractional_coordinates(r3::vector< double > a__) const
Get fractional coordinates of the vector by its Cartesian coordinates.
Definition: unit_cell.hpp:269
auto max_num_atoms() const
Maximum number of atoms across all atom types.
Definition: unit_cell.hpp:490
int num_paw_atoms() const
Return number of atoms with PAW pseudopotential.
Definition: unit_cell.hpp:161
std::vector< int > equivalent_atoms_
List of equivalent atoms, provided externally.
Definition: unit_cell.hpp:110
int num_atom_symmetry_classes() const
Number of atom symmetry classes.
Definition: unit_cell.hpp:320
double min_mt_radius() const
Minimum muffin-tin radius.
Definition: unit_cell.hpp:450
auto lattice_vector(int idx__) const
Return a single lattice vector.
Definition: unit_cell.hpp:576
std::map< std::string, int > atom_type_id_map_
Mapping between atom type label and an ordered internal id in the range [0, ).
Definition: unit_cell.hpp:49
bool augment() const
Return 'True' if at least one atom in the unit cell has an augmentation charge.
Definition: unit_cell.hpp:597
int lmax() const
Maximum orbital quantum number of radial functions between all atom types.
Definition: unit_cell.hpp:526
std::string chemical_formula()
Get a simple simple chemical formula bases on the total unit cell.
Definition: unit_cell.cpp:608
auto const & spl_num_paw_atoms() const
Get split index of PAW atoms.
Definition: unit_cell.hpp:172
int num_atom_types() const
Number of atom types.
Definition: unit_cell.hpp:281
void initialize()
Initialize the unit cell data.
Definition: unit_cell.cpp:669
void init_paw()
Add PAW atoms.
Definition: unit_cell.cpp:958
Atom_symmetry_class & atom_symmetry_class(int id__)
Return symmetry class instance by class id.
Definition: unit_cell.hpp:332
json serialize(bool cart_pos__=false) const
Write structure to JSON file.
Definition: unit_cell.cpp:374
std::vector< std::vector< nearest_neighbour_descriptor > > nearest_neighbours_
List of nearest neighbours for each atom.
Definition: unit_cell.hpp:113
std::pair< int, std::vector< int > > num_ps_atomic_wf() const
Get the total number of pseudo atomic wave-functions.
Definition: unit_cell.cpp:971
double min_bond_length() const
Find the minimum bond length.
Definition: unit_cell.cpp:656
int max_mt_basis_size() const
Maximum number of basis functions among all atom types.
Definition: unit_cell.hpp:430
std::vector< std::shared_ptr< Atom_symmetry_class > > atom_symmetry_classes_
List of atom classes.
Definition: unit_cell.hpp:55
int max_mt_aw_basis_size() const
Maximum number of AW basis functions among all atom types.
Definition: unit_cell.hpp:470
splindex_block< atom_symmetry_class_index_t > spl_num_atom_symmetry_classes_
Split index of atom symmetry classes.
Definition: unit_cell.hpp:70
Atom_type & atom_type(int id__)
Return atom type instance by id.
Definition: unit_cell.hpp:288
int max_mt_radial_basis_size() const
Maximum number of radial functions among all atom types.
Definition: unit_cell.hpp:440
int atom_id_by_position(r3::vector< double > position__)
Get atom ID (global index) by it's position in fractional coordinates.
Definition: unit_cell.cpp:932
auto const & atom_type(std::string const label__) const
Return const atom type instance by label.
Definition: unit_cell.hpp:302
std::vector< sddk::mdarray< double, 2 > > atom_coord_
Atomic coordinates in GPU-friendly ordering packed in arrays for each atom type.
Definition: unit_cell.hpp:118
void set_lattice_vectors(r3::matrix< double > lattice_vectors__)
Set matrix of lattice vectors.
Definition: unit_cell.cpp:911
r3::matrix< double > inverse_lattice_vectors_
Inverse matrix of Bravais lattice vectors.
Definition: unit_cell.hpp:86
auto & atom_type(std::string const label__)
Return atom type instance by label.
Definition: unit_cell.hpp:314
void write_cif()
Write structure to CIF file.
Definition: unit_cell.cpp:342
void add_atom(const std::string label, r3::vector< double > position)
Add new atom without vector field to the list of atom types.
Definition: unit_cell.hpp:152
int num_atoms() const
Number of atoms in the unit cell.
Definition: unit_cell.hpp:338
double num_core_electrons() const
Number of core electrons.
Definition: unit_cell.hpp:386
std::vector< double > find_mt_radii(int auto_rmt__, bool inflate__)
Automatically determine new muffin-tin radii as a half distance between neighbor atoms.
Definition: unit_cell.cpp:41
Simulation_parameters const & parameters_
Basic parameters of the simulation.
Definition: unit_cell.hpp:46
double num_valence_electrons() const
Number of valence electrons.
Definition: unit_cell.hpp:375
std::vector< std::shared_ptr< Atom > > atoms_
List of atoms.
Definition: unit_cell.hpp:58
double volume_mt_
Total volume of the muffin-tin spheres.
Definition: unit_cell.hpp:104
double max_mt_radius() const
Maximum muffin-tin radius.
Definition: unit_cell.hpp:460
Atom_type & add_atom_type(const std::string label__, const std::string file_name__="")
Add new atom type to the list of atom types and read necessary data from the .json file.
Definition: unit_cell.cpp:629
void get_symmetry()
Get crystal symmetries and equivalent atoms.
Definition: unit_cell.cpp:726
double omega_
Volume of the unit cell. Volume of Brillouin zone is then .
Definition: unit_cell.hpp:101
auto get_cartesian_coordinates(r3::vector< T > a__) const
Get Cartesian coordinates of the vector by its fractional coordinates.
Definition: unit_cell.hpp:263
r3::matrix< double > lattice_vectors_
Bravais lattice vectors in column order.
Definition: unit_cell.hpp:78
Atom & atom(int id__)
Return atom instance by id.
Definition: unit_cell.hpp:351
void add_atom(const std::string label, r3::vector< double > position, r3::vector< double > vector_field)
Add new atom to the list of atom types.
Definition: unit_cell.cpp:637
void update()
Update the parameters that depend on atomic positions or lattice vectors.
Definition: unit_cell.cpp:839
void find_nearest_neighbours(double cluster_radius)
Find the cluster of nearest neighbours around each atom.
Definition: unit_cell.cpp:412
Atom_type const & atom_type(int id__) const
Return const atom type instance by id.
Definition: unit_cell.hpp:295
double volume_it_
Volume of the interstitial region.
Definition: unit_cell.hpp:107
double num_electrons() const
Total number of electrons (core + valence).
Definition: unit_cell.hpp:369
int total_nuclear_charge() const
Total nuclear charge.
Definition: unit_cell.hpp:358
Atom_symmetry_class const & atom_symmetry_class(int id__) const
Return const symmetry class instance by class id.
Definition: unit_cell.hpp:326
auto paw_atom_index(paw_atom_index_t::global ipaw__) const
Return global index of atom by the index in the list of PAW atoms.
Definition: unit_cell.hpp:183
std::vector< std::shared_ptr< Atom_type > > atom_types_
List of atom types.
Definition: unit_cell.hpp:52
bool check_mt_overlap(int &ia__, int &ja__)
Check if MT spheres overlap.
Definition: unit_cell.cpp:144
int max_mt_lo_basis_size() const
Maximum local orbital basis size among all atoms.
Definition: unit_cell.hpp:480
Unit cell representation.
Definition: config.hpp:336
MPI communicator wrapper.
Interface to nlohmann::json library and helper functions.
Contains declaration and implementation of sddk::MPI_grid class.
void copy(T *target__, T const *source__, size_t n__)
Copy memory inside a device.
Definition: acc.hpp:320
Namespace of the SIRIUS library.
Definition: sirius.f90:5
Contains definition and implementation of sirius::Simulation_parameters class.