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.1.1.tar.gz
(6.4 kB
view hashes)
Built Distribution
Close
Hashes for run_elmer-0.1.1-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | e0a705e1a362f2d40a3914f08c1fb1e2e5233ef9a27e82b46dbee7ac7a390dc9 |
|
MD5 | 20ccabe6bb957f3c91008b76741b2f5f |
|
BLAKE2b-256 | 08535b61d8f9e3d9855b786dcde8ade5ff19199d444f36b559eeca8bcb4f11da |