Azzera filtri
Azzera filtri

Having problems building custom block

3 visualizzazioni (ultimi 30 giorni)
Chandana
Chandana il 24 Lug 2012
Hi, I'm making a custom block to mimic the spring accumulator block provided in simscape (r2010b). The block has three states that define the flowrate into the block : one when the pressure is below the preload pressure, an intermediate state when the pressure is above preload and below maximum pressure, and finally a maximum pressure condition.
When I try to use ssc_build I get the following error message " Error using ==> nonlinear_accumulator>equations at 38 Provided units '1/s' and 'in^3/s' are not commensurate.". I don't seem to understand where in the code the units are not consistent. Line 38 is where q is set equal to vf.der in when vf=0.
Also, when testing the intermediate condition I get this error message " Error using ==> nonlinear_accumulator>equations at 40. Conditional equation has inconsistent differentiability for true and false branches. If the time derivative of a variable appears on a true branch, the same time derivative must appear on the false branch in the same order." Line 40 is the intermediate pressure condition ppr<p<pmax.
Have I made some sort of syntax error? Any help would be appreciated. My block code is as appears below. Thanks for all the help!
component nonlinear_accumulator
% Nonlinear Accumulator
% This block models damping behavior of voided silicone
% liners for use as accumulators in systems affected by water hammer
outputs
Q = { 0, 'in^3/s' }; % Q:top
VF = {0, 'in^3'};% VF: top
end
nodes
a = foundation.hydraulic.hydraulic; % a:bottom
end
parameters
vmax = { 1.4 'in^3'}; % accumulator capacity
ppr = { 4 'psi'}; % preload pressure
pmax = { 80 'psi'}; % max pressure
vpr = { 0, 'in^3'} % inital fluid volume
c = { 1, 'psi*s/in^3'}%damping coefficient
end
variables
q = { 0 , 'in^3/s' }; %flowrate
p = { 0 , 'psi' };%pressure
vf = { 0, 'in^3'} %instantaneous fluid volume
end
function setup
through( q, a.q, [] );
across( p, a.p, [] );
end
equations
if p<= ppr
let
vf = 0;
in
q == vf.der;
end
if p > ppr && p < pmax
let
vf =((vmax-vpr)*((p-ppr)-(c*q)))/(pmax-ppr);
in
q == vf.der;
end
else
let
vf = vmax;
in
q == vf.der;
end
end
Q == q
VF == vf
end
end

Risposta accettata

Ryan G
Ryan G il 24 Lug 2012
On line 36 you set
vf = 0;
With no units. I believe that is why vf.der is 1/s instead of in^3/s. To resolve this you can construct a new variable with units of in^3 and value 0 and set vf equal to that .

Più risposte (0)

Categorie

Scopri di più su Foundation and Custom Domains in Help Center e File Exchange

Tag

Prodotti

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by