Archived OpenModelica forums. Posting is disabled.

Alternative forums include GitHub discussions or StackOverflow (make sure to read the Stack Overflow rules; you need to have well-formed questions)


Forgot password? | Forgot username? | Register

Compilation error

Compilation error

class Simplecircuit1

import Modelica;
Resistor R1(R=10);
Capacitor C(C = 0.01);
Resistor R2(R2=100);
Inductor L(L=0.1);
VsourceAC AC;
Ground G;
equation
connect(AC.p,R1.P);
connect(R1.n,C.p);
connect(C.n,AC.n);
connect(R1.p,R2.p);
connect(R2.n,L.p);
connect(L.n,C.n);
connect(AC.n,G.n);
end Simplecircuit1;

Error infoemation: [Simplecircuit1: 10:1-10:9]: Class Ground not found in scope Simplecircuit1.
So how should I deal with this error?

Re: Compilation error

The compiler can't find the class `Ground` in scope.
That means there is no Modelica model / class named `Ground` loaded.

There are two ways to fix this:

- Create a new model named `Ground` with a connector for the pin (you are connecting to `G.n`) and the equation describing what ground should do (pin.v = 0).
Take a look at `Modelica.Electrical.Analog.Basic.Ground` from the Modelica Standard Library (MSL) how it is done in that case.

- Use a library that provides electrical components, e.g. from the MSL (4.0.0) `Modelica.Electrical.Analog`.

You will have the same issue for every other model/class you are using in your class `Simplecircuit1`. If you are using MSL you also have some typos in the connect equations

Code:


[...]
  connect(AC.p,R1.p);
[...]

The book "Modelica by Example" by by Dr. Michael M. Tiller gives a nice introduction to Modelica and also provides examples on object oriented modeling and simple electric examples similar to what oyu are trying to do in your model: https://mbe.modelica.university/

Edited by: AnHeuermann - May-23-22 07:26:49

Re: Compilation error

Thanks a lot.I will have a try

There are 0 guests and 0 other users also viewing this topic
You are here: