Is it possible to create a state space component in Simscape?

3 Ansichten (letzte 30 Tage)
Alex Dugas
Alex Dugas am 19 Jul. 2019
Bearbeitet: Alex Dugas am 20 Jul. 2019
I have a DAE in the following form
The DAE corresponds to some circuit. The input corresponds to the voltage at the ports and is the current flowing through those ports. I'd like to be able to create custom Simscape component for this system.
I did find this answer, that has help me get started but I'm very far off still. I have the following very wrong attempt that I figured I'd include.
component myComponent
% Non-working attempt at creating a Custom Simscape component
% from a state space system
nodes
p=foundation.electrical.electrical; % 1:left
n=foundation.electrical.electrical; % 2:left
end
variables
i = { 0, 'A'}; % current into port 1
v = { 0, 'V'}; % current into port 2
x = {zeros(30,1), 'V'} % internal state variable
end
function setup
E = "some 30x30 matrix"
A = "some 30x30 matrix"
B = "some 30x2 matrix"
C = "some 2x30 matrix"
end
equations
E*x.der == A*x + B*v;
i == C*x;
end
end

Antworten (1)

Alex Dugas
Alex Dugas am 20 Jul. 2019
Bearbeitet: Alex Dugas am 20 Jul. 2019
I think I've figured this out for my own problem. I'll post what I think is the answer in case it's helpful to someone.
What is still "wrong", is that the initial DCOP found by simscape isn't what I expect. There could be something wrong with this model or maybe I don't know how to use the solver.
component myComponent
% Non-working attempt at creating a Custom Simscape component
% from a state space system
nodes
p=foundation.electrical.electrical; % 1:left
n=foundation.electrical.electrical; % 2:left
end
variables
i1 = { 0, 'A'}; % current into port 1
i2 = { 0, 'V'}; % current into port 2
x = {zeros(30,1), 'V'} % internal state variable
end
branches
i1 : p.i -> n.i
i2 : n.i -> p.i
end
parameters
E = {0, 's'} % units to avoid complaints
A = {0, '1'}
B = {0, '1'}
C = {0, '1/Ohm'}
end
function setup
E = {"some 30x30 matrix", 's'}
A = {"some 30x30 matrix", '1'}
B = {"some 30x2 matrix", '1'}
C = {"some 2x30 matrix", '1/ohm'}
end
equations
E*x.der == A*x + B*[p.v; n.v];
[i1; i2] == C*x;
end
end

Kategorien

Mehr zu Composite Components finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by