Interactive plotter for Serpent

Questions and discussion about applications, input, output and general user topics
Andrei Fokau
Posts: 77
Joined: Thu Mar 25, 2010 12:25 am
Security question 2: 0
Location: KTH, Stockholm, Sweden
Contact:

Interactive plotter for Serpent

Post by Andrei Fokau » Tue Aug 24, 2010 12:23 pm

Serpent is an excellent tool for calculation of simple geometries and repeated structures. It can be used also for full-core modeling, however, one may find it a bit hard to define a complex geometry without the union operator. Another feature, which one can miss is an interactive plotter for looking for geometry errors like the one for MCNP/X. Since its implementation can be time demanding, I have tried to make a quick workaround solution using the current Serpent features. You can have a look at the following screencast to see what one can do:
- low resolution, fast: http://vimeo.com/14360334
- high resolution, slow: http://neutron.kth.se/public/video/serp ... r-demo.mov

The idea is relatively simple:
1. get a user command
2. read serpent input, remove all lines starting with "set acelib" or "plot",
3. add requested plot commands, and save to temporary file
4. run Serpent and open created PNG-files in an image viewer
5. ask user for another command

Note, that step 2 can fail at certain conditions, be careful.

The tool is written in Ruby 1.9 and can be downloaded at http://github.com/andreif/serpent-plotter
KTH Reactor Physics (Stockholm, Sweden) neutron.kth.se

User avatar
Jaakko Leppänen
Site Admin
Posts: 2202
Joined: Thu Mar 18, 2010 10:43 pm
Security question 2: 0
Location: Espoo, Finland
Contact:

Re: Interactive plotter for Serpent

Post by Jaakko Leppänen » Tue Aug 24, 2010 2:24 pm

WOW! That's very impressive!

With a tool like this, I don't think there is a need for an internal interactive plotting routine. If you want to keep developing this further, just let me know what you need from the Serpent plotter routine. I suppose the plot-only (-plot command line option) mode was inteded for this purpose? Do you think the routine could be optimized more by removing some unnecessary stuff before the call to PlotGeometry()?

I have a few ides for new features as well. For example, It would be nice to have the Serpent plotter parameters available as well, because those can be used to set a mesh plot for the same part of the geometry. So the user could use the interactive plotter to locate a position where he/she wants to see how flux and power behave, and run the simulation with the mesh plotter to get the results.
- Jaakko

Andrei Fokau
Posts: 77
Joined: Thu Mar 25, 2010 12:25 am
Security question 2: 0
Location: KTH, Stockholm, Sweden
Contact:

Re: Interactive plotter for Serpent

Post by Andrei Fokau » Tue Aug 24, 2010 3:47 pm

Jaakko Leppänen wrote:If you want to keep developing this further, just let me know what you need from the Serpent plotter routine.
Jaakko, due to the typical lack of time, I develop this plotter just to save some time on plotting operations. Therefore, new commands appear when I get annoyed by their absence. There is a list of things which I would want to implement, but cannot really say when it will happen.
Jaakko Leppänen wrote:I suppose the plot-only (-plot command line option) mode was inteded for this purpose? Do you think the routine could be optimized more by removing some unnecessary stuff before the call to PlotGeometry()?
Well, honestly, the plot-only option was the way to avoid killing Serpent by Ctrl+C because I was constantly forgetting to remove "set acelib". Now you see that I found a better solution for this problem :) However, the other users probably need the plot-only mode, since the interactive plotter is not very easy to use on other platforms. I strongly support people porting it to other languages (Python would be a nice choice). Also, I believe it can be relatively easy to make a GUI application for Mac on the basis of what has been already done in Ruby, but this year I will not have time for this for sure, and actually for me it feels better with the command-line.

As for me, Serpent runs very fast, so I don't feel that it is possible to speed it up. If plotting takes too long, I simply reduce the resolution and it becomes very fast again.
Jaakko Leppänen wrote:I have a few ideas for new features as well. For example, It would be nice to have the Serpent plotter parameters available as well, because those can be used to set a mesh plot for the same part of the geometry. So the user could use the interactive plotter to locate a position where he/she wants to see how flux and power behave, and run the simulation with the mesh plotter to get the results.
I haven't tried the mesh plotter yet, but I strongly believe that we can do a lot of very cool things with Serpent, thanks to you, Jaakko! Just give me some time to try all the Serpent features!
KTH Reactor Physics (Stockholm, Sweden) neutron.kth.se

Peter Wolniewicz

Re: Interactive plotter for Serpent

Post by Peter Wolniewicz » Wed Aug 25, 2010 1:10 pm

Hi! Could you explain how to run this? I have no clue what ruby is :)

after chmodding it it says

/usr/bin/env: ruby: No such file or directory

:)


cheers ! / Peter

Andrei Fokau
Posts: 77
Joined: Thu Mar 25, 2010 12:25 am
Security question 2: 0
Location: KTH, Stockholm, Sweden
Contact:

Re: Interactive plotter for Serpent

Post by Andrei Fokau » Wed Aug 25, 2010 1:41 pm

