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:
| Name | Description | Units | Default value |
|---|---|---|---|
L | Length of cylinder | m | |
d | Diameter of cylinder | m | |
k0 | Volume offset in V = k0 + k1*(1 - x) | – | 0.01 |
k1 | Volume scale in V = k0 + k1*(1 - x) | – | 1 |
k | Gas constant in p_V = k_T | – | 1 |
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
| Name | Description | Units |
|---|---|---|
x | Normalized position of cylinder (= 1 - s_rel/L) | – |
press | Cylinder pressure | – |
V | Cylinder gas volume | – |
T | Cylinder gas temperature | – |
v_rel | Relative piston velocity (<0: compression; >0: expansion) | m/s |
s_rel | Relative flange distance flange_b.s - flange_a.s (piston position) | m |
f | Internal force (positive from flange_a to flange_b) | N |
Behavior
Source
"""
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
endFlattened Source
"""
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 {}
endTest Cases
No test cases defined.
Related
Examples
Experiments
Analyses