Spaces:
Build error
Build error
Delete simulators/fenics_simulation.py
Browse files
simulators/fenics_simulation.py
DELETED
|
@@ -1,33 +0,0 @@
|
|
| 1 |
-
from fenics import *
|
| 2 |
-
import numpy as np
|
| 3 |
-
|
| 4 |
-
def run_fenics_simulation(simulation_type, **kwargs):
|
| 5 |
-
length, width, thickness = kwargs["length"], kwargs["width"], kwargs["thickness"]
|
| 6 |
-
mesh = BoxMesh(Point(0, 0, 0), Point(length, width, thickness), 10, 10, 2)
|
| 7 |
-
load = kwargs.get("force", kwargs.get("load", 0))
|
| 8 |
-
|
| 9 |
-
V = VectorFunctionSpace(mesh, "P", 1)
|
| 10 |
-
u = TrialFunction(V)
|
| 11 |
-
v = TestFunction(V)
|
| 12 |
-
|
| 13 |
-
E, nu = 2e11, 0.3
|
| 14 |
-
mu = E / (2.0 * (1.0 + nu))
|
| 15 |
-
lmbda = E * nu / ((1.0 + nu) * (1.0 - 2.0 * nu))
|
| 16 |
-
|
| 17 |
-
def sigma(v):
|
| 18 |
-
return lmbda * nabla_div(v) * Identity(3) + 2 * mu * sym(grad(v))
|
| 19 |
-
|
| 20 |
-
f = Constant((-load, 0, 0))
|
| 21 |
-
a = inner(sigma(u), sym(grad(v))) * dx
|
| 22 |
-
L = dot(f, v) * dx
|
| 23 |
-
|
| 24 |
-
def boundary(x, on_boundary):
|
| 25 |
-
return on_boundary and near(x[0], 0)
|
| 26 |
-
|
| 27 |
-
bc = DirichletBC(V, Constant((0, 0, 0)), boundary)
|
| 28 |
-
u = Function(V)
|
| 29 |
-
solve(a == L, u, bc)
|
| 30 |
-
|
| 31 |
-
stress = np.max(u.vector().get_local())
|
| 32 |
-
deformation = u.vector().norm("l2")
|
| 33 |
-
return stress, deformation
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|