How to Convert TMESH Data to Text Files in MCNP6 Using Python"

  • Thread starter Thread starter rai915
  • Start date Start date
  • Tags Tags
    Mcnp6 Python
Click For Summary

Discussion Overview

The discussion focuses on converting TMESH data from MCNP6, specifically the unformatted binary mdata, into text files using Python. Participants explore various methods and tools for achieving this conversion, including the use of GRIDCONV and other programming approaches.

Discussion Character

  • Exploratory
  • Technical explanation
  • Debate/contested

Main Points Raised

  • One participant expresses difficulty in converting mdata from TMESH in MCNP6 to a text file using Python, mentioning that GRIDCONV is not suitable for automation.
  • Another participant suggests checking if a mctal file is generated, as it may contain the needed text data when using TMESH.
  • A participant proposes a method for using GRIDCONV in a non-interactive way by automating input through a program, although this is based on an older version of the tool.
  • One participant mentions successfully controlling the interactive GRIDCONV using the pexpect library in Python.

Areas of Agreement / Disagreement

Participants do not reach a consensus on the best method for converting mdata to text files, with multiple approaches discussed and no definitive solution established.

Contextual Notes

Some limitations include uncertainty about the correct settings for the Fortran file output and the specific requirements for using GRIDCONV in an automated context.

rai915
Messages
3
Reaction score
2
I would like to analyse mdata of tmesh in MCNP6 by python, but I am struggling how to convert mdata (unformatted binary) to any text file in python.
I used GRIDCONV but it's not suitable for automations.

I also used scipy.io.Fortrunfile but could not convert the file because I was not sure fortrun setting for output, like endians.
 
Engineering news on Phys.org
Welcome to PF!

Are you also generating a mctal file and does this not have what you need as text when you do a tmesh?

If the data is right https://github.com/ipostuma/MCNPtools might help to plot what you want.
 
Alex A said:
Welcome to PF!

Are you also generating a mctal file and does this not have what you need as text when you do a tmesh?

If the data is right https://github.com/ipostuma/MCNPtools might help to plot what you want.
Thank you for the reply, but I want to have MDATA generated by tmesh option, not mctal.
MDATA is the tmesh tally data, with unformatted binary.
 
I'm assuming the reason you don't want to use gridconv is because it's interactive. What OS are you using?

For linux if you made a program that printed
Code:
y
mdatatext
and ran it with program.py | gridconv
That would take a binary format file called mdata and convert it to a text file called mdatatext
That is three enters, y(enter), mdatatext(enter), and two enters. This is for an older version but if it's changed I imagine it won't be much.

Patching the source would also work, if you don't have the source patching the binary will also work.
 
Thank you Alex, I solved it to control interactive GUIDCONV by pexpect:)
 
  • Like
Likes   Reactions: zhj2024 and Alex A

Similar threads

  • · Replies 24 ·
Replies
24
Views
6K
Replies
1
Views
2K
  • · Replies 4 ·
Replies
4
Views
3K
Replies
3
Views
3K
  • · Replies 3 ·
Replies
3
Views
2K
  • · Replies 10 ·
Replies
10
Views
6K
  • · Replies 1 ·
Replies
1
Views
3K
  • · Replies 29 ·
Replies
29
Views
3K
  • · Replies 1 ·
Replies
1
Views
962
  • · Replies 14 ·
Replies
14
Views
4K