9#include <autopas/molecularDynamics/MoleculeLJ.h>
10#include <autopas/utils/SoAType.h>
11#include <autopas/utils/inBox.h>
13#include "FullMolecule.h"
21 double rz = 0.,
double vx = 0.,
double vy = 0.,
double vz = 0.,
double q0 = 1.,
22 double q1 = 1.,
double q2 = 0.,
double q3 = 0.,
double Dx = 0.,
double Dy = 0.,
32 enum AttributeNames :
int { ptr, id, posX, posY, posZ, forceX, forceY, forceZ, typeId, ownershipState };
43 double ,
double ,
double ,
double ,
44 size_t , autopas::OwnershipState >::Type;
52 template <AttributeNames attribute>
53 constexpr
typename std::tuple_element<static_cast<size_t>(attribute),
SoAArraysType>::type::value_type
get() {
54 if constexpr (attribute == AttributeNames::ptr) {
58 }
else if constexpr (attribute == AttributeNames::posX) {
60 }
else if constexpr (attribute == AttributeNames::posY) {
62 }
else if constexpr (attribute == AttributeNames::posZ) {
64 }
else if constexpr (attribute == AttributeNames::forceX) {
66 }
else if constexpr (attribute == AttributeNames::forceY) {
68 }
else if constexpr (attribute == AttributeNames::forceZ) {
70 }
else if constexpr (attribute == AttributeNames::typeId) {
72 }
else if constexpr (attribute == AttributeNames::ownershipState) {
73 return this->_ownershipState;
75 throw std::runtime_error(
"AutoPasSimpleMolecule::get() unknown attribute");
85 template <AttributeNames attribute>
87 typename std::tuple_element<
static_cast<size_t>(attribute),
SoAArraysType>::type::value_type value) {
90 }
else if constexpr (attribute == AttributeNames::posX) {
92 }
else if constexpr (attribute == AttributeNames::posY) {
94 }
else if constexpr (attribute == AttributeNames::posZ) {
96 }
else if constexpr (attribute == AttributeNames::forceX) {
98 }
else if constexpr (attribute == AttributeNames::forceY) {
100 }
else if constexpr (attribute == AttributeNames::forceZ) {
102 }
else if constexpr (attribute == AttributeNames::typeId) {
104 }
else if constexpr (attribute == AttributeNames::ownershipState) {
105 this->_ownershipState = value;
107 throw std::runtime_error(
"AutoPasSimpleMolecule::set() unknown attribute");
111 unsigned long getID()
const override {
return _id; }
113 void setid(
unsigned long id)
override { setID(
id); }
115 void setComponent(
Component* component)
override { _component = component; }
117 void setr(
unsigned short d,
double r)
override { _r[d] = r; }
119 void setv(
unsigned short d,
double v)
override { _v[d] = v; }
121 void setF(
unsigned short d,
double F)
override { _f[d] = F; }
123 Component* component()
const override {
return _component; }
125 double r(
unsigned short d)
const override {
return getR()[d]; }
127 double v(
unsigned short d)
const override {
return getV()[d]; }
129 double F(
unsigned short d)
const override {
return getF()[d]; }
131 const Quaternion& q()
const override {
return _quaternion; }
133 void setq(
Quaternion q)
override { _quaternion = q; }
135 double D(
unsigned short d)
const override {
return 0.; }
137 double M(
unsigned short d)
const override {
return 0.; }
139 double Vi(
unsigned short d)
const override {
return 0.; }
141 void setD(
unsigned short d,
double D)
override {}
143 inline void move(
int d,
double dr)
override { setr(d, r(d) + dr); }
146 double getI(
unsigned short d)
const override {
return 1.; }
148 double U_rot()
override {
return 0.; }
150 double U_rot_2()
override {
return 0.; }
152 void updateMassInertia()
override {}
154 void setupSoACache(
CellDataSoABase*
const s,
unsigned iLJ,
unsigned iC,
unsigned iD,
unsigned iQ)
override {}
158 void setStartIndexSoA_LJ(
unsigned i)
override{};
160 void setStartIndexSoA_C(
unsigned i)
override{};
162 void setStartIndexSoA_D(
unsigned i)
override{};
164 void setStartIndexSoA_Q(
unsigned i)
override{};
166 unsigned int numSites()
const override {
return 1; };
168 unsigned int numOrientedSites()
const override {
return 0; }
170 unsigned int numLJcenters()
const override {
return 1; }
172 unsigned int numCharges()
const override {
return 0; }
174 unsigned int numDipoles()
const override {
return 0; }
176 unsigned int numQuadrupoles()
const override {
return 0; }
178 std::array<double, 3> site_d(
unsigned int i)
const override {
return emptyArray3(); }
180 std::array<double, 3> ljcenter_d(
unsigned int i)
const override {
return emptyArray3(); }
182 std::array<double, 3> charge_d(
unsigned int i)
const override {
return emptyArray3(); }
184 std::array<double, 3> dipole_d(
unsigned int i)
const override {
return emptyArray3(); }
186 std::array<double, 3> quadrupole_d(
unsigned int i)
const override {
return emptyArray3(); }
188 std::array<double, 3> site_d_abs(
unsigned int i)
const override {
return getR(); }
190 std::array<double, 3> ljcenter_d_abs(
unsigned int i)
const override {
return getR(); }
192 std::array<double, 3> charge_d_abs(
unsigned int i)
const override {
return emptyArray3(); }
194 std::array<double, 3> dipole_d_abs(
unsigned int i)
const override {
return emptyArray3(); }
196 std::array<double, 3> quadrupole_d_abs(
unsigned int i)
const override {
return emptyArray3(); }
198 std::array<double, 3> dipole_e(
unsigned int i)
const override {
return emptyArray3(); }
200 std::array<double, 3> quadrupole_e(
unsigned int i)
const override {
return emptyArray3(); }
202 std::array<double, 3> site_F(
unsigned int i)
const override {
return getF(); }
204 std::array<double, 3> ljcenter_F(
unsigned int i)
const override {
return emptyArray3(); }
206 std::array<double, 3> charge_F(
unsigned int i)
const override {
return emptyArray3(); }
208 std::array<double, 3> dipole_F(
unsigned int i)
const override {
return emptyArray3(); }
210 std::array<double, 3> quadrupole_F(
unsigned int i)
const override {
return emptyArray3(); }
212 void normalizeQuaternion()
override {}
214 std::array<double, 3> computeLJcenter_d(
unsigned int i)
const override {
return emptyArray3(); }
216 std::array<double, 3> computeCharge_d(
unsigned int i)
const override {
return emptyArray3(); }
218 std::array<double, 3> computeDipole_d(
unsigned int i)
const override {
return emptyArray3(); }
220 std::array<double, 3> computeQuadrupole_d(
unsigned int i)
const override {
return emptyArray3(); }
222 std::array<double, 3> computeDipole_e(
unsigned int i)
const override {
return emptyArray3(); }
224 std::array<double, 3> computeQuadrupole_e(
unsigned int i)
const override {
return emptyArray3(); }
226 unsigned long totalMemsize()
const override {
return sizeof(*this); }
228 void setF(
double F[3])
override {
229 for (
unsigned short i = 0; i < 3; i++) _f[i] = F[i];
232 void setF(
const std::array<double, 3>& f) { autopas::Particle::setF(f); }
234 void setM(
double M[3])
override {}
236 void setVi(
double Vi[3])
override {}
238 void Fadd(
const double F[])
override {
239 for (
unsigned short i = 0; i < 3; i++) _f[i] += F[i];
242 void Madd(
const double a[])
override {}
244 void Viadd(
const double a[])
override {}
246 void vadd(
const double ax,
const double ay,
const double az)
override {
247 std::array<double, 3> addV_arr{ax, ay, az};
251 void vsub(
const double ax,
const double ay,
const double az)
override {
252 std::array<double, 3> addV_arr{-ax, -ay, -az};
256 void Fljcenteradd(
unsigned int i,
double a[])
override { vadd(a[0], a[1], a[2]); }
258 void Fljcentersub(
unsigned int i,
double a[])
override { vsub(a[0], a[1], a[2]); }
260 void Fchargeadd(
unsigned int i,
double a[])
override {}
262 void Fchargesub(
unsigned int i,
double a[])
override {}
264 void Fdipoleadd(
unsigned int i,
double a[])
override {}
266 void Fdipolesub(
unsigned int i,
double a[])
override {}
268 void Fquadrupoleadd(
unsigned int i,
double a[])
override {}
270 void Fquadrupolesub(
unsigned int i,
double a[])
override {}
273 void upd_preF(
double dt)
override;
275 void upd_postF(
double dt_halve,
double& summv2,
double& sumIw2)
override;
277 void calculate_mv2_Iw2(
double& summv2,
double& sumIw2)
override { summv2 += _component->
m() * v2(); }
279 void calculate_mv2_Iw2(
double& summv2,
double& sumIw2,
double offx,
double offy,
double offz)
override {
280 double vcx = _v[0] - offx;
281 double vcy = _v[1] - offy;
282 double vcz = _v[2] - offz;
283 summv2 += _component->
m() * (vcx * vcx + vcy * vcy + vcz * vcz);
286 static std::string getWriteFormat() {
return "IRV"; }
288 void write(std::ostream& ostrm)
const override {
289 ostrm << getID() <<
"\t" << r(0) <<
" " << r(1) <<
" " << r(2) <<
"\t" << v(0) <<
" " << v(1) <<
" " << v(2)
290 <<
"\t" << std::endl;
293 void writeBinary(std::ostream& ostrm)
const override {
294 ostrm.write(
reinterpret_cast<const char*
>(&_id), 8);
295 ostrm.write(
reinterpret_cast<const char*
>(&(_r[0])), 8);
296 ostrm.write(
reinterpret_cast<const char*
>(&(_r[1])), 8);
297 ostrm.write(
reinterpret_cast<const char*
>(&(_r[2])), 8);
298 ostrm.write(
reinterpret_cast<const char*
>(&(_v[0])), 8);
299 ostrm.write(
reinterpret_cast<const char*
>(&(_v[1])), 8);
300 ostrm.write(
reinterpret_cast<const char*
>(&(_v[2])), 8);
303 void clearFM()
override {
304 for (
unsigned short d = 0; d < 3; ++d) {
308 void calcFM()
override {}
309 void check(
unsigned long id)
override {}
315 bool inBox(
const double rmin[3],
const double rmax[3])
const override {
319 bool inBox(
const std::array<double, 3>& rmin,
const std::array<double, 3>& rmax)
const {
320 return autopas::utils::inBox(this->getR(), rmin, rmax);
323 size_t getTypeId()
const {
324 mardyn_assert(_component !=
nullptr);
325 return _component->
ID();
329 static std::array<double, 3> emptyArray3() {
331 std::array<double, 3> ret{0., 0., 0.};
Definition: AutoPasSimpleMolecule.h:18
bool inBox(const double rmin[3], const double rmax[3]) const override
test whether molecule is inside a cuboid region
Definition: AutoPasSimpleMolecule.h:315
typename autopas::utils::SoAType< AutoPasSimpleMolecule *, size_t, double, double, double, double, double, double, size_t, autopas::OwnershipState >::Type SoAArraysType
Definition: AutoPasSimpleMolecule.h:44
void buildOwnSoA() override
Definition: AutoPasSimpleMolecule.h:311
constexpr std::tuple_element< static_cast< size_t >(attribute), SoAArraysType >::type::value_type get()
Definition: AutoPasSimpleMolecule.h:53
AttributeNames
Definition: AutoPasSimpleMolecule.h:32
void releaseOwnSoA() override
Definition: AutoPasSimpleMolecule.h:313
constexpr void set(typename std::tuple_element< static_cast< size_t >(attribute), SoAArraysType >::type::value_type value)
Definition: AutoPasSimpleMolecule.h:86
Definition: CellDataSoABase.h:13
Class implementing molecules as rigid rotators consisting out of different interaction sites (LJcente...
Definition: Component.h:14
double m() const
Definition: Component.h:53
unsigned int ID() const
Definition: Component.h:33
Definition: MoleculeInterface.h:18
virtual bool inBox(const double l[3], const double u[3]) const
test whether molecule is inside a cuboid region
Definition: MoleculeInterface.h:300
Definition: Quaternion.h:10
std::ostream & operator<<(std::ostream &stream, const Vector3< type > &v)
Definition: Vector3.h:22
::xsd::cxx::tree::id< char, ncname > id
C++ type corresponding to the ID XML Schema built-in type.
Definition: vtk-punstructured.h:322
::xsd::cxx::tree::string< char, simple_type > string
C++ type corresponding to the string XML Schema built-in type.
Definition: vtk-punstructured.h:270