Opened 11 years ago

Closed 11 years ago

#2210 closed defect (fixed)

variable-names involved in equation-systems

Reported by: lochel Owned by: sjoelund.se
Priority: high Milestone: 1.9.0
Component: Run-time Version: trunk
Keywords: Cc: lochel

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 Changed 11 years ago by sjoelund.se

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

comment:2 Changed 11 years ago by lochel

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

comment:3 Changed 11 years ago by sjoelund.se

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 Changed 11 years ago by lochel

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 Changed 11 years ago by sjoelund.se

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

comment:6 Changed 11 years ago by lochel

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 Changed 11 years ago by lochel

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 Changed 11 years ago by sjoelund.se

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 Changed 11 years ago by lochel

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 Changed 11 years ago by lochel

  • Resolution set to fixed
  • Status changed from new to closed

fixed in r16197. Thanks to Martin.

Note: See TracTickets for help on using tickets.