From: a black on
i tried to write a pneumatic flow rate source the source code is the above
component pneumatic_1

nodes
A = foundation.pneumatic.pneumatic; % +:top
B = foundation.pneumatic.pneumatic; % -:bottom
end

parameters
gas_flow_reference = { 0.001, 'kg/s' }; % Mass flow rate
end

variables
pressure_difference = { 0, 'Pa' };
gas_flow = { 0 , 'kg/s' };
temperature_difference = { 0 , 'K' };
heat_flow = { 0 , 'J/s' };
end

function setup
across( pressure_difference, A.p, B.p );
through( heat_flow, A.Q, B.Q );
across( temperature_difference, A.T, B.T );
through( gas_flow, A.G, B.G );
end

equations
% Flow equation
gas_flow == gas_flow_reference;
% Heat equation
temperature_difference == 0;
end

end

my problem is that the simulation runs only for values of gas_flow_reference below 0,001 whenever i try a value greater than 0,001 i get an error Nonlinear solver: Linear Algebra error. Failed to solve using iteration matrix.
Initial conditions solve failed to converge.

Does anybody know whats wrong ? if i try the simulation with the already model of pneumatic flow rate source i can run the simulation with any value i want and the models are exactly the same...
From: Arnaud Miege on
"a black" <earedil88(a)gmail.com> wrote in message <i31d51$2jq$1(a)fred.mathworks.com>...
> i tried to write a pneumatic flow rate source the source code is the above
> component pneumatic_1
>
> nodes
> A = foundation.pneumatic.pneumatic; % +:top
> B = foundation.pneumatic.pneumatic; % -:bottom
> end
>
> parameters
> gas_flow_reference = { 0.001, 'kg/s' }; % Mass flow rate
> end
>
> variables
> pressure_difference = { 0, 'Pa' };
> gas_flow = { 0 , 'kg/s' };
> temperature_difference = { 0 , 'K' };
> heat_flow = { 0 , 'J/s' };
> end
>
> function setup
> across( pressure_difference, A.p, B.p );
> through( heat_flow, A.Q, B.Q );
> across( temperature_difference, A.T, B.T );
> through( gas_flow, A.G, B.G );
> end
>
> equations
> % Flow equation
> gas_flow == gas_flow_reference;
> % Heat equation
> temperature_difference == 0;
> end
>
> end
>
> my problem is that the simulation runs only for values of gas_flow_reference below 0,001 whenever i try a value greater than 0,001 i get an error Nonlinear solver: Linear Algebra error. Failed to solve using iteration matrix.
> Initial conditions solve failed to converge.
>
> Does anybody know whats wrong ? if i try the simulation with the already model of pneumatic flow rate source i can run the simulation with any value i want and the models are exactly the same...

Why not use the pneumatic flow rate source block from the Simscape foundation library?
http://www.mathworks.com/access/helpdesk/help/toolbox/physmod/simscape/ref/pneumaticflowratesource.html

That's exactly what the block does. Why do you need to rewrite your own block?

The code looks OK, the problem most likely lies with how the block is used in the model.

HTH,

Arnaud