Skip to content
LIBRARY
GasForce2.md

GasForce2

Rough approximation of the gas force in the cylinder of a combustion engine, acting between two 1D translational flanges.

The force is a function of the relative flange distance s_rel = flange_b.s - flange_a.s (the piston position) and its derivative v_rel (the piston velocity): compression (v_rel < 0) and expansion (v_rel > 0) follow different quartic pressure curves in the normalized position x = 1 - s_rel/L. The resulting cylinder pressure acts on the piston area pi*d^2/4. A valid operating range requires 0 <= s_rel <= L.

Usage

MultibodyComponents.GasForce2(L, d, k0=0.01, k1=1, k=1)

Parameters:

NameDescriptionUnitsDefault value
LLength of cylinderm
dDiameter of cylinderm
k0Volume offset in V = k0 + k1*(1 - x)0.01
k1Volume scale in V = k0 + k1*(1 - x)1
kGas constant in p_V = k_T1

Connectors

  • flange_a - This connector represents a mechanical flange with position and force as the potential and flow variables, respectively. (Flange)

  • flange_b - This connector represents a mechanical flange with position and force as the potential and flow variables, respectively. (Flange)

Variables

NameDescriptionUnits
xNormalized position of cylinder (= 1 - s_rel/L)
pressCylinder pressure
VCylinder gas volume
TCylinder gas temperature
v_relRelative piston velocity (<0: compression; >0: expansion)m/s
s_relRelative flange distance flange_b.s - flange_a.s (piston position)m
fInternal force (positive from flange_a to flange_b)N

Behavior

Source

dyad
"""
Rough approximation of the gas force in the cylinder of a combustion engine,
acting between two 1D translational flanges.

The force is a function of the relative flange distance `s_rel = flange_b.s -
flange_a.s` (the piston position) and its derivative `v_rel` (the piston
velocity): compression (`v_rel < 0`) and expansion (`v_rel > 0`) follow different
quartic pressure curves in the normalized position `x = 1 - s_rel/L`. The
resulting cylinder pressure acts on the piston area `pi*d^2/4`. A valid operating
range requires `0 <= s_rel <= L`.
"""
component GasForce2
  flange_a = Flange() {
    "Dyad": {
      "placement": {
        "diagram": {"iconName": "default", "x1": -50, "y1": 460, "x2": 50, "y2": 560, "rot": 0}
      },
      "tags": []
    }
  }
  flange_b = Flange() {
    "Dyad": {
      "placement": {
        "diagram": {"iconName": "default", "x1": 950, "y1": 450, "x2": 1050, "y2": 550, "rot": 0}
      },
      "tags": []
    }
  }
  "Length of cylinder"
  parameter L::Length
  "Diameter of cylinder"
  parameter d::Length
  "Volume offset in V = k0 + k1*(1 - x)"
  parameter k0::Real = 0.01
  "Volume scale in V = k0 + k1*(1 - x)"
  parameter k1::Real = 1
  "Gas constant in p*V = k*T"
  parameter k::Real = 1
  "Normalized position of cylinder (= 1 - s_rel/L)"
  variable x::Real
  "Cylinder pressure"
  variable press::Real
  "Cylinder gas volume"
  variable V::Real
  "Cylinder gas temperature"
  variable T::Real
  "Relative piston velocity (<0: compression; >0: expansion)"
  variable v_rel::Velocity
  "Relative flange distance flange_b.s - flange_a.s (piston position)"
  variable s_rel::Length
  "Internal force (positive from flange_a to flange_b)"
  variable f::Dyad.Force
relations
  s_rel = flange_b.s - flange_a.s
  flange_b.f = f
  flange_a.f = -f
  x = 1 - s_rel / L
  v_rel = der(s_rel)
  press = 1e5 * ifelse(v_rel < 0, ifelse(x < 0.986061, 177.4132 * x ^ 4 - 287.2189 * x ^ 3 + 151.8252 * x ^ 2 - 24.9973 * x + 2.4, 2836360 * x ^ 4 - 10569296 * x ^ 3 + 14761814 * x ^ 2 - 9158505 * x + 2129670), ifelse(x > 0.933, -3929704 * x ^ 4 + 14748765 * x ^ 3 - 20747000 * x ^ 2 + 12964477 * x - 3036495, 145.930 * x ^ 4 - 131.707 * x ^ 3 + 17.3438 * x ^ 2 + 17.9272 * x + 2.4))
  f = -press * pi * d ^ 2 / 4
  V = k0 + k1 * (1 - x)
  press * V = k * T
end
Flattened Source
dyad
"""
Rough approximation of the gas force in the cylinder of a combustion engine,
acting between two 1D translational flanges.

The force is a function of the relative flange distance `s_rel = flange_b.s -
flange_a.s` (the piston position) and its derivative `v_rel` (the piston
velocity): compression (`v_rel < 0`) and expansion (`v_rel > 0`) follow different
quartic pressure curves in the normalized position `x = 1 - s_rel/L`. The
resulting cylinder pressure acts on the piston area `pi*d^2/4`. A valid operating
range requires `0 <= s_rel <= L`.
"""
component GasForce2
  flange_a = Flange() {
    "Dyad": {
      "placement": {
        "diagram": {"iconName": "default", "x1": -50, "y1": 460, "x2": 50, "y2": 560, "rot": 0}
      },
      "tags": []
    }
  }
  flange_b = Flange() {
    "Dyad": {
      "placement": {
        "diagram": {"iconName": "default", "x1": 950, "y1": 450, "x2": 1050, "y2": 550, "rot": 0}
      },
      "tags": []
    }
  }
  "Length of cylinder"
  parameter L::Length
  "Diameter of cylinder"
  parameter d::Length
  "Volume offset in V = k0 + k1*(1 - x)"
  parameter k0::Real = 0.01
  "Volume scale in V = k0 + k1*(1 - x)"
  parameter k1::Real = 1
  "Gas constant in p*V = k*T"
  parameter k::Real = 1
  "Normalized position of cylinder (= 1 - s_rel/L)"
  variable x::Real
  "Cylinder pressure"
  variable press::Real
  "Cylinder gas volume"
  variable V::Real
  "Cylinder gas temperature"
  variable T::Real
  "Relative piston velocity (<0: compression; >0: expansion)"
  variable v_rel::Velocity
  "Relative flange distance flange_b.s - flange_a.s (piston position)"
  variable s_rel::Length
  "Internal force (positive from flange_a to flange_b)"
  variable f::Dyad.Force
relations
  s_rel = flange_b.s - flange_a.s
  flange_b.f = f
  flange_a.f = -f
  x = 1 - s_rel / L
  v_rel = der(s_rel)
  press = 1e5 * ifelse(v_rel < 0, ifelse(x < 0.986061, 177.4132 * x ^ 4 - 287.2189 * x ^ 3 + 151.8252 * x ^ 2 - 24.9973 * x + 2.4, 2836360 * x ^ 4 - 10569296 * x ^ 3 + 14761814 * x ^ 2 - 9158505 * x + 2129670), ifelse(x > 0.933, -3929704 * x ^ 4 + 14748765 * x ^ 3 - 20747000 * x ^ 2 + 12964477 * x - 3036495, 145.930 * x ^ 4 - 131.707 * x ^ 3 + 17.3438 * x ^ 2 + 17.9272 * x + 2.4))
  f = -press * pi * d ^ 2 / 4
  V = k0 + k1 * (1 - x)
  press * V = k * T
metadata {}
end


Test Cases

No test cases defined.

  • Examples

  • Experiments

  • Analyses