Run Elmer FEM from Python
Project description
run-elmer
- Run Elmer FEM (inside a container) from Python
- Requires a working Docker and docker-py installations
- In future: support using noncontainerized Elmer FEM binary
Installation
pip install run-elmer
Usage
import run_elmer as elmer
m = elmer.mesh(
[[0, 0],
[0, 1],
[1, 0],
[1, 1]],
[[0, 1, 2],
[1, 2, 3]]
).refined(2).with_boundaries({
'left': lambda x: x[0] == 0,
'right': lambda x: x[0] == 1,
})
m # use in Elmer?
out = elmer.run(m, """
Header
Mesh DB "." "."
End
Simulation
Coordinate System = Cartesian
Simulation Type = Steady
Post File = "results.vtu"
End
Body 1
Equation = 1
Body Force = 1
End
Body Force 1 :: Source = Real 1.0
Equation 1 :: Active Solvers(1) = 1
Solver 1
Equation = "Poisson"
Variable = "Potential"
Variable DOFs = 1
Procedure = "Poisson" "PoissonSolver"
Linear System Solver = "Direct"
Linear System Direct Method = UMFPack
Steady State Convergence Tolerance = 1e-09
End
Boundary Condition 1
{}
Potential = Real 0
End
""".format(elmer.target_boundaries(m, 'left', 'right')), verbose=False)
out.point_data
{'potential': array([[0. ],
[0. ],
[0. ],
[0. ],
[0. ],
[0.125 ],
[0.125 ],
[0.125 ],
[0. ],
[0. ],
[0.09375],
[0. ],
[0.09375],
[0.09375],
[0.09375],
[0.09375],
[0. ],
[0.09375],
[0. ],
[0.09375],
[0.09375],
[0.125 ],
[0.125 ],
[0.09375],
[0.09375]])}
elmer.plot(m, out.point_data['potential'], edges=True)
<matplotlib.axes._subplots.AxesSubplot at 0x7fe1198e1730>
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
run_elmer-0.2.0.tar.gz
(6.5 kB
view hashes)
Built Distribution
Close
Hashes for run_elmer-0.2.0-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 7a6fab7a5bfc5e7fb7154784ce1f0782d0a23e12de3654e371f12f168bdaa0ea |
|
MD5 | 712c126bab3d507ca22ded458b830c3b |
|
BLAKE2b-256 | 459876f6ff95f380177555211e44eb8459edec97579c618794058825b441e451 |