An EPOCH plasma PIC code input file (deck) reader/writer.
Project description
epydeck
An EPOCH plasma PIC code input file (deck) reader/writer.
[!IMPORTANT] Plain numbers and bools are converted directly, everything else is represented as a string. Note that floating point numbers may have their exact form changed.
Installation
Install from PyPI with:
pip install epydeck
or from local checkout:
git clone https://github.com/PlasmaFAIR/epydeck.git
cd epydeck
pip install .
We recommend switching to uv to manage packages.
Usage
The interface follows the standard Python
json
module:
epydeck.load
to read from afile
objectepydeck.loads
to read from an existing stringepydeck.dump
to write to afile
objectepydeck.dumps
to write to a string
import epydeck
# Read from a file with `epydeck.load`
with open(filename) as f:
deck = epydeck.load(f)
print(deck.keys())
# dict_keys(['control', 'boundaries', 'constant', 'species', 'laser', 'output_global', 'output', 'dist_fn'])
# Modify the deck as a usual python dict:
deck["species"]["proton"]["charge"] = 2.0
# Write to file
with open(filename, "w") as f:
epydeck.dump(deck, f)
print(epydeck.dumps(deck))
# ...
# begin:species
# name = proton
# charge = 2.0
# mass = 1836.2
# fraction = 0.5
# number_density = if((r gt ri) and (r lt ro), den_cone, 0.0)
# number_density = if((x gt xi) and (x lt xo) and (r lt ri), den_cone, number_density(proton))
# number_density = if(x gt xo, 0.0, number_density(proton))
# end:species
# ...
Further Examples
Reads from file into a standard Python dict
. Repeated blocks, such
as species
, have an extra level of nesting using the block name
.
Repeated keys, such as number_density
, are represented as a single
key with a list of values. For example, the following input deck:
begin:constant
lambda = 1.06 * micron
omega = 2 * pi * c / lambda
den_cone = 4.0 * critical(omega)
th = 1 * micron / 2.0
ri = abs(x - 5*micron) - sqrt(2.0) * th
ro = abs(x - 5*micron) + sqrt(2.0) * th
xi = 3*micron - th
xo = 3*micron + th
r = sqrt(y^2 + z^2)
end:constant
begin:species
name = proton
charge = 1.0
mass = 1836.2
fraction = 0.5
number_density = if((r gt ri) and (r lt ro), den_cone, 0.0)
number_density = if((x gt xi) and (x lt xo) and (r lt ri), \
den_cone, number_density(proton))
number_density = if(x gt xo, 0.0, number_density(proton))
end:species
begin:species
name = electron
charge = -1.0
mass = 1.0
fraction = 0.5
number_density = number_density(proton)
end:species
is represented by the following dict
:
{
'constant': {
'lambda': '1.06 * micron',
'omega': '2 * pi * c / lambda',
'den_cone': '4.0 * critical(omega)',
'th': '1 * micron / 2.0',
'ri': 'abs(x - 5*micron) - sqrt(2.0) * th',
'ro': 'abs(x - 5*micron) + sqrt(2.0) * th',
'xi': '3*micron - th',
'xo': '3*micron + th',
'r': 'sqrt(y^2 + z^2)',
},
'species': {
'proton': {
'name': 'proton',
'charge': 1.0,
'mass': 1836.2,
'fraction': 0.5,
'number_density': [
'if((r gt ri) and (r lt ro), den_cone, 0.0)',
'if((x gt xi) and (x lt xo) and (r lt ri), den_cone, number_density(proton))',
'if(x gt xo, 0.0, number_density(proton))'
]
},
'electron': {
'name': 'electron',
'charge': -1.0,
'mass': 1.0,
'fraction': 0.5,
'number_density': 'number_density(proton)'
}
}
}
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file epydeck-1.0.0.tar.gz
.
File metadata
- Download URL: epydeck-1.0.0.tar.gz
- Upload date:
- Size: 70.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/5.1.1 CPython/3.12.7
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 8856510149ff1ed5ae87f32b35e576cdea8b980f6a4cf702be62c883d00b8f5c |
|
MD5 | 381c57d5b996fd464f85064189254311 |
|
BLAKE2b-256 | fee9095544f5fc21046c2a0985fc04ca1f33b5453c545f3f1c24573d1099260c |
Provenance
The following attestation bundles were made for epydeck-1.0.0.tar.gz
:
Publisher:
build_publish.yml
on PlasmaFAIR/epydeck
-
Statement type:
https://in-toto.io/Statement/v1
- Predicate type:
https://docs.pypi.org/attestations/publish/v1
- Subject name:
epydeck-1.0.0.tar.gz
- Subject digest:
8856510149ff1ed5ae87f32b35e576cdea8b980f6a4cf702be62c883d00b8f5c
- Sigstore transparency entry: 145110169
- Sigstore integration time:
- Predicate type:
File details
Details for the file epydeck-1.0.0-py3-none-any.whl
.
File metadata
- Download URL: epydeck-1.0.0-py3-none-any.whl
- Upload date:
- Size: 29.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/5.1.1 CPython/3.12.7
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 839a17e2de6e1ec03823d792ed668c68b8585f38634d658648b0032f7449bd1f |
|
MD5 | 8b571795f6cd87646e0c0f4e9313506a |
|
BLAKE2b-256 | c7885b82d32be9d885ed2b242a45e9bbb04cb6eb6378a1bf99339ef5b1f7cdcf |
Provenance
The following attestation bundles were made for epydeck-1.0.0-py3-none-any.whl
:
Publisher:
build_publish.yml
on PlasmaFAIR/epydeck
-
Statement type:
https://in-toto.io/Statement/v1
- Predicate type:
https://docs.pypi.org/attestations/publish/v1
- Subject name:
epydeck-1.0.0-py3-none-any.whl
- Subject digest:
839a17e2de6e1ec03823d792ed668c68b8585f38634d658648b0032f7449bd1f
- Sigstore transparency entry: 145110171
- Sigstore integration time:
- Predicate type: