Posted Thu, 26 Jul 2018 14:21:25 GMT by cpdmulde

I'm building a new version of the sand filtration model currently present in the default Library. I was able to implement what I wanted, checking along the way for syntax and other errors in the new .msl file and the new CLASS that I created. When I open my WEST project, add the sand filter block and change the properties of the block to use the model I want, I get the following error when trying to run a dynamic simulation:

[i]System error: Error in tree structure[/I]

Since I've never encountered this error and since it's also not very instructive in telling me where to look, I was wondering if anyone has some experience with this error message and has possibly found a solution for it.

Thanks in advance,
Posted Tue, 31 Jul 2018 06:32:10 GMT by Enrico Remigi WEST Product Owner
Hello Chaim,
I must admit: that's a first for me too ...
Never seen this before.

Just to be clear: you are using MSL, the WEST Model Editor and release 2017, correct ?
Are you by any chance implementing a coupled-model? that's where I could imagine a "tree" error may occur, although I would expect such error be caught by the syntax check ...
Posted Tue, 31 Jul 2018 07:34:50 GMT by cpdmulde
Hi Enrico,

I am indeed working in .msl-files and using the 'normal' WEST Model Editor. I'm running the 2018dev version of WEST though.
If with coupled-model you mean that my model would under the hood contain multiple tanks or other submodels, then no, I'm not using a coupled-model (not using coupling <- {}, or connecting variables/parameters in any other way).

One more 'unconventional' thing I do is calculate the interface.Outflow variables explicitly, and not through a FOREACH statement, e.g.:

[i]interface.Outflow[S_I] = -interface.Inflow[S_I]
interface.Outflow[S_O] = -interface.Inflow[S_O][/i]

instead of

[i]{FOREACH Comp_Index IN {IndexOfSolvent .. IndexOfLastSolubleComponent}:
      interface.Outflow_Unfiltered[Comp_Index] = - interface.Inflow[Comp_Index] * state.f_Out_Unfiltered
                - interface.Backwash * interface.Inflow_Backwash[Comp_Index];

Could the problem hide somewhere in there? Just trying to narrow down which piece of code I best start checking when looking for the source of the error.
Posted Tue, 31 Jul 2018 08:55:59 GMT by Enrico Remigi WEST Product Owner
Hello Chaim,
no, I really don't believe it may be due to the replacement of the FOREACH by individual expressions.

However, since you must be restricting your model to one instance only, the 'tree' that the error complains about may refer to resolving the #ifdef statements (only a wild guess ...)
Posted Tue, 31 Jul 2018 10:49:15 GMT by cpdmulde
Hi Enrico,

Thanks for the answer and the nice tip at the end, I think I found the source of the error (due to technical problems, I cannot check at this time, I will confirm in this thread once I can); I was using an [i]#ifdef StandardCategoryModels[/i] at the beginning of my class definition, while I'm only calculating state variables for an own custom version of ASM2d, and not for other models. I've changed this to the relevant [i]#ifdef ASM2dChemTemp[/I]. If this wasn't the source of the error, it would have probably popped up sooner or later.

Thanks for the help!
Posted Tue, 31 Jul 2018 15:21:40 GMT by Filip Claeys
"Error in tree structure" is a very unusual error message that is generated by the TMSL model compiler in case of a malformed equation LHS. As such it has nothing to do with preprocessor defines, at least not directly.
Posted Wed, 01 Aug 2018 08:09:17 GMT by cpdmulde

Indeed, the changing of the [i]#ifdef statements[/i] did not solve the problem. I went through my model .msl file and found the weirdest typo: a '+' sitting in the middle of an otherwise empty line. Removing this also got rid of the problem. Still weird it does not pick this up as a syntax error though.

With regards to other possible causes, would you then suggest to got through the model implementation and double-check every equation left hand side, Filip? Just in case other users ever bump into the same error message.

Best and thanks for your help!
Posted Mon, 18 Nov 2019 08:42:33 GMT by Morata
I have a try to apply.

You must be signed in to post in this forum.