Archived OpenModelica forums. Posting is disabled.

Alternative forums include GitHub discussions or StackOverflow (make sure to read the Stack Overflow rules; you need to have well-formed questions)


Forgot password? | Forgot username? | Register

Modeling Interfaces

Modeling Interfaces

Hi Guys,

I am trying to simulate the Oscillator Model described in page 156, section 5.4.4 from the book Principles of Object Oriented Modeling and Simulation with Modelica (same example is given in Chapter 5, section 5.3, example Oscillating Mass Connected to a spring in DrModelica).

The example given calls some classes  from predefined Modelica libraries.  The predefined classes used are: "Position", "Force", "Flange_a", "Flange_b".   In my case I am trying to build these classes from scratch using the information provided in the book.  The code that I have used for the modelling is as follows:

type Position = Real (quantity = "Position", unit = "m");

type Force = Real (quantity = "Force", unit = "N");

connector Flange_a
  Position s;
  flow Force f;
  end Flange_a;

connector Flange_b
  Position s;
  flow Force f;
end Flange_b;

partial model Compliant
  Flange_a flange_a;
  Flange_b flange_b;
  Position s_rel;
  flow Force f;
  equation
  f = flange_b.f;
  s_rel = flange_a.s - flange_b.s;
  0 = flange_a.f + flange_b.f;
  end Compliant;

At the end I manage to compile the whole code but the graph that I am getting is not oscillating.  I think the problem might lie on how I have done the modelling of the above classes however I am not sure where the issue might be.  Could you please recommend how to fix the issue?

Thanks in advance

Maleni

Edited by: Malen - Mar-05-14 14:55:25

Re: Modeling Interfaces

Hi Malen,
in the Compliant model, you wrote

Code:

s_rel = flange_a.s - flange_b.s; 

but it should be:

Code:

s_rel = flange_b.s - flange_a.s; 

you switched between the two flanges, so the spring pushes the mass away from equilibrium, instead of pulling towards it.

Re: Modeling Interfaces

Hi Daniel,

Thanks a lot for the reply.  Quite useful.  I modeled the Compliant having in mind the TwoPin model.  Cheers

There are 0 guests and 0 other users also viewing this topic