Message Boards Message Boards

1
|
11141 Views
|
16 Replies
|
9 Total Likes
View groups...
Share
Share this post:

Exceeding the "memory pool" in WSM

I know there are much larger systems simulated than the one I have, so this should be an easy question:

I have a network of about 200 "Short Pipes" and 200 "Point Volumes" from the Media library. It runs just fine if I cut that down to about 100 each. But I'm getting this error in Simulation Center in the Simulation Log

Assertion failed: (current_state.char_buffer_ptr + n < NR_CHAR_ELEMENTS), function char_alloc, file /Users/jenkins/workspace/Kernel-5.0.X/label/OSX/MCOpenModelica/c_runtime/memory_pool.c, line 181.

Looking at the memory pool header file it looks like NR_CHAR_ELEMENTS is a hardcoded limit designed for 1998 computers. Is there a place to increase this or change my code to avoid the error?

POSTED BY: Eric Smith
16 Replies

Hi Eric,

We believe we have narrowed down the cause of the issue. To put it shortly, the issue seems to be caused by an excessive amount of potential assert messages that are being prepared (a few for each of the pipe sections). When they contain dynamic information from the model, such as:

    assert(p >= 0.0, "Pressure (= " + String(p) + " Pa) of medium \"" + mediumName + "\" is negative\n(Temperature = " + String(T) + " K)");

These currently need to be pre-allocated. We are currently working on a fix to avoid this. I'll let you know when I have a rough time-frame. A fix that can be applied in the mean time would be to make a slightly modified copy of the medium model, where all assert strings are constants, like:

    assert(p >= 0.0, "Pressure of medium is negative");

I could help you with that. Is Modelica.Media.Air.SimpleAir the medium you are looking to use in your test models?

Regards, Patrik

POSTED BY: Patrik Ekenberg

Interesting Patrik, nice work finding that. SimpleAir would be fine if you want to send a patched medium file.

If there is a good regex expression I could use, please send that as well. I’ll make copies of the other media I want to use and do a regex find-replace in a text editor.

Please keep me in the loop on a more permanent fix.

POSTED BY: Eric Smith

Eric, try this Custom Media package and see if it works for you. It at least works with my PipeVolumeSystem model. I replaced all the references in the PipeVolumeSystem model from Modelica.Media to CustomMedia (I set the Medium to CustomMedia.Air.SimpleAir and changed the components to CustomMedia.Examples.Tests.Components.[...]).

The test simulation will produce an assert message, which is expected since the temperature in the model is set to high. I left it there because it was the assert message that was giving troubles previously.

I'll follow up with you on a more permanent fix.

Attachments:
POSTED BY: Patrik Ekenberg

Patrik, I didn't get around to testing this today. I'm trying to figure out the media library – creating a custom medium – and I'm running into trouble. It's saying

state.p not found in scope Modelica.Media.Examples.Tests.Components.FixedAmbient$fixedAmbient.Medium.BaseProperties.

I think I just need to call setState_pTX in my component. I'll try to wrap this up and test for you tomorrow.

POSTED BY: Eric Smith
Posted 6 years ago

Patrik, to update you on the progress. I did install the CustomMedia package and it's working. I was also able to duplicate other libraries from the Media package (like the ideal gas package) without any issue. Thanks for the workaround!

POSTED BY: Updating Name

Thanks for confirming, Neil. Patrik, would you be able to send me a build with the patch? What's a rough timeframe to get this fixed?

Thanks, Eric

POSTED BY: Eric Smith

Patrik,

It appears that there is a bug in the Mac version of WSM. I get the same error as Eric running your posted code (PipeVolumeSystem). It appears that a hard path is burned into the code because there is no user "Jenkins" on my machine (nor presumably on Eric's). I am even running it on the WSM version (the number of which I emailed you yesterday) and it crashes.

/Users/jenkins/workspace/Kernel-ci/label/OSX/SystemModeler/Kernel/cruntime/memorypool.c, line 181.

If I manually build the program it builds but does not run -- it throws the error at runtime. My guess is that there is an error in one of the Library files that overflows on such a large _init.sim file. Using 200 runs but 300 fails. The file reference must be embedded inside the library. I hope that helps.

Regards

POSTED BY: Neil Singer

I tried to run it on my mac but you are missing some models:

Pipe

OnePipe.Medium

Can you post the entire package zipped?

Regards

POSTED BY: Neil Singer

Neil, the site wouldn't let me upload a zip file. I added the two files (not sure why "OnePipe" was needed).

Alternatively, run Patrik's code. I hit the same problem with it, but his doesn't rely on my custom components.

Attachments:
POSTED BY: Eric Smith

Like Patrick, I am also interested in more information. Thank you.

Hi Eric,

I realize you might not want to share the full model, but could you tell me if the attached model is roughly similar to what you are trying to model? I tried to reconstruct it from your description and I am not able to reproduce the error even with 300 pipes.

Attachments:
POSTED BY: Patrik Ekenberg

Patrik, there's nothing proprietary here. Just some simple test cases at this point. I've attached the two files you'd need. The file that I'm talking about is "MultipleSectionNetwork.mo" the only non-Media library file that it relies on is "DryGasPipeline.TwoPort"

Attachments:
POSTED BY: Eric Smith

I ran your code and got the same error from my code. Something must be strange with my install. I'm running on a Mac. Since I have a network license and Parallels, let me try on Windows. I'll report back soon.

POSTED BY: Eric Smith

The model worked fine in Windows. Would you be able to check if there is an issue with the Mac version in general or if it's a setting on my computer? I'm running macOS High Sierra 10.13.2, Kaby Lake 2.8 GHz i7

POSTED BY: Eric Smith

Eric,

You may have to wait for the people in Sweden to help you out on this but I took a quick look at the memory_pool.h file in WSM and that value is set to 20,000,000. It would surprise me if you could legitimately exceed that -- it must be some kind of bug.

You can find the file on a mac by showing the contents of the SystemModeler app and going to Contents->include. You can certainly try increasing it (although a backup copy would be a great idea!).

I would try to look at the source with view->Generated Source Code to find the line that is causing the trouble and see if you can figure out what is going on. It is strange to me that you are even using anything that involve CHAR elements in a model of pipes.

Regards

Neil

POSTED BY: Neil Singer

Neil, 20,000,000 is in the header file and I definitely don't have that many outputs. Thanks for finding the header file. It doesn't look like the c file is in the directory though, so I can't see what line 181 is in "memory_pool.c"

POSTED BY: Eric Smith
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard

Group Abstract Group Abstract