Opened 12 years ago

Closed 12 years ago

#2210 closed defect (fixed)

variable-names involved in equation-systems

Reported by: Lennart Ochel Owned by: Martin Sjölund
Priority: high Milestone: 1.9.0
Component: Run-time Version: trunk
Keywords: Cc: Lennart Ochel

Description

We cannot access variable-names involved in equation-systems during runtime since r15072. This is quite important to provide useful warnings/error-messages. Previously we had nice dumps that were quite useful. Now we get just a “Segmentation fault (core dumped)”. The reason is that we do not load the VAR_INFO inside the EQUATION_INFO structure.

This can be tested using the following model and flags:

model: /testsuite/simulation/modelica/nonlinear_system/problem6_newton.mos
simflags: -lv=LOG_NLS -nls=kinsol

Martin: Can you fix this? Or can we revert this until your changes are not breaking anything (as you promised ;-)).
I tried already to fix it. But I have no idea how to access the var names inside the xml-parser. Probably you can fix it quickly.

Change History (10)

comment:1 by Martin Sjölund, 12 years ago

It's easy to fix. Good practice. I'll be back on Friday the 7th if you cannot fix it by then.

comment:2 by Lennart Ochel, 12 years ago

How can I access the variable name inside a "var"-node of the XML-structure? Maybe I will do a second try.

comment:3 by Martin Sjölund, 12 years ago

c/simulation/simulation_info_xml.c. Just implement behaviour in startElement and/or endElement.

Also, your other code that tries to access the variables should not crash since the equationInfo defaults to numVar=0. And who tries to dereference a NULL pointer anyway ;) Might be good to fix those two things first.

comment:4 by Lennart Ochel, 12 years ago

numVar is not = 0 because it get increased in endElement.
I have already started to implement the stuff in start/endElement. But I do not know how I can access the Name Attribute of the var-node.

comment:5 by Martin Sjölund, 12 years ago

const char **attr. Just loop over attr until it becomes NULL, I think.

comment:6 by Lennart Ochel, 12 years ago

Okay, I will try it out. One more question: In the info.xml file are more vars than equations for some non-linear equations. Is that possible? I thought that there should be always the same number of unknowns and equations.

<equation index="395">
  <nonlinear indexNonlinear="2">
    <var>a</var>
    <var>b</var>
    <var>c</var>
    <var>d</var>
    <eq index="384"/>
    <eq index="386"/>
    <eq index="387"/>
    <eq index="388"/>
    <eq index="389"/>
    <eq index="390"/>
    <eq index="394"/>
    <eq index="393"/>
    <eq index="392"/>
    <eq index="391"/>
  </nonlinear>
</equation>

comment:7 by Lennart Ochel, 12 years ago

attr[0] is already NULL. This is what I have expected. The name of the var not an attribute, because it is insert in the hierarchical xml-structure as seen in my last post. I have still no idea how to access this name.

comment:8 by Martin Sjölund, 12 years ago

You need another handler for that, it seems:
http://www.xml.com/pub/a/1999/09/expat/index.html?page=3#chardatahandler

And yes, you need to know that the last tag was a var tag before you read the data, etc. Or you change the template and xslt to use <var name="a" />.

As for NLS, yes they can have more equations than variables. From my understanding, they are stored in this way for tearing.

comment:9 by Lennart Ochel, 12 years ago

You are right. This is because of tearing.
I tried to fix it again by myself. Now, I can load the var-names, but my implementation crashes for linear equation system. So it would be much more efficient if you can fix this by your own. I spend too much time trying to get this running by my own … this is totally annoying, because I got this working a few month ago …
Probably we should add also test for our dumps in the testsuite. Because such effects can be only covered if we test also all of our dumps.

comment:10 by Lennart Ochel, 12 years ago

Resolution: fixed
Status: newclosed

fixed in r16197. Thanks to Martin.

Note: See TracTickets for help on using tickets.