Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Weird Behavior with IdealDiode #99

Open
WinWL opened this issue Apr 23, 2019 · 3 comments
Open

Weird Behavior with IdealDiode #99

WinWL opened this issue Apr 23, 2019 · 3 comments

Comments

@WinWL
Copy link

WinWL commented Apr 23, 2019

Hi, I'm having an issue when connecting an ideal diode in my circuit. When I connect the diode in Modia, I get an error about the number of equations and unknowns/states. Without the diode, the simulation runs and the voltage and current sensors for both Matlab and Modia agree quite well. I am translating a circuit from Matlab/Simscape to Modia.

The number of equations and the number of unknowns/states does not match.
Number of equations: 130
Number of variables: 146
Number of continuous states: 17
Note: Number of equations - Number of variables + Number of continuous states must be zero.
It might be that 1 states must be defined to be non-states
(note, Modia does not yet support automatic state selection).
error(::String, ::String, ::Int64, ::String, ::Int64, ::String, ::Int64, ::String, ::String) at error.jl:42
macro expansion at show.jl:555 [inlined]
analyzeStructurally(::Array{Any,1}, ::OrderedCollections.OrderedDict{Symbol,Any}, ::Dict{Symbol,Int64}, ::Array{Any,1}, ::Array{Symbol,1}, ::Array{Int64,1}, ::Array{Any,1}, ::Array{Any,1}, ::Array{Any,1}, ::Int64, ::Array{Any,1}, ::typeof(Modia.StructuralTransform.findIncidence!), ::Array{Any,1}, ::Array{Any,1}, ::Array{Any,1}, ::Array{Any,1}, ::OrderedCollections.OrderedDict{Symbol,Any}, ::Bool) at BasicStructuralTransform.jl:1015
transformStructurally(::Modia.Instantiation.Instance) at StructuralTransform.jl:845
elaborateModel(::Modia.Instantiation.Instance) at ModelElaboration.jl:120
#simulateModelWithOptions#7(::Base.Iterators.Pairs{Symbol,Real,NTuple{4,Symbol},NamedTuple{(:logTiming, :logTranslation, :removeSingularities, :relTol),Tuple{Bool,Bool,Bool,Float64}}}, ::Function, ::Modia.Instantiation.Model, ::StepRangeLen{Float64,Base.TwicePrecision{Float64},Base.TwicePrecision{Float64}}) at ModelElaboration.jl:347
#simulateModelWithOptions at none:0 [inlined]
#simulateModel#8 at ModelElaboration.jl:421 [inlined]
#simulateModel at none:0 [inlined]
SimulateHeartModel(::Float64, ::Float64) at ModiaDE.jl:186
top-level scope at none:0

@HildingElmqvist
Copy link
Contributor

Would you be able to send the model in order that I can analyze it. Or at least the diode model.

@WinWL
Copy link
Author

WinWL commented Apr 23, 2019

I don't think I'm allowed to send the full model of the circuit. I'll see if I can get a minimum working example. The diode model is the one in

https://github.com/ModiaSim/Modia.jl/blob/master/src/models/Electric.jl.

I'm trying to use IdealDiode and IdealDiode2 from the link above. The Matlab circuit uses a piece-wise linear diode.
When I try using IdealDiode, I get the above error.
When I try using IdealDiode2 I get an UndefVarError: IdealDiode2.s not defined.

@WinWL
Copy link
Author

WinWL commented Apr 23, 2019

Here's a text file of a model that illustrates the above error with the equations and unknowns/states.

MWE.txt

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants