PlasmaFAIR / epydeck

EPOCH input file reader/writer
GNU General Public License v3.0
2 stars 0 forks source link

Maths parser support #6

Open ShaunD137 opened 4 hours ago

ShaunD137 commented 4 hours ago

It would be helpful if in-line calculations in the input.deck were processed into the result. For example the input.deck might define.

omega = 2.0 * pi * c / (1.0e-6) 

But epydeck will read that as a string instead of calculating the value of 1.88 * 10^15. Also support for variables that reference previous sections would help.

#size of domain
x_min = -4e-6
x_max =  20e-6
y_min = -12e-6
y_max = -y_min

and

number_density = number_density(Electron) / 6

Which sets the number density of one species to be 1/6 the number density of the electron species.

Additional Request: It would also be useful if this functionality would include EPOCH defined functions such as the critical() function:

$$\text{critical}(\omega) = \frac{\omega^2 m_e \epsilon_0}{e^2}$$

JoelLucaAdams commented 3 hours ago

This is definitely an interesting issue that I think could be beneficial although I worry about some of the overhead it might cause by trying to parse everything. I think we should consider it being a function that either gets called exclusively by the user to convert the data or a parameter that is turned off by default and can be called during import deck.load(f, parse_maths=true).

In terms of libraries to use I'm thinking that the scipy library for constants (these could also be coded by hand as there aren't that many according to the docs) and to parse the functions we use the sympy library.