/FUNCT_PYTHON example: Force, /CLOAD PID control.

OverView

/FUNCT_PYTHON has been added to Radioss 2025. A function can be defined by Python,

https://help.altair.com/hwsolvers/rad/topics/solvers/rad/funct_python_starter_r.htm

Time, nodal displacement, velocity, elemental stress, etc,,, can be used to define a curve.

Those curves are availeble for boundary and load conditions.

This article is only for people who can develop Python code (or can learn by yourself) and who knows PID control (or can learn by yourself). In this article, those are not explained.

Subject

The aim is to keep certain distance between the two springs. You can imagine a virtual tension rod between the two springs. According to the principal of action and reaction force, two force /CLOAD with same magnitude but opposite direction are applied.

Here is the Radioss input. A same curve is applied to the two /CLOAD, but the direction is reversed,

To simplify things, the nodes can be moved into x-direction.

The aim of the control is to keep the distance 20mm while the initial distance is 10mm.

PID control

Even though I have mentioned that I do not explain about PID, I would like to introduce one URL where I have learned PID.

https://kurobekoblog.com/pid

(Sorry, this site is written in Japanese. I do not know good English URL to learn PID)

For this tutorial, I have chosen those gains. They works fine.

  • Propotional gain Kp=100
  • Differential gain Kd=-2.2
  • Do not use integral gain

Vector adn Python Code explanation

The nodes which we should consider are 2 and 3,

I describe the coordinate vectors of node-2 and 3 as x2, x3. Thus, the vector from node-2 to node-3 is x3-x2,

The distance = the magnitude of the vector = the square of the vector self dot product. Thus, the distance D is expressed by this equation. (Maybe, numpy has a special function for this, but I don't know.)

And for differential term, we have to calculate dD/dt. If we really would do it, we have to export the current cycle D to a text file, and read it and calculate in the next cycle. To do it, we have to learn Python file I/O coding. However, fortunately, the differential of (relative) distance D is relative velocity. Thus, we can calculate by just using prepared variables in /FUNCT_PYTHON.

I describe the velocity vectors of node-2 and -3 as v2, v3. Then, the relative velocity vector from node-2 to node-3 is v3-v2,

We can calculate dot product of the velocity vector and a unit vector which goes from node-2 to node-3. This is the relative velocity magnitude with +/- signs. When the two nodes is closing, the value is negative. When going away, the value is positive. The vector expresson is,

Finally, the applied force is determined by PID formulation, F=Kp D + Kd V.

Run simulation

To use /FUNCT_PYTHON, "-python" option is needed.

Here is the animation. Since there is no viscosity, the system keeps vibrating. However, the distance controll is well done,

It might be a good idea to stop the vibration by /ADYREL,

Download the model (with /ADYREL only):

Tagged:

Welcome!

It looks like you're new here. Sign in or register to get started.

Welcome!

It looks like you're new here. Sign in or register to get started.