object_in_fluid package¶
Submodules¶
object_in_fluid.oif_classes module¶
- class object_in_fluid.oif_classes.Angle(A, B, C, D)[source]¶
Bases:
objectRepresents angles in a mesh.
- class object_in_fluid.oif_classes.FixedPoint(pos, id)[source]¶
Bases:
objectRepresents mesh points, not connected to any ESPResSo particle.
- class object_in_fluid.oif_classes.Mesh(nodes_file=None, triangles_file=None, system=None, resize=(1.0, 1.0, 1.0), particle_type=-1, particle_mass=1.0, normal=False, check_orientation=True)[source]¶
Bases:
objectRepresents a triangular mesh.
- copy(origin=None, particle_type=-1, particle_mass=1.0, rotate=None)[source]¶
Create particles in the system.
- class object_in_fluid.oif_classes.OifCell(cell_type=None, origin=None, particle_type=None, particle_mass=1.0, rotate=None)[source]¶
Bases:
objectRepresent a concrete elastic object (“cell”).
- Parameters:
cell_type (
OifCellType) – Template containing mesh nodes, triangle incidences, elasticity parameters and bond parameters, and a system, into which particles and bonds will be instantiated.particle_type (
int) – Must start at 0 for the first cell and monotonically increase for subsequent cells. Volume calculation of individual objects and interactions between objects are set up using these types.origin ((3,) array_like of
float) – Center of the cell object.particle_mass (
float) – Mass of each particle forming the cell.rotate ((3,) array_like of
float) – angles in radians, by which the cell will be rotated about the x, y, z axis. Default value is (0.0, 0.0, 0.0). Value (\(\pi/2, 0.0, 0.0\)) means that the object will be rotated by \(\pi/2\) radians clockwise around the x axis when looking in the positive direction of the axis.
- append_point_data_to_vtk(file_name=None, data_name=None, data=None, first_append=None)[source]¶
Append the specified scalar
datato a VTK file. This is useful for ParaView visualisation of local velocity magnitudes, magnitudes of forces, …, in the meshnodes and can be shown in ParaView by selecting thedata_namein the Properties toolbar. It is possible to consecutively write multiple datasets; for the first one, thefirst_appendparameter is set toTrue, for the following datasets, it needs to be set toFalse. This is to ensure the proper structure of the output file.
- diameter()[source]¶
Compute the maximal pairwise distance between all mesh points. Computational complexity is \(\mathcal{O}(N^2)\).
- elastic_forces(el_forces=(0, 0, 0, 0, 0, 0), f_metric=(0, 0, 0, 0, 0, 0), vtk_file=None, raw_data_file=None)[source]¶
This method can be used in two different ways. One is to compute the elastic forces locally for each mesh point, and the other is to compute the f-metric, which is an approximation of elastic energy.
To compute the elastic forces, use the vector
el_forces. It is a sextuple of zeros and ones, e.g.el_forces = (1,0,0,1,0,0), where the ones denote the elastic forces to be computed. The order is (stretching, bending, local area, global area, volume, total). The output can be saved in two different ways: either by settingvtk_file = filename.vtk, which saves a VTK file that can be visualized using ParaView. If more than one elastic force was selected, they can be chosen in the Properties window in ParaView. The other type of output israw_data_file*=filename.dat, which will save a datafile with the selected type of elastic force - one force per row, where each row corresponds to a single mesh node. Note that only one type of elastic force can be written this way at a time. Thus, if you need output for several elastic forces, this method should be called several times.To compute the f-metric, use the vector
f_metric. It is also a sextuple of zeros and ones, e.g.f_metric = (1,1,0,0,0,0), where the ones denote the elastic forces to be computed. The order is (stretching, bending, local area, global area, volume, total). The output is also a vector with six elements, each corresponding to the requested f-metric/”naive energy” computed as a sum of magnitudes of respective elastic forces over all mesh points.
- get_approx_origin()[source]¶
Get the approximate location of the cell center. It is computed as average of 6 mesh points that have extremal x, y and z coordinates at the time of object loading.
- output_mesh_points(file_name=None)[source]¶
Write the positions of the mesh points to a white-space delimited text file. This file can later be read by
set_mesh_points(). The center of the object is located at (0.0, 0.0, 0.0). This method is meant to store a deformed shape in order to be loaded later as a new shape template.
- output_raw_data(file_name=None, data=None)[source]¶
Write the vector or matrix
rawdatato a white-space delimited text file. The rows are ordered by the mesh points indices.
- output_vtk_pos(file_name=None)[source]¶
Write the mesh information to a VTK file in unfolded coordinates. ParaView can directly visualize this file.
- output_vtk_pos_folded(file_name=None)[source]¶
Write the mesh information to a VTK file in folded coordinates. ParaView can directly visualize this file.
- pos_bounds()[source]¶
Compute six extremal coordinates of the cell. More precisely, run through all mesh points and return the minimal and maximal \(x\)-coordinate, \(y\)-coordinate and \(z\)-coordinate in the order (\(x_{max}\), \(x_{min}\), \(y_{max}\), \(y_{min}\), \(z_{max}\), \(z_{min}\)).
- set_force(new_force=(0.0, 0.0, 0.0))[source]¶
Set an external force to all mesh points. Note, that this command sets the external force in each integration step. So if you want to use the external force only in one iteration, you need to set zero external force in the following integration step.
- set_mesh_points(file_name=None)[source]¶
Read a file containing a list of mesh point coordinates to deform the current cell. The current origin stays unchanged. The file should contain the coordinates of the mesh points with the origin location at (0.0, 0.0, 0.0). It can be generated by
output_mesh_points().
- class object_in_fluid.oif_classes.OifCellType(nodes_file='', triangles_file='', system=None, resize=(1.0, 1.0, 1.0), ks=0.0, kslin=0.0, kb=0.0, kal=0.0, kag=0.0, kv=0.0, kvisc=0.0, normal=False, check_orientation=True)[source]¶
Bases:
objectTemplate to create elastic objects (“cells”) from a mesh file.
The switches
ks,kbandkalset elastic parameters for local interactions:ksfor edge stiffness,kbfor angle preservation stiffness andkalfor triangle area preservation stiffness. Currently, the stiffness is implemented to be uniform over the whole object, but with some tweaking, it is possible to have non-uniform local interactions. At least one of the elastic moduli should be set.Note the difference between stretching (
ks) and linear stretching (kslin): these two options cannot be used simultaneously. Linear stretching behaves like linear spring, where the stretching force is calculated as \(\mathbf{f_{ij}} = k_s \mathbf{d_{ij}}\), where \(\mathbf{d_{ij}}\) is the prolongation of the given edge. By default, the stretching is non-linear (neo-Hookean). The optional viscous damping (kvisc) is meant to reduce oscillations in the stretching force. This corresponds to the case \(\gamma^T = 0\) and \(\gamma^C = k_{\mathrm{visc}}\) in equation 8 of [Fedosov et al., 2010] (which uses the \(\times\) symbol for the dot product).- Parameters:
nodes_file (
str) – Path to the mesh data file. Each line contains three real numbers. These are the x, y, z coordinates of individual surface mesh nodes of the objects centered at [0,0,0] and normalized so that the “radius” of the object is 1.triangles_file (
str) – Path to the triangles data file. Each line contains three integers representing the 0-indexed line number of the mesh nodes innodes_filethat form a triangle.system (
espressomd.system.System) – System in which particles will be created.ks (
float) – Elastic modulus for stretching forces.kslin (
float) – Elastic modulus for linear stretching forces.kb (
float) – Elastic modulus for bending forces.kal (
float) – Elastic modulus for local area forces.kvisc (
float) – Viscous damping for stretching forces.kag (
float) – Elastic modulus for global area forces.kv (
float) – Elastic modulus for volume forces.resize ((3,) array_like of
float) – Scaling factor by which the coordinates stored innodes_filewill be stretched in the x, y, z directions.normal (
bool) – IfTrue, create list of neighbors to allow membrane collisions, and thus cell-cell interactions.check_orientation (
bool) – IfTrue, check whethertriangles_filecontains triangles with correct orientation. If not, it corrects the orientation and created cells with corrected triangles. It is useful for new or unknown meshes, but not necessary for meshes that have already been tried out. Since it can take a few minutes for larger meshes (with thousands of nodes), it can be set toFalse. In that case, the check is skipped when creating theCellTypeand a warning is displayed.The order of indices in
triangles_fileis important. Normally, each triangle ABC should be oriented in such a way, that the normal vector computed as vector product ABxAC must point inside the object. For example, a sphere (or any other sufficiently convex object) contains such triangles that the normals of these triangles point towards the center of the sphere (almost).The check runs over all triangles, makes sure that they have the correct orientation and then calculates the volume of the object. If the result is negative, it flips the orientation of all triangles.
Note, this method tells the user about the correction it makes. If there is any, it might be useful to save the corrected triangulation for future simulations using the method
Mesh.output_mesh_triangles(), so that the check does not have to be used repeatedly.
- class object_in_fluid.oif_classes.PartPoint(part, id, part_id)[source]¶
Bases:
objectRepresents mesh points, connected to ESPResSo particle.
object_in_fluid.oif_utils module¶
- object_in_fluid.oif_utils.angle_btw_triangles(P1, P2, P3, P4)[source]¶
Returns the size of an angle between triangles given by points P2, P1, P3 and P2, P3, P4 that share a common edge P2, P3.
- Parameters:
P1 ((3,) array_like of
float) – Point P1P2 ((3,) array_like of
float) – Point P2P3 ((3,) array_like of
float) – Point P3P4 ((3,) array_like of
float) – Point P4
- object_in_fluid.oif_utils.area_triangle(a, b, c)[source]¶
Returns the area of a triangle given by points a, b, c.
- Parameters:
a ((3,) array_like of
float) – Point ab ((3,) array_like of
float) – Point bc ((3,) array_like of
float) – Point c
- object_in_fluid.oif_utils.discard_epsilon(x)[source]¶
Returns zero if the argument is too small.
- Parameters:
x (
float) – real number
- object_in_fluid.oif_utils.get_triangle_normal(a, b, c)[source]¶
Returns the normal vector of a triangle given by points a,b,c.
- Parameters:
a ((3,) array_like of
float) – Point ab ((3,) array_like of
float) – Point bc ((3,) array_like of
float) – Point c
- object_in_fluid.oif_utils.norm(vect)[source]¶
Returns the norm of a vector.
- Parameters:
vect ((3,) array_like of
float) – Input vector
- object_in_fluid.oif_utils.oif_calc_bending_force(kb, pA, pB, pC, pD, phi0, phi)[source]¶
Calculates bending forces for four points on two adjacent triangles.
- Parameters:
kb (
float) – coefficient of the stretching, spring stiffnesspA ((3,) array_like of
float) – position of the first particlepB ((3,) array_like of
float) – position of the second particlepC ((3,) array_like of
float) – position of the third particlepD ((3,) array_like of
float) – position of the fourth particlephi0 (
float) – relaxed angle btw two trianglesphi (
float) – current angle btw two triangles
- object_in_fluid.oif_utils.oif_calc_global_area_force(kag, pA, pB, pC, Ag0, Ag)[source]¶
Calculates global area forces between three points in a triangle.
- Parameters:
kag (
float) – coefficient of the stretching, spring stiffnesspA ((3,) array_like of
float) – position of the first particlepB ((3,) array_like of
float) – position of the second particlepC ((3,) array_like of
float) – position of the third particleAg0 (
float) – relaxed surface area of the cellAg (
float) – current surface area of the cell
- object_in_fluid.oif_utils.oif_calc_linear_stretching_force(ks, pA, pB, dist0, dist)[source]¶
Calculates linear stretching forces between two points on an edge.
- Parameters:
ks (
float) – coefficient of the stretching, spring stiffnesspA ((3,) array_like of
float) – position of the first particlepB ((3,) array_like of
float) – position of the second particledist0 (
float) – relaxed distance btw particlesdist (
float) – current distance btw particles
- object_in_fluid.oif_utils.oif_calc_local_area_force(kal, pA, pB, pC, A0, A)[source]¶
Calculates local area forces between three points in one triangle.
- Parameters:
kal (
float) – coefficient of the stretching, spring stiffnesspA ((3,) array_like of
float) – position of the first particlepB ((3,) array_like of
float) – position of the second particlepC ((3,) array_like of
float) – position of the third particleA0 (
float) – relaxed area of the triangleA (
float) – current area of the triangle
- object_in_fluid.oif_utils.oif_calc_stretching_force(ks, pA, pB, dist0, dist)[source]¶
Calculates nonlinear stretching forces between two points on an edge.
- Parameters:
ks (
float) – coefficient of the stretching, spring stiffnesspA ((3,) array_like of
float) – position of the first particlepB ((3,) array_like of
float) – position of the second particledist0 (
float) – relaxed distance btw particlesdist (
float) – current distance btw particles
- object_in_fluid.oif_utils.oif_calc_volume_force(kv, pA, pB, pC, V0, V)[source]¶
Calculates volume forces for three points in a triangle.
- Parameters:
kv (
float) – coefficient of the stretching, spring stiffnesspA ((3,) array_like of
float) – position of the first particlepB ((3,) array_like of
float) – position of the second particlepC ((3,) array_like of
float) – position of the third particleV0 (
float) – relaxed volume of the cellV (
float) – current volume of the cell
- object_in_fluid.oif_utils.oif_neo_hookean_nonlin(lambd)[source]¶
Defines neo-Hookean non-linear factor (equation 19 in [Dupin et al., 2007]).
- Parameters:
lambd (
float) – real number
- object_in_fluid.oif_utils.output_vtk_cylinder(cyl_shape, n, out_file)[source]¶
Outputs the VTK files for visualisation of a cylinder in e.g. ParaView.
- Parameters:
cyl_shape (
espressomd.shapes.Cylinder) – cylindrical shapen (
int) – number of discretization sectionsout_file (
str) – filename for the output
- object_in_fluid.oif_utils.output_vtk_lines(lines, out_file)[source]¶
Outputs the VTK files for visualisation of lines in e.g. ParaView.
- Parameters:
lines (array_like
float) – lines is a list of pairs of points p1, p2 each pair represents a line segment to output to vtk each line in lines contains 6 floats: p1x, p1y, p1z, p2x, p2y, p2zout_file (
str) – filename for the output
- object_in_fluid.oif_utils.output_vtk_pore(axis, length, outer_rad_left, outer_rad_right, pos, rad_left, rad_right, smoothing_radius, m, out_file)[source]¶
Outputs the VTK files for visualisation of a pore in e.g. ParaView.
- Parameters:
axis ((3,) array_like of
float) – The axislength (
float) – length of poreouter_rad_left (
float) – outer left radius of poreouter_rad_right (
float) – outer right radius of porerad_left (
float) – inner left radius of porerad_right (
float) – inner right radius of poresmoothing_radius (
float) – smoothing radius for surface connecting outer and inner radii of the porepos ((3,) array_like of
float) – Position of the center of the porem (
int) – number of discretization sectionsout_file (
str) – filename for the output
- object_in_fluid.oif_utils.output_vtk_rhomboid(rhom_shape, out_file)[source]¶
Outputs the VTK files for visualisation of a rhomboid in e.g. ParaView.
- Parameters:
rhom_shape (
espressomd.shapes.Rhomboid) – rhomboid shapeout_file (
str) – filename for the output