Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Particle property getters #4473

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
52 changes: 1 addition & 51 deletions src/core/particle_data.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -373,32 +373,6 @@ int number_of_particles_with_type(int type);
// This is needed, because cython does not support conditional compilation
// within a ctypedef definition

#ifdef LB_ELECTROHYDRODYNAMICS
inline Utils::Vector3d get_particle_mu_E(Particle const *p) {
return p->mu_E();
}
#endif

#ifdef ROTATION
inline Utils::Vector3d get_particle_omega_body(Particle const *p) {
return p->omega();
}

inline Utils::Vector3d get_particle_torque_body(Particle const *p) {
return p->torque();
}

inline Utils::Quaternion<double> get_particle_quat(Particle const *p) {
return p->quat();
}
#endif

inline double get_particle_q(Particle const *p) { return p->q(); }

#ifdef VIRTUAL_SITES
inline bool get_particle_virtual(Particle const *p) { return p->is_virtual(); }
#endif

#ifdef VIRTUAL_SITES_RELATIVE
inline Utils::Quaternion<double> get_particle_vs_quat(Particle const *p) {
return p->vs_relative().quat;
Expand All @@ -412,19 +386,7 @@ inline Utils::Quaternion<double> get_particle_vs_relative(Particle const *p,
}
#endif

#ifdef DIPOLES
inline double get_particle_dipm(Particle const *p) { return p->dipm(); }
#endif

#ifdef EXTERNAL_FORCES
inline Utils::Vector3d get_particle_ext_force(Particle const *p) {
return p->ext_force();
}
#ifdef ROTATION
inline Utils::Vector3d get_particle_ext_torque(Particle const *p) {
return p->ext_torque();
}
#endif
inline Utils::Vector3i get_particle_fix(Particle const *p) {
return Utils::Vector3i{
{p->is_fixed_along(0), p->is_fixed_along(1), p->is_fixed_along(2)}};
Expand Down Expand Up @@ -452,24 +414,12 @@ inline double get_particle_gamma_rot(Particle const *p) {
#endif // ROTATION
#endif // THERMOSTAT_PER_PARTICLE

#ifdef ENGINE
inline ParticleParametersSwimming get_particle_swimming(Particle const *p) {
return p->swimming();
}
#endif

#ifdef ROTATIONAL_INERTIA
inline Utils::Vector3d get_particle_rotational_inertia(Particle const *p) {
return p->rinertia();
}
#endif

#ifdef ROTATION
inline Utils::Vector3i get_particle_rotation(Particle const *p) {
return Utils::Vector3i{{p->can_rotate_around(0), p->can_rotate_around(1),
p->can_rotate_around(2)}};
}
#endif
#endif // ROTATION

/**
* @brief Check if particle exists.
Expand Down
78 changes: 32 additions & 46 deletions src/python/espressomd/particle_data.pxd
Original file line number Diff line number Diff line change
Expand Up @@ -25,53 +25,51 @@ include "myconfig.pxi"

from .utils cimport Span


# Import particle data structures and setter functions from particle_data.hpp
cdef extern from "particle_data.hpp":
cppclass BondView:
int bond_id()
Span[const int] partner_ids()

ctypedef struct particle_parameters_swimming "ParticleParametersSwimming":
bool swimming
double f_swim
double v_swim
int push_pull
double dipole_length

# Note: Conditional compilation is not possible within ctypedef blocks.
# Therefore, only member variables are imported here, which are always compiled into ESPResSo.
# For all other properties, getter-functions have to be used on the c
# level.
ctypedef struct particle_properties "ParticleProperties":
int identity
int mol_id
int type
double mass

ctypedef struct particle_position "ParticlePosition":
Vector3d p
Vector3d calc_director()

ctypedef struct particle_force "ParticleForce":
Vector3d f

ctypedef struct particle_momentum "ParticleMomentum":
Vector3d v

ctypedef struct particle_local "ParticleLocal":
Vector3i i
double lees_edwards_offset
int lees_edwards_flag
# level.

ctypedef struct particle "Particle":
particle_properties p
particle_position r
particle_momentum m
particle_force f
particle_local l
vector[int] exclusions() except +
Vector3d calc_dip()

IF ENGINE:
ctypedef struct particle_parameters_swimming "ParticleParametersSwimming":
bool swimming
double f_swim
double v_swim
int push_pull
double dipole_length
int type()
int identity()
double mass()
int mol_id()
Vector3d pos()
Vector3d calc_director()
Vector3d force()
Vector3d v()
Vector3i image_box()
double lees_edwards_offset()
int lees_edwards_flag()

Vector3d rinertia()
Vector3d mu_E()
double q()
Vector3d omega()
Vector3d torque()
Quaternion[double] quat()
double dipm()
bint is_virtual()
Vector3d ext_force()
Vector3d ext_torque()
particle_parameters_swimming swimming()

# Setter/getter/modifier functions functions
void prefetch_particle_data(vector[int] ids)
Expand All @@ -88,7 +86,6 @@ cdef extern from "particle_data.hpp":

IF ROTATIONAL_INERTIA:
void set_particle_rotational_inertia(int part, const Vector3d & rinertia)
Vector3d get_particle_rotational_inertia(const particle * p)

IF ROTATION:
void set_particle_rotation(int part, const Vector3i & flag)
Expand All @@ -98,30 +95,24 @@ cdef extern from "particle_data.hpp":

IF LB_ELECTROHYDRODYNAMICS:
void set_particle_mu_E(int part, const Vector3d & mu_E)
Vector3d get_particle_mu_E(const particle * p)

void set_particle_type(int part, int type)

void set_particle_mol_id(int part, int mid)

IF ROTATION:
void set_particle_quat(int part, const Quaternion[double] & quat)
Quaternion[double] get_particle_quat(const particle * p)
void set_particle_director(int part, const Vector3d & director)
void set_particle_omega_lab(int part, const Vector3d & omega)
void set_particle_omega_body(int part, const Vector3d & omega)
void set_particle_torque_lab(int part, const Vector3d & torque)
Vector3d get_particle_omega_body(const particle * p)
Vector3d get_particle_torque_body(const particle * p)

IF DIPOLES:
void set_particle_dip(int part, const Vector3d & dip)
void set_particle_dipm(int part, double dipm)
double get_particle_dipm(const particle * p)

IF VIRTUAL_SITES:
void set_particle_virtual(int part, int isVirtual)
bint get_particle_virtual(const particle * p)

IF THERMOSTAT_PER_PARTICLE:
IF PARTICLE_ANISOTROPY:
Expand All @@ -145,15 +136,11 @@ cdef extern from "particle_data.hpp":
void set_particle_vs_relative(int part, int vs_relative_to, double vs_distance, const Quaternion[double] & rel_ori)
void set_particle_vs_quat(int part, const Quaternion[double] & vs_quat)

double get_particle_q(const particle * p)

IF EXTERNAL_FORCES:
IF ROTATION:
void set_particle_ext_torque(int part, const Vector3d & torque)
Vector3d get_particle_ext_torque(const particle * p)

void set_particle_ext_force(int part, const Vector3d & force)
Vector3d get_particle_ext_force(const particle * p)

void set_particle_fix(int part, const Vector3i & flag)
Vector3i get_particle_fix(const particle * p)
Expand All @@ -168,7 +155,6 @@ cdef extern from "particle_data.hpp":

IF ENGINE:
void set_particle_swimming(int part, particle_parameters_swimming swim)
particle_parameters_swimming get_particle_swimming(const particle * p)

int remove_particle(int part) except +

Expand Down
Loading