ABACUS develop
Atomic-orbital Based Ab-initio Computation at UStc
Loading...
Searching...
No Matches
setcell.h
Go to the documentation of this file.
1//==========================================================
2// Used to genarate ucell
3//==========================================================
4#ifndef SETCELL_H
5#define SETCELL_H
6
14
15#include <cmath>
16#include <cstdint>
17#include <string>
18#include <vector>
19
21{
22 this->tot_mag = 0.0;
23 this->abs_mag = 0.0;
24}
26
27class Setcell
28{
29 public:
30 static void setupcell(UnitCell &ucell)
31 {
32 ucell.ntype = 1;
33
34 ucell.atoms = new Atom[ucell.ntype];
35 ucell.set_atom_flag = true;
36
37 ucell.atoms[0].mass = 39.948;
38 ucell.atoms[0].label = "Ar";
39
40 ucell.lat0 = 1;
42 ucell.tpiba = ModuleBase::TWO_PI / ucell.lat0;
43 ucell.tpiba2 = ucell.tpiba * ucell.tpiba;
44
45 ucell.latvec.e11 = ucell.latvec.e22 = ucell.latvec.e33 = 10;
46 ucell.latvec.e12 = ucell.latvec.e13 = ucell.latvec.e23 = 0;
47 ucell.latvec.e21 = ucell.latvec.e31 = ucell.latvec.e32 = 0;
48
49 ucell.a1.x = ucell.latvec.e11;
50 ucell.a1.y = ucell.latvec.e12;
51 ucell.a1.z = ucell.latvec.e13;
52
53 ucell.a2.x = ucell.latvec.e21;
54 ucell.a2.y = ucell.latvec.e22;
55 ucell.a2.z = ucell.latvec.e23;
56
57 ucell.a3.x = ucell.latvec.e31;
58 ucell.a3.y = ucell.latvec.e32;
59 ucell.a3.z = ucell.latvec.e33;
60
61 ucell.nat = 4;
62 ucell.atoms[0].na = 4;
63 ucell.init_vel = true;
64
65 ucell.atoms[0].tau.resize(4);
66 ucell.atoms[0].dis.resize(4);
67 ucell.atoms[0].taud.resize(4);
68 ucell.atoms[0].vel.resize(4);
69 ucell.atoms[0].mbl.resize(4);
70
71 ucell.atoms[0].angle1.resize(4);
72 ucell.atoms[0].angle2.resize(4);
73 ucell.atoms[0].m_loc_.resize(4);
74
75 ucell.atoms[0].taud[0].set(0.0, 0.0, 0.0);
76 ucell.atoms[0].taud[1].set(0.52, 0.52, 0.0);
77 ucell.atoms[0].taud[2].set(0.51, 0.0, 0.5);
78 ucell.atoms[0].taud[3].set(0.0, 0.53, 0.5);
79 ucell.atoms[0].vel[0].set(-0.000132080736364, 7.13429429835e-05, -1.40179977966e-05);
80 ucell.atoms[0].vel[1].set(0.000153039878532, -0.000146533266608, 9.64491480698e-05);
81 ucell.atoms[0].vel[2].set(-0.000133789480226, -3.0451038112e-06, -5.40998380137e-05);
82 ucell.atoms[0].vel[3].set(0.000112830338059, 7.82354274358e-05, -2.83313122596e-05);
83 for (int ia = 0; ia < 4; ++ia)
84 {
85 ucell.atoms[0].tau[ia] = ucell.atoms[0].taud[ia] * ucell.latvec;
86 ucell.atoms[0].mbl[ia].set(1, 1, 1);
87 }
88
89 ucell.omega = std::abs(ucell.latvec.Det()) * ucell.lat0 * ucell.lat0 * ucell.lat0;
90
91 ucell.GT = ucell.latvec.Inverse();
92 ucell.G = ucell.GT.Transpose();
93 ucell.GGT = ucell.G * ucell.GT;
94 ucell.invGGT = ucell.GGT.Inverse();
95
96 ucell.set_iat2itia();
97 };
98
106 {
107 input.search_radius = 8.5 * ModuleBase::ANGSTROM_AU;
108 input.esolver_type = "lj";
109
110 input.cal_stress = true;
111
112 input.mdp.md_restart = false;
113 input.init_vel = true;
114 input.mdp.md_dt = 1;
115 input.mdp.md_tfirst = input.mdp.md_tlast = 300;
116
117 input.mdp.lj_rcut = {8.5};
118 input.mdp.lj_epsilon = {0.01032};
119 input.mdp.lj_sigma = {3.405};
120
121 input.mdp.msst_direction = 2;
122 input.mdp.msst_qmass = 1;
123 input.mdp.msst_vel = 0;
124 input.mdp.msst_vis = 0;
125 input.mdp.msst_tscale = 0.01;
126
127 input.mdp.md_tfreq = 1;
128 input.mdp.md_tchain = 4;
129 input.mdp.md_pfreq = 1;
130 input.mdp.md_pchain = 4;
131
132 input.mdp.md_damp = 1;
133
134 input.mdp.md_nraise = 2;
135 input.mdp.md_tolerance = 0;
136 };
137
139 {
140 std::vector<LocalAtom> owned_atoms;
141 std::vector<std::string> type_labels;
142 std::vector<double> type_masses;
143 std::vector<std::int64_t> type_atom_counts;
144 for (int it = 0; it < ucell.ntype; ++it)
145 {
146 type_labels.push_back(ucell.atoms[it].label);
147 type_masses.push_back(ucell.atoms[it].mass);
148 type_atom_counts.push_back(ucell.atoms[it].na);
149 for (int ia = 0; ia < ucell.atoms[it].na; ++ia)
150 {
151 owned_atoms.push_back(LocalAtom(
152 ucell.atoms[it].tau[ia], ucell.atoms[it].taud[ia], ucell.atoms[it].vel[ia],
153 ModuleBase::Vector3<double>(0.0, 0.0, 0.0), ucell.atoms[it].mbl[ia],
154 ucell.atoms[it].mass / ModuleBase::AU_to_MASS, it, ia, 0));
155 }
156 }
157
159 mdcell.initialize_from_owned_atoms(
160 ucell.latvec, ucell.GT, ucell.lat0, ucell.omega, ucell.nat, owned_atoms, type_labels, type_masses,
161 type_atom_counts, 0.0, ModuleBase::world_comm_domain());
162 return mdcell;
163 }
164
166 {
167 const ModuleBase::Vector3<double> initial_frac[] = {ModuleBase::Vector3<double>(0.0, 0.0, 0.0),
168 ModuleBase::Vector3<double>(0.52, 0.52, 0.0), ModuleBase::Vector3<double>(0.51, 0.0, 0.5),
169 ModuleBase::Vector3<double>(0.0, 0.53, 0.5)};
170 ModuleBase::Vector3<double> displacement = atom.frac - initial_frac[atom.type_index];
171 displacement.x -= std::floor(displacement.x + 0.5);
172 displacement.y -= std::floor(displacement.y + 0.5);
173 displacement.z -= std::floor(displacement.z + 0.5);
174 return displacement;
175 }
176};
177
178#endif
Atom class for storing atom information.
Definition atom_spec.h:14
std::vector< ModuleBase::Vector3< double > > m_loc_
local magnetic moment
Definition atom_spec.h:65
int na
Number of atoms in this type.
Definition atom_spec.h:44
std::vector< double > angle2
spin angle, added by zhengdy-soc
Definition atom_spec.h:64
std::vector< ModuleBase::Vector3< double > > vel
velocities of each atom in this type
Definition atom_spec.h:56
double mass
the mass of atom
Definition atom_spec.h:27
std::string label
atomic symbol
Definition atom_spec.h:51
std::vector< ModuleBase::Vector3< double > > dis
direct displacements of each atom in this type in current step (liuyu modify 2023-03-22)
Definition atom_spec.h:53
std::vector< ModuleBase::Vector3< double > > taud
Direct coordinates of each atom in this type.
Definition atom_spec.h:54
std::vector< ModuleBase::Vector3< double > > tau
Cartesian coordinates of each atom in this type, in unit of lat0.
Definition atom_spec.h:52
std::vector< ModuleBase::Vector3< int > > mbl
whether the atoms can move or not
Definition atom_spec.h:28
std::vector< double > angle1
spin angle, added by zhengdy-soc
Definition atom_spec.h:63
Definition mdcell.h:29
double tot_mag
tot_mag : majority spin - minority spin (nelup - neldw)
Definition magnetism.h:23
Magnetism()
Constructor.
Definition magnetism.cpp:8
double abs_mag
absolute magnetic moment
Definition magnetism.h:29
~Magnetism()
Destructor.
Definition magnetism.cpp:16
double e13
Definition matrix3.h:22
Matrix3 Inverse(void) const
Inverse a 3x3 matrix.
Definition matrix3.cpp:44
double e31
Definition matrix3.h:22
double e11
element e_ij: i_row, j_column
Definition matrix3.h:22
double e33
Definition matrix3.h:22
double e32
Definition matrix3.h:22
double e21
Definition matrix3.h:22
double e12
Definition matrix3.h:22
double Det(void) const
Calculate the determinant of a 3x3 matrix.
Definition matrix3.cpp:29
double e23
Definition matrix3.h:22
double e22
Definition matrix3.h:22
Matrix3 Transpose(void) const
Transpose a 3x3 matrix.
Definition matrix3.cpp:39
3 elements vector
Definition vector3.h:21
T x
Definition vector3.h:23
T y
Definition vector3.h:24
T z
Definition vector3.h:25
Definition setcell.h:35
static void parameters(Input_para &input)
fill an Input_para with the settings the md tests share. Only the passed-in object is touched: no sou...
Definition setcell.h:105
static MDCell setup_mdcell(UnitCell &ucell)
Definition setcell.h:138
static ModuleBase::Vector3< double > fractional_displacement(const LocalAtom &atom)
Definition setcell.h:165
static void setupcell(UnitCell &ucell)
Definition setcell.h:30
Provide the basic information about unitcell.
Definition unitcell.h:16
int ntype
number of atom species in UnitCell
Definition unitcell.h:154
Atom * atoms
Definition unitcell.h:165
ModuleBase::Matrix3 & GT
Definition unitcell.h:147
double & lat0
Definition unitcell.h:135
ModuleBase::Matrix3 & latvec
Definition unitcell.h:142
bool init_vel
liuyu 2021-07-15
Definition unitcell.h:195
double & tpiba
Definition unitcell.h:137
double & tpiba2
Definition unitcell.h:138
double & omega
Definition unitcell.h:139
ModuleBase::Matrix3 & GGT
Definition unitcell.h:148
ModuleBase::Vector3< double > & a2
Definition unitcell.h:143
ModuleBase::Vector3< double > & a3
Definition unitcell.h:143
bool set_atom_flag
added on 2009-3-8 by mohan
Definition unitcell.h:215
void set_iat2itia()
Definition mock_unitcell.cpp:23
int nat
total number of atoms of all species in unitcell
Definition unitcell.h:155
ModuleBase::Matrix3 & invGGT
Definition unitcell.h:149
ModuleBase::Vector3< double > & a1
Definition unitcell.h:143
ModuleBase::Matrix3 & G
Definition unitcell.h:146
double & lat0_angstrom
Definition unitcell.h:136
const double TWO_PI
Definition constants.h:21
const double BOHR_TO_A
Definition constants.h:55
CommunicationDomain world_comm_domain()
Definition parallel_cell.cpp:152
const double AU_to_MASS
Definition constants.h:85
const double ANGSTROM_AU
Definition constants.h:64
Definition mdcell_cif_io.cpp:34
Grid_Driver class for neighbor search interface.
Definition input_parameter.h:13
Atom record owned by a distributed neighbor-search rank.
Definition local_atom.h:18
Input_para input
Definition test_io_sys_var.cpp:58