Peter Wolniewicz wrote:Hi! Could you explain how to run this? I have no clue what ruby is :)
It is a cool programming language: http://www.ruby-lang.org
Please, use RVM to install it: http://rvm.beginrescueend.com
KTH Reactor Physics (Stockholm, Sweden) neutron.kth.se

User avatar
Jaakko Leppänen
Site Admin
Posts: 2202
Joined: Thu Mar 18, 2010 10:43 pm
Security question 2: 0
Location: Espoo, Finland
Contact:

Re: Interactive plotter for Serpent

Post by Jaakko Leppänen » Tue Sep 28, 2010 8:57 pm

Andrei,

I'm having some problems running ruby, or understanding how the system works, to be more exact. I'm using a MacBook Pro with OS X 10.6.1. Ruby seems to be installed by default, but when I try to run your script, all I get is a long list of errors, so I'm guessing I'm either missing something or I simply cannot run the script properly.

Could you explain in a few words how to actually run the program to get to the interactive console view in your videos? Do I need to set up or start something before that, or should the program start by simply executing the script?
- Jaakko

Andrei Fokau
Posts: 77
Joined: Thu Mar 25, 2010 12:25 am
Security question 2: 0
Location: KTH, Stockholm, Sweden
Contact:

Re: Interactive plotter for Serpent

Post by Andrei Fokau » Tue Sep 28, 2010 9:39 pm

Jaakko Leppänen wrote:I'm having some problems running ruby, or understanding how the system works, to be more exact. I'm using a MacBook Pro with OS X 10.6.1. Ruby seems to be installed by default, but when I try to run your script, all I get is a long list of errors, so I'm guessing I'm either missing something or I simply cannot run the script properly.
Jaakko,

OS X has older version of Ruby (1.8.6 or 1.8.7 depending on the initial version), while the latest stable one is 1.9.2. There were several improvements which simplify coding, so I decided to do not support the older branch. You can try a very nice tool to install different versions of Ruby -- everybody strongly recommends using it. It's called Ruby Version Manager (RVM) and allows installing Ruby in the home directory, which is very handy when one doesn't have the root access. Other options would be macports, and standard installation in the system folders. I did have some difficulties when was playing with architecture type, but everything should work fine with default settings. Let me know if you get a problem.
Jaakko Leppänen wrote:Could you explain in a few words how to actually run the program to get to the interactive console view in your videos? Do I need to set up or start something before that, or should the program start by simply executing the script?
The plotter uses Apple Preview to open/update png-files, and you don't need to set anything. It will create a number of files serpent-plotter.* - you may want to add a few lines in the plotter code to clean them up after exit.

The plotter is run simply by:

Code: Select all

serpent-plotter.rb input
You may want to rename/alias the file to something more convenient :)
KTH Reactor Physics (Stockholm, Sweden) neutron.kth.se

User avatar
Jaakko Leppänen
Site Admin
Posts: 2202
Joined: Thu Mar 18, 2010 10:43 pm
Security question 2: 0
Location: Espoo, Finland
Contact:

Re: Interactive plotter for Serpent

Post by Jaakko Leppänen » Wed Sep 29, 2010 12:49 am

I'm pretty sure it's a version thing. My ruby version was 1.8.7 when I tried to run the script.

I installed rvm and managed to get the latest version (1.9.2). But even if I follow the (very simple instructions) at the website, command ruby -v always returns the old version number. Have you encountered this problem? This is what I get:

Code: Select all

jaakko-leppanens-macbook-pro:~ Jaakko$ rvm list

rvm rubies

   ruby-1.9.1-p378 [ x86_64 ]
=> ruby-1.9.2-p0 [ x86_64 ]

jaakko-leppanens-macbook-pro:~ Jaakko$ ruby -v
ruby 1.8.7 (2009-06-12 patchlevel 174) [i686-darwin10]
Am I missing some obvious step in the installation?
- Jaakko

Andrei Fokau
Posts: 77
Joined: Thu Mar 25, 2010 12:25 am
Security question 2: 0
Location: KTH, Stockholm, Sweden
Contact:

Re: Interactive plotter for Serpent

Post by Andrei Fokau » Wed Sep 29, 2010 9:58 am

Jaakko,

I had similar problem with Ruby version in TextMate, but that was due to the application. Have you executed the following line after installing RVM?

Code: Select all

source ~/.rvm/scripts/rvm
Probably yes, since the script is working. And probably the following command as well

Code: Select all

rvm use ruby-1.9.2-p0
Interesting. Do you use the standard Terminal app? The system cannot find RVM ruby. Do you see rvm paths in output of

Code: Select all

echo $PATH
KTH Reactor Physics (Stockholm, Sweden) neutron.kth.se

User avatar
Jaakko Leppänen
Site Admin
Posts: 2202
Joined: Thu Mar 18, 2010 10:43 pm
Security question 2: 0
Location: Espoo, Finland
Contact:

Re: Interactive plotter for Serpent

Post by Jaakko Leppänen » Wed Sep 29, 2010 11:10 am

Andrei,

I tried all the steps but the version is sill 1.8.7. I am using iTerm, but the version number is the same when I try with terminal. The RVM paths are not in $PATH.
- Jaakko

Post Reply