Figure 26: Constraint block for physical interaction in SysML

Gallery
Tutorial
Click on the image to view it full size

model Spring
  Flange p1;
  Flange p2;
  Real lengthchg;
  parameter Real springcst = “10”;
  Real velocitydiff
  Real forcethru
equation
  p1.f+p2.f=0
  forcethru=p1.f;
  velocitydiff=p1.lV-p2.lV;
  velocitydiff=der(lengthchg);
  forcediff=springcst*lengthchg;
end Spring;

The spec code contains a typo:

Export of block Spring to Modelica from the MagicDraw SysML Plugin or Magic Cyber-Systems Engineer ® (Cameo Systems Modeler®) gives:

model Spring
  Spring _Spring;
  model Spring
    Flange p1;
    Flange p2;
    Length lengthchg;
    parameter Stiffness springcst(start=10.0,fixed=true);
    Velocity velocitydiff;
    Force forcethru;
  equation
    p1.f+p2.f=0;
    forcethru=p1.f;
    velocitydiff=p2.lV-p1.lV;
    velocitydiff=der(lengthchg);
    forcethru=springcst*lengthchg;
  end Spring;
  connector Flange
    flow Force f;
    Velocity lV;
  end Flange;
  type Length=Real(unit="m");
  type Stiffness=Real(unit="N/m");
  type Velocity=Real(unit="m/s");
  type Force=Real(unit="N");
end Spring;

Note the use of the explicit start attribute along with the explicit attribute fixed=true.

Unfortunately, the Spring model as shown is not quite well formed. Wolfram SystemModeler reports:

Validation of model WebelSysMLvsSysPhS.Spring 

Warning: Parameter _Spring.springcst has no value, and is fixed during initialization (fixed = true), using available start value (start = 10.0) as default value.

Error: The following equations are redundant:
    0.0 = 0.0
  Corresponding variables with arbitrary value: _Spring.p1.lV

Validation of model Spring completed with 1 error.
Note how in the trail model version the custom ValueTypes Stiffness and Length explicitly extend Real: And on a very minor modelling matter:
Up next
Notes
Snippets (quotes/extracts)
Visit also
Visit also (backlinks)
Related slides (includes other tutorials)
Related slides (backlinks, includes other tutorials)