-
Hi, I'm creating a program that is modelling slender structures in the ocean based on your library. In this process, I've created a class in 'interactions.py' based on Morison's equation to include inertial effects in the flow-structure interaction between the rod and its surrounding fluid. The apply forces function in my class looks like this
where the wave-induced inertia is applied through the airy wave theory and kinematic stretching, while the current velocity is a distributed force decreasing linearly from the sea level to the seabed. The "compute_morison_forces" function applies the Morison forces to each element similarly to the "Slender Body Theory" function (https://docs.cosseratrods.org/en/latest/api/external_forces.html#elastica.interaction.SlenderBodyTheory). The class is working as intended and has been validated against OrcaFlex in its current state, but I still need to include the fluid acceleration for the class to be complete. This means that I must save the fluid velocity in the "system" object to find the fluid acceleration at the next step. Being a novice Python programmer, I'd really appreciate some input to where in the code I should add this functionality (It looks to me like the "memory_block\memory_block_rod.py" is the correct place, and that the best approach would be to store the fluid velocity at nodes similarly to the "position_collection" in the "allocate_block_variables_in_nodes" function), or if there is another simpler approach to save the "fluid velocity" parameter from my apply forces function for one time step to calculate the acceleration? |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 1 reply
-
@sy-cui can you help this issue. |
Beta Was this translation helpful? Give feedback.
-
Hi, You are correct that
Note that this is not the only way to make this work. You may also consider allocating this variable outside the main memory block, like in your interaction class. However, you will need to know the exact size of this class MorrisonForce(NoForces):
def __init__(self, fluid_velocity: np.ndarray):
# Create an aliase to fluid_velocity
self.fluid_velocity = fluid_velocity
def apply_forces(self, system, time=0.0):
self.compute_morrison_force(..., self.fluid_velocity, ...) and in the main case file, ...
# Initialize fluid velocity as a on-node buffer
fluid_velocity = np.zeros((3, n_elements + 1), dtype=np.float64)
simulator.add_forcing_to(rod).using(MorrisonForce, fluid_velocity=fluid_velocity.view()) # .view() is optional
# use fluid_velocity to compute acceleration somehow Hope this helps. |
Beta Was this translation helpful? Give feedback.
Hi,
You are correct that
elastica/memory_block/memory_block_rod.py
is the place to add this variable internally. Assuming that you want to add a vector variable calledfluid_velocity
on the nodes of a rod, there are three files you want to change:elastica/memory_block/memory_block_rod.py
. In the_allocate_block_variables_in_nodes
method you mentioned, simply add to themap_vector_dofs_in_rod_nods
dictionary the line"fluid_velocity": 3
. The block initialization will automatically go through each item in the dictionary and allocate the memory as vectors stored in rod nodes. Of course if you decide to put them on rod elements instead, you will need to put this in the_allocate_block_varia…