proteus.mbd.CouplingFSI module
Coupling between Chrono and Proteus is done in this file.
Objects (classes) starting with ‘ProtCh’ (e.g. ProtChBody) are objects that have logic specifically developed for communication between Proteus and Chrono.
Objects starting with ‘Ch’ (e.g. ChBody) are objects that only have Chrono logic associated to them.
Some ProtCh objects give access to the Chrono object: my_protchsystem = ProtChSystem() my_protchbody = ProtChBody(system=my_protchsystem) my_chbody = my_protchbody.ChBody my_chbody.SetPos(…) my_chbody.SetRot(…)
# pass the index of the boundaries (or particle index) where forces must be integrated my_protchbody.setIndexBoundary([0, 1, 2, 3]) # alternatively, if you use a Shape instance from proteus.SpatialTools # the boundaries indice will be set automatically after calling SpatialTools.assembleDomain() my_protchbody.setShape(my_shape)
- class proteus.mbd.CouplingFSI.ProtChSystem[source]
Bases:
object
- addSubcomponent(self, subcomponent)[source]
Adds subcomponent to system calculate_init() of subcomponent called before initial timestep prestep() and poststep of subcomponent() called at all timestep
- Parameters
subcomponent (class instance) – class instance of subcomponent
- calculate(self, proteus_dt=None)[source]
Does chrono system calculation for a Proteus time step Calls prestep and poststep on all subcomponents (bodies, moorings, etc) attached to the system.
- Parameters
proteus_dt (Optional[proteus_dt]) – Manually sets a time step. The time step is set automatically when coupled with a Proteus simulation
- calculate_init(self)[source]
Does chrono system initialisation (!) Must be called before the first calculate() call. Calls calculate_init and poststep on all subcomponents (bodies, moorings, etc) attached to the system.
- findElementContainingCoordsDist(self, coords, node_guess, eN_guess, rank_guess)[source]
Distance search of nearest node, element containing coords, and owning rank.
- Parameters
- Returns
xi – local coordinates
node (int) – nearest node
eN (int) – (local) element number
rank (int) – processor rank containing element
- findElementContainingCoordsKD(self, coords)[source]
k-d tree search of nearest node, element containing coords, and owning rank.
- Parameters
coords (array_like) – global coordinates to look for
- Returns
xi – local coordinates
node (int) – nearest node
eN (int) – (local) element number
rank (int) – processor rank containing element
- log_bodies_h5(self, l_logging_info)[source]
Logs the chrono information into a h5 file at each timestep :param self: ProtChSystem being referenced :type self: object :param l_logging_info: Contains the information to be logged. Structure is [body number, type]
with multiple entries being included as a 2d list. Valid types are ‘position’, ‘rotation’, ‘force’, and ‘torque’.
- Return type
None. Data is saved to an h5 file.
- log_bodies_text(self, d_time, l_logging_info)[source]
- Logs the chrono information into a text file at each timestep
Parameters
- self: object
ProtChSystem being referenced
- d_time: float
Simulation time
- l_logging_info: list
Contains the information to be logged. Structure is [body number, type] with multiple entries being included as a 2d list. Valid types are ‘position’, ‘rotation’, ‘force’, and ‘torque’.
- Return type
None. Data is logged to a text file
- log_residuals_h5(self, l_linklocks)[source]
Logs chrono spring information to an h5 file :param self: ProtChSystem object being referenced. :type self: object :param l_linklocks: Link lock objects for which the residual information is desired. :type l_linklocks: list
- Return type
None. Data is logged to an h5 file.
- log_residuals_text(self, d_time, l_linklocks)[source]
Logs the chrono information into a text file at each timestep :param self: ProtChSystem being referenced :type self: object :param d_time: Current simulation time :type d_time: float :param l_linklocks: Link lock objects for which the residual information is desired. :type l_linklocks: list
- Return type
None. Data is saved to a text file.
- log_springs_h5(self, l_springs)[source]
Logs chrono spring information to an h5 file :param self: ProtChSystem object being referenced. :type self: object :param l_springs: Spring objects for which the data is being logged :type l_springs: list
- Return type
None. Data is logged to an h5 file.
- log_springs_text(self, d_time, l_springs)[source]
Logs the chrono information into a text file at each timestep :param self: ProtChSystem being referenced :type self: object :param d_time: Current simulation time :type d_time: float :param l_springs: Spring objects for which data is being stored :type l_springs: list
- Return type
None. Data is saved to a text file.
- log_times_h5(self, d_time)[source]
Creates a log of the Proteus timestep within the h5 log file :param self: ProtChSystem being referenced :type self: object :param d_time: Time within the simulation :type d_time: float
- Return type
None. Data is logged to the disk.
- setMinimumSubsteps(self, int nb)[source]
Sets the minimum nb of chrono substeps per proteus step if prot_dt=0.001 and ch_dt=0.002, there will be <nb> substeps of chrono instead of just 1.
- Parameters
nb (int) – Minimum number of chrono substeps.
- setTimeStep(self, double dt)[source]
Sets time step for Chrono solver. Calculations in Chrono will use this time step within the Proteus time step (if bigger) :param dt: Chrono time step size :type dt: float
- class proteus.mbd.CouplingFSI.ProtChBody[source]
Bases:
object
- addPrismaticLinksWithSpring(self, ndarray pris1, ndarray pris2, double stiffness, double damping, double rest_length)[source]
fairlead: barycenter coords pris: absolute coords pris1——-fairlead(barycenter) | | | | pris2
- addSpring(self, double stiffness, double damping, ndarray fairlead, ndarray anchor, double rest_length)[source]
- addTriangleMeshFromShape(self, shape=None, double[:] pos=None, double[:, :] rot=None, bool is_static=False, bool is_convex=False, double sphereswept_thickness=0.005)[source]
Adds triangle mesh to collision model and for IBM calculations
- attachShape(self, shape, take_shape_name=True)[source]
Attach proteus.SpatialTools shape to body. Used for automatic calculation of external forces from Proteus. Called automatically when creating a body and passing a shape instance.
- Parameters
shape (SpatialTools.Shape) – instance of shape from proteus.SpatialTools or proteus.mprans.SpatialTools
- calculate_init(self)[source]
Called from self.ProtChSystem.calculate_init() before simulation starts
- getMoments(self)[source]
Gives moments from fluid (Proteus) acting on body (!) Only works during proteus simulation
- Returns
M – moments (x, y, z) as provided by Proteus
- Return type
array_like
- getPressureForces(self)[source]
Gives pressure forces from fluid (Proteus) acting on body. (!) Only works during proteus simulation
- Returns
F_p – pressure forces (x, y, z) as provided by Proteus
- Return type
array_like
- getRotationMatrix(self)[source]
Gives current rotation (matrix) of body
- Returns
rot – current rotation (matrix) of body
- Return type
array_like
- getShearForces(self)[source]
Gives shear forces from fluid (Proteus) acting on body (!) Only works during proteus simulation
- Returns
F_v – shear forces (x, y, z) as provided by Proteus
- Return type
array_like
- hx(self, ndarray x, double t)[source]
BC function for mesh nodes displacement (x component)
- Parameters
x (array_like) – coordinates of the node before displacement
t (double) – simulation time
- hx_rotation(self, ndarray x, double t)[source]
BC function for mesh nodes displacement (x component)
- Parameters
x (array_like) – coordinates of the node before displacement
t (double) – simulation time
- hx_translation(self, ndarray x, double t)[source]
BC function for mesh nodes displacement (x component)
- Parameters
x (array_like) – coordinates of the node before displacement
t (double) – simulation time
- hy(self, ndarray x, double t)[source]
BC function for mesh nodes displacement (y component)
- Parameters
x (array_like) – coordinates of the node before displacement
t (double) – simulation time
- hy_rotation(self, ndarray x, double t)[source]
BC function for mesh nodes displacement (y component)
- Parameters
x (array_like) – coordinates of the node before displacement
t (double) – simulation time
- hy_translation(self, ndarray x, double t)[source]
BC function for mesh nodes displacement (y component)
- Parameters
x (array_like) – coordinates of the node before displacement
t (double) – simulation time
- hz(self, ndarray x, double t)[source]
BC function for mesh nodes displacement (z component)
- Parameters
x (array_like) – coordinates of the node before displacement
t (double) – simulation time
- hz_rotation(self, ndarray x, double t)[source]
BC function for mesh nodes displacement (z component)
- Parameters
x (array_like) – coordinates of the node before displacement
t (double) – simulation time
- hz_translation(self, ndarray x, double t)[source]
BC function for mesh nodes displacement (z component)
- Parameters
x (array_like) – coordinates of the node before displacement
t (double) – simulation time
- poststep(self)[source]
Called after Chrono system step. Records values to csv, broadcast new position and rotation from calculating processor to all processors for moving mesh BC.
- prestep(self)[source]
Called before Chrono system step. Sets external forces automatically from Proteus solution.
- setAddedMass(self, ndarray Aij)[source]
Sets the added mass matrix of the body
- Parameters
added_mass (array_like) – Added mass matrix (must be 6x6 array!)
- setBoundaryFlags(self, flags)[source]
Sets the flags of the boundaries of the body numbers must be gloabal (from domain.segmentFlags or domain.facetFlags).
- Parameters
flags (array_like) – list of flags that belong to this body
- setConstraints(self, ndarray free_x, ndarray free_r)[source]
Sets constraints on the body (!) Only acts on Proteus and gravity forces
- Parameters
free_x (array_like) – Translational constraints.
free_r (array_like) – Rotational constraints.
- setExternalForces(self, ndarray forces=None, ndarray moments=None)[source]
Sets external forces to body. Called during prestep or can be called manually. If called manually, must be a Chrono only simulation.
- Parameters
forces (array_like) – forces array (length 3)
moments (array_like) – moments array (length 3)
- setIBM(self, useIBM=True, radiusIBM=0., sdfIBM=None)[source]
Sets IBM mode for retrieving fluid forces
- Parameters
useIBM (bool) – set if IBM should be used
radiusIBM (double) – radius of the particle for IBM
radiusIBM – sdf relative to barycentre of body for IBM
- setName(self, string name)[source]
Sets name of body (used for csv file)
- Parameters
name (str) – name of the body
- setPrescribedMotion(self, function)[source]
Sets custom prescribed motion function (!) should be preferably set only if body is free and not linked to other bodies or other elements (such as moorings) as this is used only for setting moving mesh BC by enforcing position of the body at each time step. Use setPrescribedMotionPoly or setPrescribedMotionSine for functions that are safe to use with a body linked with other elements.
- Parameters
function – must be a function of time returning an array of the absolute position of the body (numpy array of length 3: x, y, z)
- setPrescribedMotionCustom(self, double[:] t, double[:] x=None, double[:] y=None, double[:] z=None, double[:] ang=None, double[:] ang2=None, double[:] ang3=None, double t_max=0)[source]
Sets custom prescribed motion for body. Parameters must have the same length as the time array t
- Parameters
t (array_like) – time array
x (array_like) – x coordinates of body
y (array_like) – y coordinates of body
z (array_like) – z coordinates of body
ang (array_like) – rotation of body
ang2 (array_like) – rotation of body
ang3 (array_like) – rotation coordinates of body
t_max (double) – prescribed motion is released when t > t_max. if t_max=0, the prescribed motion is never released.
- setPrescribedMotionPoly(self, double coeff1)[source]
Sets polynomial prescribed motion for body
- Parameters
coeff1 (double) – coeff1 of polynomial
- setPrescribedMotionSine(self, double a, double f)[source]
Sets sinusoidal prescribed motion for body
- Parameters
a (double) – amplitude of sinusoid
f (double) – frequency of sinusoid
- setRecordValues(self, all_values=False, pos=False, rot=False, ang_disp=False, F=False, M=False, inertia=False, vel=False, acc=False, ang_vel=False, ang_acc=False, h_predict=False)[source]
Sets the body attributes that are to be recorded in a csv file during the simulation.
- Parameters
all_values (bool) – Set to True to record all values listed below.
time (bool) – Time of recorded row (default: True).
pos (bool) – Position of body (default: False. Set to True to record).
rot (bool) – Rotation of body (default: False. Set to True to record).
ang_disp (array) – Angular displecement calculated during rigid body calculation step. Applied on the body in order to make it rotating.
F (bool) – Forces applied on body (default: False. Set to True to record).
M (bool) – Moments applied on body (default: False. Set to True to record).
inertia (bool) – Inertia of body (default: False. Set to True to record).
vel (bool) – Velocity of body (default: False. Set to True to record).
acc (bool) – Acceleration of body (default: False. Set to True to record).
ang_vel (array) – Angular velocity of body (default: False. Set to True to record).
ang_acc (bool) – Angular acceleration of body (default: False. Set to True to record).
Notes
To add another value manually, add to dictionary self.record_dict: key: header of the column in .csv value: list of length 2: [variable name, index within variable]
(if no index, use None)
e.g. self.record_dict[‘m’][‘mass’, None]
- class proteus.mbd.CouplingFSI.ProtChMesh[source]
Bases:
object
- class proteus.mbd.CouplingFSI.ProtChMoorings[source]
Bases:
object
Class for building mooring cables
- Parameters
system (System) – Class instance of the system.
mesh (Mesh) – Class instance of the mesh.
length (np.ndarray) – Length of cable segments. Must be an array, if the cable only has one type of segment (e.g. only one type of chain), an array of length 1 can be passed.
nb_elems (np.ndarray) – Number of elements per segments.
d (np.ndarray) – Diameter of segments.
rho (np.ndarray) – Density of segments.
E (np.ndarray) – Young’s modulus of segments.
beam_type (str) – Type of elements (default: “CableANCF”).
- attachBackNodeToBody(self, ProtChBody body)[source]
Attaches back node to a body with ChLinkLockLock
- Parameters
body (ProtChBody) – body to which the node will be attached
- attachFrontNodeToBody(self, ProtChBody body)[source]
Attaches front node to a body with ChLinkLockLock
- Parameters
body (ProtChBody) – body to which the node will be attached
- fixBackNode(self, bool fixed)[source]
Fix back node of cable
- Parameters
fixed (bool) – Fixes node if True
- fixFrontNode(self, bool fixed)[source]
Fix front node of cable
- Parameters
fixed (bool) – Fixes node if True
- getNodesAcceleration(self)[source]
Gives array of nodes acceleration
- Returns
pos – Array of nodes acceleration.
- Return type
np.ndarray
- getNodesD(self)[source]
Gives direction of nodes
- Returns
dire – Array of nodes direction.
- Return type
np.ndarray
- getNodesPosition(self)[source]
Gives array of nodes position
- Returns
pos – Array of nodes position.
- Return type
np.ndarray
- getNodesVelocity(self)[source]
Gives array of nodes velocity
- Returns
pos – Array of nodes velocity.
- Return type
np.ndarray
- setAddedMassCoefficients(self, double tangential, double normal, int segment_nb)[source]
Sets added mass coefficients of cable
- Parameters
tangential (double) – Tangential added mass coefficient.
normal (double) – Normal added mass coefficient.
segment_nb (int) – Segment number to which these coefficients apply.
- setContactMaterial(self, mat)[source]
Sets contact material of the cable
- Parameters
mat (ChMaterialSurfaceSMC) – Material of cable.
- setDragCoefficients(self, double tangential, double normal, int segment_nb)[source]
Sets drag coefficients of cable
- Parameters
tangential (double) – Tangential drag coefficient.
normal (double) – Normal drag coefficient.
segment_nb (int) – Segment number to which these coefficients apply.
- setExternalForces(self, fluid_velocity_array=None, fluid_density_array=None, fluid_acceleration_array=None)[source]
Sets external forces acting on cables Pass fluid velocity_array as argument only for debugging (must be an array as long as the number of nodes)
- setFluidVelocityFunction(self, function)[source]
Function to build nodes
- Parameters
function – Must be a function taking two arguments (3D coordinates and time), and returning velocity (x, y, z).
- setName(self, string name)[source]
Sets name of cable, used for csv file
- Parameters
name (str) – Name of cable.
- setNodesPosition(self, double[:, :, :] positions=None, tangents=None)[source]
Builds the nodes of the cable.
(!) Must be called after setNodesPositionFunction()
- setNodesPositionFunction(self, function_position, function_tangent=None)[source]
Function to build nodes
- Parameters
function_position (Optional) – Must be a function taking one argument (e.g. distance along cable) and returning 3 arguments (x, y, z) coords.
function_position – Must be a function taking one argument (e.g. distance along cable) and returning 3 arguments (x, y, z) tangents at coords.