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

Fix TypeError in System.number_of_particles() #3536

Merged
merged 2 commits into from
Feb 23, 2020
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
1 change: 0 additions & 1 deletion src/core/grid_based_algorithms/electrokinetics.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,6 @@ void ek_calculate_electrostatic_coupling();
int ek_set_bulk_viscosity(double bulk_viscosity);
int ek_set_gamma_odd(double gamma_odd);
int ek_set_gamma_even(double gamma_even);
int ek_set_lb_force_density(double *ext_force_density);
int ek_set_density(int species, double density);
int ek_set_D(int species, double D);
int ek_set_valency(int species, double valency);
Expand Down
7 changes: 0 additions & 7 deletions src/python/espressomd/electrokinetics.pxd
Original file line number Diff line number Diff line change
Expand Up @@ -79,10 +79,8 @@ IF ELECTROKINETICS and CUDA:
cdef extern EK_parameters ek_parameters

# EK functions
void ek_integrate()
void ek_print_parameters()
void ek_print_lbpar()
void lb_set_ek_pointer(EK_parameters * pointeradress)
unsigned int ek_calculate_boundary_mass()
int ek_print_vtk_density(int species, char * filename)
int ek_print_vtk_flux(int species, char * filename)
Expand All @@ -102,7 +100,6 @@ IF ELECTROKINETICS and CUDA:
int ek_set_bulk_viscosity(double bulk_viscosity)
int ek_set_gamma_odd(double gamma_odd)
int ek_set_gamma_even(double gamma_even)
int ek_set_lb_force_density(double * ext_force_density)
int ek_set_density(int species, double density)
int ek_set_D(int species, double D)
int ek_set_valency(int species, double valency)
Expand All @@ -123,8 +120,4 @@ IF ELECTROKINETICS and CUDA:
int ek_load_checkpoint(char * filename)

int ek_set_electrostatics_coupling(bool electrostatics_coupling)
void ek_calculate_electrostatic_coupling()
int ek_print_vtk_particle_potential(char * filename)

IF EK_BOUNDARIES:
void ek_init_species_density_wallcharge(ekfloat * wallcharge_species_density, int wallcharge_species)
4 changes: 0 additions & 4 deletions src/python/espressomd/electrostatics.pxd
Original file line number Diff line number Diff line change
Expand Up @@ -210,9 +210,6 @@ IF ELECTROSTATICS:
int MMM1D_sanity_checks()
int mmm1d_tune(char ** log)

cdef extern from "nonbonded_interactions/nonbonded_interaction_data.hpp":
int coulomb_set_prefactor(double prefactor)

cdef inline pyMMM1D_tune():
cdef char * log = NULL
cdef int resp
Expand Down Expand Up @@ -254,6 +251,5 @@ IF ELECTROSTATICS and MMM1D_GPU:

float force_benchmark(SystemInterface & s)

void check_periodicity()
void activate()
void deactivate()
1 change: 0 additions & 1 deletion src/python/espressomd/lb.pxd
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,6 @@ cdef extern from "grid_based_algorithms/lb_interface.hpp":
void lb_lbfluid_save_checkpoint(string filename, int binary) except +
void lb_lbfluid_load_checkpoint(string filename, int binary) except +
void lb_lbfluid_set_lattice_switch(ActiveLB local_lattice_switch) except +
ActiveLB lb_lbfluid_get_lattice_switch() except +
Vector6d lb_lbfluid_get_stress() except +
bool lb_lbnode_is_index_valid(const Vector3i & ind) except +
Vector3i lb_lbfluid_get_shape() except +
Expand Down
6 changes: 0 additions & 6 deletions src/python/espressomd/particle_data.pxd
Original file line number Diff line number Diff line change
Expand Up @@ -83,8 +83,6 @@ cdef extern from "particle_data.hpp":

void set_particle_f(int part, const Vector3d & F)

void set_particle_solvation(int part, double * solvation)

IF ROTATION:
void set_particle_rotation(int part, int rot)

Expand Down Expand Up @@ -114,13 +112,9 @@ cdef extern from "particle_data.hpp":
void set_particle_omega_lab(int part, Vector3d omega)
void set_particle_omega_body(int part, Vector3d omega)
void set_particle_torque_lab(int part, Vector3d torque)
void set_particle_torque_body(int part, Vector3d torque)
void pointer_to_omega_body(const particle * p, const double * & res)
Vector3d get_torque_body(const particle p)

IF MASS:
void pointer_to_mass(particle * p, double * & res)

IF DIPOLES:
void set_particle_dip(int part, double dip[3])

Expand Down
1 change: 0 additions & 1 deletion src/python/espressomd/script_interface.pxd
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@ cdef extern from "ScriptInterface.hpp" namespace "ScriptInterface":
Variant()
Variant(const Variant & )
Variant & operator = (const Variant &)
int which()

bool is_type[T](const Variant &)
bool is_none(const Variant &)
Expand Down
20 changes: 4 additions & 16 deletions src/python/espressomd/system.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,6 @@ from . import particle_data
from . import cuda_init
from . import code_info
from .utils cimport make_array_locked, make_Vector3d, Vector3d
from .lb cimport lb_lbfluid_get_tau
from .lb cimport lb_lbfluid_get_lattice_switch
from .lb cimport NONE
from .thermostat import Thermostat
from .cellsystem import CellSystem
from .analyze import Analysis
Expand All @@ -47,9 +44,9 @@ if LB_BOUNDARIES or LB_BOUNDARIES_GPU:
from .comfixed import ComFixed
from .globals import Globals
from .globals cimport FIELD_SIMTIME, FIELD_MAX_OIF_OBJECTS
from .globals cimport max_seen_particle_type, integ_switch, max_oif_objects, sim_time
from .globals cimport integ_switch, max_oif_objects, sim_time
from .globals cimport recalc_maximal_cutoff_bonded, recalc_maximal_cutoff_nonbonded, mpi_bcast_parameter
from .utils cimport handle_errors
from .utils cimport handle_errors, check_type_or_throw_except
IF VIRTUAL_SITES:
from .virtual_sites import ActiveVirtualSitesHandle, VirtualSitesOff

Expand Down Expand Up @@ -395,15 +392,6 @@ cdef class System:
"""
auto_exclusions(distance)

def _is_valid_type(self, current_type):
return not (isinstance(current_type, int)
or current_type < 0
or current_type > max_seen_particle_type)

def check_valid_type(self, current_type):
if self._is_valid_type(current_type):
raise ValueError("type", current_type, "does not exist!")

def setup_type_map(self, type_list=None):
"""
For using ESPResSo conveniently for simulations in the grand canonical
Expand All @@ -425,7 +413,7 @@ cdef class System:
"""
Parameters
----------
current_type : :obj:`int` (:attr:`~espressomd.particle_data.ParticleHandle.type`)
type : :obj:`int` (:attr:`~espressomd.particle_data.ParticleHandle.type`)
Particle type to count the number for.

Returns
Expand All @@ -434,7 +422,7 @@ cdef class System:
The number of particles which have the given type.

"""
self.check_valid_type(type)
check_type_or_throw_except(type, 1, int, "type must be 1 int")
number = number_of_particles_with_type(type)
handle_errors("")
return int(number)