Saarland University
Lehrstuhl für Automatisierungstechnik

Welcome Guest ( Log In | Register )

 
Reply to this topicStart new topic
> is such a construct allowed?
daniel@ka
post Jun 18 2010, 01:00 PM
Post #1


Member
**

Group: Members
Posts: 23
Joined: 3-June 08
Member No.: 11,399



CODE

    model R
        pin p,n;
        parameter resistance R0;
    equation
        p.v - n.v = p.i * R0;
        p.i + n.i = 0;
    end R;
    
    model ground
        pin n;
    equation
        n.v = 0;
    end ground;
    
    model V
        pin p,n;
        parameter voltage V0;
    equation
        p.v - n.v = V0;
        p.i + n.i = 0;
    end V;
    
    model circuit_working
        V V1(V0 = 1);
        R R1(R0 = 1);
        ground gnd;
    equation
        connect(V1.p, R1.p);
        connect(V1.n, R1.n);
        connect(V1.n, gnd.n);          
    end circuit_working;

    model circuit_not_working
        V V1(V0 = 1);
        R R1(R0 = 1);
        pin n;
    equation
        n.v = 0;
                connect(V1.n, n);
        connect(V1.p, R1.p);
        connect(V1.n, R1.n);
    end circuit_not_working;


this is very similar to my previous problem
I think it is obvious what the code should do
In my opinion both variants are equivalent in terms of mathematical description
(I am using the openmodelica 3.0)

I would like to ask somebody to try this example in dymola (as I do not have access to it)
and to report the results.

Regards, Daniel
User is offlineProfile CardPM
Go to the top of the page
+Quote Post
daniel@ka
post Jun 17 2010, 10:45 PM
Post #2


Member
**

Group: Members
Posts: 23
Joined: 3-June 08
Member No.: 11,399



Hello @all,

CODE

    type voltage = Real(final unit = "V");
    type current = Real(final unit = "A");
    type resistance = Real(final unit = "V/A", final min = 0);

    connector pin
        voltage v;
        flow current i;
    end pin;
    
    model R
        pin p,n;
        parameter resistance R0;
    equation
        p.v - n.v = p.i * R0;
        p.i + n.i = 0;
    end R;

    model circuit
        R R1(R0(max = 1e9) = 1);
        pin p, n;
    equation
        p.v - n.v = 10 "Volt";
        connect(p, R1.p);
        connect(n, R1.n);
        n.v = 0;
        p.i + n.i = 0;
    end circuit;


what I am trying is to implement a voltage source within the circuit
this may not be wise but I want to understand what happens if one
goes this path.

CODE

>> instantiateModel(elec.circuit)
"fclass elec.circuit
Real R1.p.v(unit = "V");
Real R1.p.i(unit = "A");
Real R1.n.v(unit = "V");
Real R1.n.i(unit = "A");
parameter Real R1.R0(unit = "V/A", min = 0.0, max = 1000000000.0) = 1.0;
Real p.v(unit = "V");
Real p.i(unit = "A");
Real n.v(unit = "V");
Real n.i(unit = "A");
equation
  R1.p.v - R1.n.v = R1.p.i * R1.R0;
  R1.p.i + R1.n.i = 0.0;
  p.v - n.v = 10.0;
  n.v = 0.0;
  p.i + n.i = 0.0;
  (-n.i) + R1.n.i = 0.0;
n.v = R1.n.v;
  (-p.i) + R1.p.i = 0.0;
p.v = R1.p.v;
  p.i = 0.0;
  n.i = 0.0;
end elec.circuit;
"


we have 2 pins within R and 2 pins within the circuit, which makes 8 variables in total
all but the last two equations (n.i=0; p.i=0) can also be found in the previous code
I guess that all flow-prefixed variables will implicitly(?) create such 0-equations
but should not this be the case when the pins (p and n) were left unconnected?

It would be nice if someone could provide some advice.

Regards, Daniel
User is offlineProfile CardPM
Go to the top of the page
+Quote Post

Reply to this topicStart new topic
1 User(s) are reading this topic (1 Guests and 0 Anonymous Users)
0 Members:

 



Lo-Fi Version Time is now: 24th June 2019 - 10:21 PM