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

Tracking and plotting residuals while running the case #36

Closed
TheodoreGalanos opened this issue Jul 12, 2016 · 4 comments
Closed

Tracking and plotting residuals while running the case #36

TheodoreGalanos opened this issue Jul 12, 2016 · 4 comments

Comments

@TheodoreGalanos
Copy link
Collaborator

TheodoreGalanos commented Jul 12, 2016

Hello,

This is in reference to discussion #21 .

I will try to give my 0.02c on how we can go about visualizing residuals, and potentially any other information derived from function objects, within Butterfly. I think there are three possibilities to do this, with different potential and ease of implementation depending also on which operating system the user is running.
Note: I do not assume Butterfly is only for Windows, especially given the current transformation of LB (and guessing the whole suite of tools) as an independent entity.

I am listing the three possibilities below:

1.Using the pyFoam libraries and the pyFoamPlotRunner.py utility. This works in like a charm Linux but I haven't got the chance to test it in Windows. If we can manage to setup pyFoam in windows this would be one of the easiest ways to plot residuals (and do much more). Maybe since OF is actually working through a VM this is possible. In that case, what is required by Butterfly is to edit the Run command accordingly:

pyFoamPlotRunner.py mpirun -np 4 simpleFoam -parallel (for the parallel case)

pyFoamPlotRunner.py simpleFoam -parallel (for the single processor case)

The PlotRunner utility will automatically create residual plots that automatically update on every iteration. pyFoam also allows the user to create image files out of the plots at the end!

2.In case pyFoam cannot work under the VM environment in Windows then we can replicate its functionality by following the terminal output (> log.txt kind of thing) and extracting the necessary information from its output (e.g. the number for each residual in each iteration), since the format of the output is consistent at every iteration. We can then use some windows application to plotting that. For example I know that simply opening the .log file in a browser works so perhaps it can be a sort of visualization utility/code within a browser?

This is a bit like we are rediscovering the wheel. However, it represents a generic way to visualize run-time information in Windows which can be extremely valuable for the visualization of information created from function objects.

3.The third way is a compromise between the two, or rather a most specific and probably efficient way to go about no. 2. It pertains specifically to residuals and it uses the -residual function object of OF. This function would write out the residuals for each timestep in a file. We can use that file then to visualize information.

I have to wonder if a utility like a value tracker within GH can be used for the visualization of residuals. Cause that would be really cool!

Hope all this helps!

Kind regards,
Theodore.

@mostaphaRoudsari
Copy link
Member

💯 for value tracker! will be very cool!

@TheodoreGalanos
Copy link
Collaborator Author

@mostaphaRoudsari Did you have a chance to look into the pyFoamPlotRunner.py utility? I was wondering, in case we can't already use it directly in windows, if we could use the rational of its implementation in BF.

Or if it's not compatible with the docker version somehow we can maybe write our parsing script to plot residuals? I think that's what pyFoam does, gets the residuals from the terminal (always printed at the same place) and charts them with gnuplot or smth. This could be cool!

If we can implement this, then we can potentially create a large amount of value trackers for a variety of situations. To give a small example, imagine an internal simulation where the wind velocity on a Z-section is important. The user then inputs the surface in Gh and we use a simple function object to calculate the average wind velocity on that surface at each timestep. We can then put a value tracker of that on the screen! To make things even cooler, we can link these kind of trackers to our stopping criteria. In the above case it can be smth like this:

IF u_track WITHIN 0.01 FOR 500 iterations THEN stop running

This is just one of the cool options! I can sit down and write all the tracking function objects OF offers and we can display and use them in the same way!

Let me know what you think!

Kind regards,
Theodore.

@mostaphaRoudsari
Copy link
Member

Getting somewhere with this one:

live_plot

and here is a video: https://youtu.be/R3IMHvq9W_c

@mostaphaRoudsari
Copy link
Member

Also, I had a closer look to pyFOAM. Unfortunately, we won't be able to use it directly from IronPython but we should make sure that users can initiate their own pyFOAM scripts from inside Grasshopper.

mostaphaRoudsari added a commit that referenced this issue Sep 24, 2016
Addressed #28, #36, #37 and #53. Grasshopper components need to be
updated and organized before pushing this to the main repository.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants