Modelica - connect the connectors after some distance

In modelica, I need to connect two spaces and pass an object, letโ€™s say, a ball through some distance. In my example, I have two spaces in which there is free space (without forces), and suddenly we enter an almost terrestrial space (gravity) that acts on the ball. I need to pass the ball from first place to second, but I canโ€™t get it. Here is a minimal example.

model Ball
  Real[2] position;
  Real[2] velocity;
  parameter Real mass=1;
equation
  der(position) = velocity;
end Ball;

connector Flange
  Real p;
  flow Ball b;
end Flange;

model FreeSpace
  Ball ball;
  parameter Real length;
  Flange f;
equation
  // need to do something, probably here, to end the first space when ball is at length
end FreeSpace;

model NearEarth
  extends FreeSpace;
  parameter Real[2] g={0,-9.8};
equation
  der(ball.velocity) = g;
end NearEarth;

model PassBall
  FreeSpace free(ball.velocity={5,0},ball.position={0,10});
  NearEarth near;
equation
  connect(free.f,near.f);
end Equation;

Maybe I am doing something very bad, but this is where I am. (In the real task, I have an electronic impulse that spreads through spaces that are inherited from FreeSpace, but different forces act in each of them.) Any suggestions would be great!

+1
source share
2

, "", ?

Modelica. Modelica . , , . , , , .

, , , - FreeSpaceInteraction FreeSpace NearEarthInteraction NearEarth. , ( ).

, . " Modelica" ( ), . , , , .

:

, Google - . "Modelica gravity Tiller" . , . , , .

, ..., Ph.D. , , , .

, "FixedSpace" - "Ball". , ( has-a ). " ", "", " " , . "" , , . , , , .

+1

. , Modelica .

, , : -g , .

-g, :

  • [2]
  • [2]
  • [2]

, , :

  • Real [2] positionEarth

, , :

  • real radiusGravField
  • real gravConstant

, , , , , :

model grav
  import Modelica.Math.Vectors.*;
  Real[2] velocity(start={-1,-0.9});
  Real[2] position(start={5,5});
  Real[2] acceleration;
  parameter Real[2] positionEarth={0,0};
  parameter Real radiusGravField=2;
  parameter Real gravConstant=10;
equation 
  der(position) = velocity;
  der(velocity) = acceleration;
  if norm(positionEarth - position, 2) > radiusGravField then
    acceleration = {0,0};
  else
    acceleration = gravConstant/norm(positionEarth - position, 2)^2 
                    * normalize(positionEarth - position);
  end if;
end grav;

, - .

, , :

  when norm(positionEarth - position, 2) < radiusGravField/1000 then
    terminate("Simulation over, crashed on planet");
  end when;
+1

Source: https://habr.com/ru/post/1790782/


All Articles