Git Product home page Git Product logo

opacplot2's Introduction

opacplot2

Build Status Docs

Python package for manipulating Equation of State (EoS) and Opacity data.

Opacplot2 includes command-line tools to make EoS tables of various formats available to FLASH. opac-convert converts EoS/opacity tables like SESAME, Propaceos and TOPS into a FLASH-readable IONMIX (.cn4) format. opac-error generates plots comparing the contents of two EoS tables for the same material. It is particularly useful for checking the consistency of conversions made with opac-convert.

Current Status

EoS Opacity opac-convert opac-error
SESAME ✔️ ✔️ ✔️
MULTI† ✔️ ✔️
Propaceos* ✔️ ✔️ ✔️
TOPS‡ ✔️ ✔️ ✔️

*The Propaceos reader is only distributed with a Propaceos license.

Only opacity parsers are available for MULTI.

Only average free electron number and average square free electron number in EoS

Dependencies

opacplot2's dependencies include:

  • numpy
  • six
  • tables
  • matplotlib
  • scipy
  • periodictable
  • hedp (https://github.com/luli/hedp)
  • interpolation (optional for fast interpolation)
  • numba (optional for fast planck integral calculation)
  • beautifulsoup4 (optional for tops_html2txt)

They can be installed as follows:

pip install numpy six tables matplotlib scipy periodictable
pip install git+https://github.com/luli/hedp

For OS X users, it is advised to use Anaconda Python to install matplotlib in order to avoid framework errors:

conda install matplotlib

Installation

This module requires Python 2.7 or 3.5. The latest version can be installed with

pip install git+https://github.com/flash-center/opacplot2

If you have the Propaceos Python reader, in order to include it in the installation, you must install opacplot2 as follows:

git clone https://github.com/flash-center/opacplot2
cp /path/to/opg_propaceos.py opacplot2/opacplot2/
cd opacplot2
python setup.py install

Documentation & Wiki

Full documentation can be found here.

Example output from opac-convert may be found in the wiki.


Warning About the SESAME Database

Many SESAME EoS files have multiple materials. To ensure conversion accuracy, it is important that the SESAME file must have only one material. In order to aid in the process of extracting one material's table from an entire SESAME document, included in the command line tools of opacplot2 is sesame-extract, which will extract a single material table from a SESAME document based on the material ID.

opac-convert

Command line tool for converting EoS Table formats into the IONMIX format that comes with opacplot2.

Supported input file formats:

  • Propaceos (not distributed)
  • SESAME (.ses)
  • MULTI (.opp, .opr, .opz, .eps)
  • TOPS (.html, .tops)

The only supported output format is IONMIX.

Usage

opac-convert [options] myfile.ext

opac-convert will attempt to read your file extension and convert it to IONMIX accordingly. If it is unable to read the extension, you can use the input flag to specify your filetype. Some files need additional information to write to IONMIX, such as atomic numbers. These you must specify with the command line options shown below.

Options

Option Action
-i, --input Specify the input filetype (propaceos, sesame, multi)
--Znum Comma separated list of atomic numbers.
--Xfracs Comma separated list of element fractions.
--outname Specify the output filename.
--log Comma separated list of logarithmic data.
--tabnum SESAME table number (defaults to last).

Example

To specify the files atomic numbers, one may use --Znum with a comma separated list of integers. If more than one atomic number is given, one must also specify the element fractions with --Xfracs. For example, take a SESAME table for CH named myfile.ses:

opac-convert --Znum 1,6 --Xfracs .5,.5 myfile.ses

This will convert myfile.ses to an IONMIX file named myfile.cn4.

Logarithmic Data

If you would like to take the log of the data before you write it to the IONMIX file, use --log with a comma separated list of the data keys as shown below. Each key specified will be written to IONMIX after the base 10 logarithm has been applied.

Data key
Ion number density idens
Temperatures temps
Average ionization Zf_DT
Ion pressure Pi_DT
Electron pressure Pec_DT
Ion internal energy Ui_DT
Electron internal energy Uec_DT
Opacity bounds groups
Rosseland mean opacity opr_mg
absorption Planck mean opacity opp_mg
emission Planck mean opacity emp_mg

For example, in order to specify that the emission Planck Mean Opacity be written logarithmically:

opac-convert --log emp_mg my-file.ext

Troubleshooting

Invalid Literal for int()

The --log flag may be used to fix the following error:

ValueError: invalid literal for int() with base 10

This error arises when the exponent for the data is more than 2 digits long, which IONMIX does not support. What that usually means is that the data was originally stored logarithmically and must be written back to IONMIX as logarithmic data.


opac-error

Command line tool for comparing two EoS table data. Unlike opac-convert, this tool will only compare equation of state data (not opacity). It is particularly useful in checking the consistency of opac-convert by comparing the original file with the converted IONMIX output.

Supported input file formats:

  • Propaceos (not distributed, contact jtlaune at uchicago dot edu.)
  • SESAME (.ses)
  • IONMIX

The output will consist of an error report with maximum absolute % error RMS % error. All % errors are calculated with respect to the first file listed. The user may also opt to create % error plots for the EoS data stored in the file (ion/electron pressure and energy and average ionization). These consist of three plots with resolutions of 10%, 1%, and .01%.

Usage

opac-error [options] myfile_1.ext myfile_2.ext

Much like opac-convert, this tool will first attempt to read the extensions from your EoS tables in order to open them up. However, some file types require additional information, as in opac-convert, which can be specified in the [options]. The options have many of the same names as opac-convert but suffixed by _1 for file 1 or _2 for file 2.

Then, opac-error will create error reports for the following data:

  • Average ionization
  • Electron Ppessure
  • Ion pressure
  • Electron energy
  • Ion energy

Included in the error report, we have

  • Root mean squared % error
  • Maximum absolute % error

If the --plot flag is called, opac-convert will also make error plots and save them as images to the current directory.

Options

Option Action
--filetypes Comma separated list of file types.
--mpi_# Mass per ion (in grams) for IONMIX file 1 or 2.
--Znum_# Comma separated list of atomic numbers for file 1 or 2.
--Xfrac_# Comma separated list of number fractions for file 1 or 2.
--filters_# dens_filter, temp_filter for file 1 or 2.
--tabnum_# SESAME table number for file 1 or 2.
--plot Create % error plots for data.
--writelog Write log file with % errors for data.
--lin_grid Plot using linear axes.

Example

See the wiki.

How It Works

First, opac-convert takes a conservative intersection of the two dens/temp grids from each file. Then it linearly interpolates the data from both files onto the intersection dens/temp grids. Using the interpolated data, it is able to create an error report.

sesame-extract

Usage

Check syntax possibilities:

python sesame_extract.py -h

Extract water (SESAME element 7150 - see the publicly available PDF) information from the 160 MB SESAME ASCII file, and save it into "water.ses":

python sesame_extract.py -o "./water.ses" "$HOME/SESAME/sesame-ec/sesame_ascii" 7150

opacplot2's People

Contributors

focused-hydro-chili avatar icksa avatar iltommi avatar jtlaune avatar rth avatar sfeister avatar yingchaolu avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

opacplot2's Issues

Error message for KeyError is incorrect

An error message in opac-convert.py:

# Use handle_dict to create the eos_dict based on the input format. try: self.eos_dict = self.handle_dict[args.input]() except KeyError: raise KeyError('Must use valid format name.')

May assume a format name error, but this does not match the errors experienced.

usage of eos_plotter.py

I want to plot sesame EOS file using eos_plotter.py but there are no description of usage of this file. Can you let me know how to use this?

not working with tops opacity

Hi,

I am a new FLASH user and trying to use opac-convert on TOPS opacities to get IONMIX, however, I get errors. I am using following command

opac-convert --Znum 14 Si.tops

UnboundLocalError: local variable 'lid_temp' referenced before assignment

Can you please help me?

Thank You!

Best,
Roopendra

Deployment on pypi

As to simplify use of this module some work is necessary to

  1. Remove non critical dependencies (or making them optional dependencies) including matplotlib, numexpr, pytables, scipy, periodictables
  2. Upload this package on pypi so it can be installed with pip install opacplot2

Support for LEOS read and conversion?

Would it be possible to enhance Opacplot2 to allow for the read and conversion of LEOS tables to IONMIX format? A possible use case would be to then leverage OpacMix2’s nice analysis functionalities for LEOS implicitly

Add a test suite

Add a basic test suite with continuous integration on Travis CI.

opac-convert : does not work with MULTI?

When working with MUTLI tables opac-convert seems to focus on opacity tables (opr, opp, opz, eps) and don't try to open the EoS table (.multi). This results in the following error:
"The required EoS data for FLASH is not present...
Aborting the IONMIX file creation...
Warning: Missing EoS data for IONMIX file to run in FLASH"
Is there a simple way to fix this, or can we impose the EoS values to be constant (0)? I technically don't need the EoS only the opacities.

opac-convert

I run opac-convert with my files and it shows the next error:

ValueError: invalid literal for int() with base 10: '1.03000000e+00''

I tried to use --log as shown in the Troubleshooting section, but it doesn't work. I open my SESAME file and remove all the blank spaces and run again opac-convert, now with this error:

IndexError: list index out of range

I don't know what is the error and how to fix it. I've tried to modify my SESAME file but it's OK. I debbuged the open_convert.py and I don't understand exactly where the script stops to work.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.