Skip to content

Commit ccc6a13

Browse files
committed
Initial commit R2024a
1 parent a837d49 commit ccc6a13

File tree

270 files changed

+3179
-2
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

270 files changed

+3179
-2
lines changed
Lines changed: 113 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,113 @@
1+
component PS_force_hydraulic_chamber_trans_comp
2+
% Translational Hydraulic Chamber Force Compressible
3+
% This block models an ideal transducer that converts hydraulic
4+
% energy in a chamber with a translational output member (e.g., a piston
5+
% head) into a mechanical force on the output member. Fluid
6+
% compressibility is accounted for and the pressure variation due to
7+
% density fluctuations dynamically solved.
8+
%
9+
% Port A is a hydraulic conserving port associated with the chamber
10+
% inlet. Input ports pos and vel are the respective position and velocity
11+
% of the output member. Output port f is the force acting on the output
12+
% member.
13+
14+
% Copyright 2016-2024 The MathWorks, Inc.
15+
16+
nodes
17+
A = foundation.hydraulic.hydraulic; % A:right
18+
end
19+
20+
inputs
21+
velocity = {0, 'm/s'}; % v:left
22+
position = {0, 'm'}; % p:left
23+
end
24+
25+
outputs
26+
force = {0, 'N'}; % f:left
27+
end
28+
29+
parameters
30+
area = {5e-4, 'm^2'}; % Piston area
31+
V_dead = {1e-4, 'm^3'}; % Chamber dead volume
32+
k_sh = {1.4, '1' }; % Specific heat ratio
33+
initial_pressure = {0, 'Pa' }; % Initial pressure
34+
end
35+
36+
parameters (Access = private)
37+
p_atm = {1, 'atm' }; % Atmospheric pressure
38+
rho_g0 = {1.2, 'kg/m^3'}; % Gas density at reference pressure
39+
end
40+
41+
variables (Access = private)
42+
pressure_chamber = {0, 'Pa' }; % Fluid pressure in the chamber
43+
volume = {1e-4, 'm^3' }; % Chamber volume
44+
q = {0, 'm^3/s'}; % Flow rate leaving the converter
45+
qV = {0, 'm^3/s'}; % Flow rate leaving the converter due to volume changes
46+
qrho = {0, 'm^3/s'}; % Flow rate leaving the converter due to density changes
47+
end
48+
49+
function setup
50+
% Parameter range checking
51+
if area <= 0
52+
pm_error('simscape:GreaterThanZero','Piston area');
53+
end
54+
if V_dead <= 0
55+
pm_error('simscape:GreaterThanZero','Chamber dead volume')
56+
end
57+
if k_sh < 1
58+
pm_error('simscape:GreaterThanOrEqual','Specific heat ratio','1')
59+
end
60+
if k_sh >= 2
61+
pm_error('simscape:LessThan','Specific heat ratio','2')
62+
end
63+
if initial_pressure <= {-1, 'atm'}
64+
pm_error('simscape:GreaterThanOrEqual','Initial pressure','absolute zero')
65+
end
66+
67+
% Derived parameters
68+
rho_g0 = (initial_pressure + {1, 'atm'}) / ( {287.04, 'J/kg/K'} * {293.15, 'K'} );
69+
70+
% Initial conditions
71+
pressure_chamber = initial_pressure;
72+
end
73+
74+
branches
75+
q: A.q -> *;
76+
end
77+
78+
equations
79+
assert((A.range_error == 1) | (pressure_chamber > {-1,'atm'}), 'Pressure fell below absolute zero');
80+
assert((A.range_error == 2) | (pressure_chamber > {-1,'atm'}), 'Pressure fell below absolute zero',Warn=true);
81+
82+
let
83+
% The fluid mixture density at node P is calculated to know exactly
84+
% how much fluid is actually displaced.
85+
p_abs = pressure_chamber + p_atm;
86+
p_0abs = initial_pressure + p_atm;
87+
88+
% Full fluid mixture density model
89+
rho_l0 = A.density;
90+
beta_l = A.bulk;
91+
rho_over_rho0 = (A.alpha/(1-A.alpha) * rho_g0/rho_l0 + 1)/( A.alpha/(1-A.alpha)*(p_atm/p_abs)^(1/k_sh) + exp(-pressure_chamber/beta_l) );
92+
drho_over_rho0dp = (A.alpha/(1-A.alpha) * rho_g0/rho_l0 + 1) * (A.alpha/(1-A.alpha)/p_atm/k_sh*(p_atm/p_abs)^(1/k_sh+1) + exp(-pressure_chamber/beta_l)/beta_l)/( A.alpha/(1-A.alpha)*(p_atm/p_abs)^(1/k_sh) + exp(-pressure_chamber/beta_l) )^2;
93+
94+
% Chamber volume
95+
vol_ref = area*position + V_dead;
96+
in
97+
% Fluid mechanical interface
98+
if vol_ref > V_dead
99+
volume == vol_ref;
100+
else
101+
volume == V_dead;
102+
end
103+
104+
force == pressure_chamber * area;
105+
106+
% Flow rate exiting the chamber
107+
pressure_chamber == A.p;
108+
qV == rho_over_rho0*area * velocity;
109+
qrho ==drho_over_rho0dp * pressure_chamber.der * volume;
110+
q == qV + qrho;
111+
end
112+
end
113+
end
Lines changed: 32 additions & 0 deletions
Loading
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
component PS_force_hydraulic_chamber_trans_incomp
2+
% Translational Hydraulic Chamber Force Incompressible
3+
% The block models an ideal transducer that converts hydraulic
4+
% energy into mechanical energy in the form of translational motion of the
5+
% converter output member.
6+
7+
% Copyright 2016-2024 The MathWorks, Inc.
8+
9+
nodes
10+
A = foundation.hydraulic.hydraulic; % A:right
11+
end
12+
13+
inputs
14+
velocity = {0, 'm/s'}; % v:left
15+
position = {0, 'm'}; % p:left
16+
end
17+
18+
outputs
19+
force = {0, 'N'}; % f:left
20+
end
21+
22+
parameters
23+
area = { 5e-4, 'm^2' }; % Piston area
24+
end
25+
26+
variables
27+
q = { 0, 'm^3/s' }; % Flow rate leaving the converter
28+
end
29+
30+
function setup %#simple
31+
% Parameter range checking
32+
if area <= 0
33+
pm_error('simscape:GreaterThanZero','Piston area');
34+
end
35+
end
36+
37+
branches
38+
q: A.q -> *;
39+
end
40+
41+
equations
42+
% Fluid mechanical interface
43+
force == area*A.p;
44+
45+
% Flow rate exiting the converter
46+
q == area*velocity;
47+
end
48+
end
Lines changed: 32 additions & 0 deletions
Loading
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
function lib( libInfo )
2+
% Customize library
3+
% Copyright 2005-2024 The MathWorks, Inc
4+
5+
libInfo.Name = 'Hydraulic';
6+
end
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
component PS_q_axs_to_qz
2+
% PS Calculate qz
3+
% This block calculates the rotational angle about the z axis using Angle
4+
% and Axis outputs of the Transform Sensor block
5+
6+
% Copyright 2016-2024 The MathWorks, Inc.
7+
8+
inputs
9+
q = {0, 'rad'}; % q:left
10+
axs = {[0 0 0]','1'} %axs:left
11+
end
12+
13+
outputs
14+
qz = {0, 'rad'}; %qz:right
15+
end
16+
17+
equations
18+
qz == q*sign(axs(3));
19+
end
20+
21+
end
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
function lib( libInfo )
2+
% Customize library
3+
% Copyright 2005-2024 The MathWorks, Inc
4+
5+
libInfo.Name = 'Math';
6+
end
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
component PS_force_friction_rot
2+
% Rotational Friction Force
3+
% The block represents friction in the contact between moving bodies. The
4+
% friction force is simulated as a function of relative velocity and
5+
% assumed to be the sum of Stribeck, Coulomb, and viscous components. The
6+
% sum of the Coulomb and Stribeck frictions at zero velocity is often
7+
% referred to as the breakaway friction.
8+
9+
% Copyright 2016-2024 The MathWorks, Inc.
10+
11+
inputs
12+
w = {0, 'rad/s'}; % w:left
13+
end
14+
15+
outputs
16+
t = {0, 'N*m'}; %t:right
17+
end
18+
19+
parameters
20+
brkwy_trq = { 25, 'N*m' }; % Breakaway friction torque
21+
brkwy_vel = { 0.1, 'rad/s' }; % Breakaway friction velocity
22+
Col_trq = { 20, 'N*m' }; % Coulomb friction torque
23+
visc_coef = { 0.001, 'N*m*s/rad' }; % Viscous friction coefficient
24+
end
25+
26+
parameters (Access=private)
27+
static_scale = sqrt(2*exp(1))*(brkwy_trq-Col_trq); % Scale factor for static torque
28+
static_thr = sqrt(2)*brkwy_vel; % Velocity threshold for static torque
29+
Col_thr = brkwy_vel/10; % Velocity threshold for Coulomb torque
30+
end
31+
32+
equations
33+
% Parameter range checking
34+
assert(brkwy_trq>0)
35+
assert(brkwy_vel>0)
36+
assert(Col_trq>0)
37+
assert(Col_trq<=brkwy_trq)
38+
assert(visc_coef>=0)
39+
% Torque is a combination of viscous, static, and Coulomb losses
40+
t == visc_coef * w ...
41+
+ static_scale * (w/static_thr*exp(-(w/static_thr)^2)) ...
42+
+ Col_trq * tanh(w/Col_thr);
43+
end
44+
45+
end
Lines changed: 57 additions & 0 deletions
Loading

0 commit comments

Comments
 (0)