FEM: elmer, add electrostatic equation

This commit is contained in:
Wilfried Hortschitz
2017-12-01 19:43:50 +01:00
committed by wmayer
parent 412df6f4c1
commit 51383aa9a2
10 changed files with 442 additions and 0 deletions

View File

@@ -0,0 +1,70 @@
# ***************************************************************************
# * *
# * Copyright (c) 2017 - Markus Hovorka <m.hovorka@live.de> *
# * *
# * This program is free software; you can redistribute it and/or modify *
# * it under the terms of the GNU Lesser General Public License (LGPL) *
# * as published by the Free Software Foundation; either version 2 of *
# * the License, or (at your option) any later version. *
# * for detail see the LICENCE text file. *
# * *
# * This program is distributed in the hope that it will be useful, *
# * but WITHOUT ANY WARRANTY; without even the implied warranty of *
# * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
# * GNU Library General Public License for more details. *
# * *
# * You should have received a copy of the GNU Library General Public *
# * License along with this program; if not, write to the Free Software *
# * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 *
# * USA *
# * *
# ***************************************************************************
__title__ = "Electrostatic"
__author__ = "Markus Hovorka"
__url__ = "http://www.freecadweb.org"
import FemUtils
from ... import equationbase
from . import linear
def create(doc, name="Electrostatic"):
return FemUtils.createObject(
doc, name, Proxy, ViewProxy)
class Proxy(linear.Proxy, equationbase.ElectrostaticProxy):
Type = "Fem::FemEquationElmerElectrostatic"
def __init__(self, obj):
super(Proxy, self).__init__(obj)
obj.addProperty(
"App::PropertyBool", "CalculateElectricField",
"Electrostatic", "Select type of solver for linear system")
obj.addProperty(
"App::PropertyBool", "CalculateElectricFlux",
"Electrostatic", "Select type of solver for linear system")
obj.addProperty(
"App::PropertyBool", "CalculateElectricEnergy",
"Electrostatic", "Select type of solver for linear system")
obj.addProperty(
"App::PropertyBool", "CalculateSurfaceCharge",
"Electrostatic", "Select type of solver for linear system")
'''
#obj.addProperty(
#"App::PropertyBool", "CalculateCapacitanceMatrix",
#"Electrostatic", "Select type of solver for linear system")
#obj.addProperty(
#"App::PropertyInteger", "CapacitanceBodies",
#"Electrostatic", "Select type of solver for linear system")
'''
obj.Priority = 10
class ViewProxy(linear.ViewProxy, equationbase.ElectrostaticViewProxy):
pass

View File

@@ -34,6 +34,7 @@ from . import tasks
from .equations import heat
from .equations import elasticity
from .equations import electrostatic
from .equations import flow
@@ -50,6 +51,7 @@ class Proxy(solverbase.Proxy):
_EQUATIONS = {
"Heat": heat,
"Elasticity": elasticity,
"Electrostatic": electrostatic,
"Flow": flow,
}

View File

@@ -106,6 +106,7 @@ class Writer(object):
self._handleSimulation()
self._handleHeat()
self._handleElasticity()
self._handleElectrostatic()
self._handleFlow()
self._addOutputSolver()
@@ -280,6 +281,59 @@ class Writer(object):
name, "Heat Capacity",
convert(m["SpecificHeat"], "L^2/(T^2*O)"))
def _handleElectrostatic(self):
activeIn = []
for equation in self.solver.Group:
if FemUtils.isOfType(equation, "Fem::FemEquationElmerElectrostatic"):
if equation.References:
activeIn = equation.References[0][1]
else:
activeIn = self._getAllBodies()
solverSection = self._getElectrostaticSolver(equation)
for body in activeIn:
self._addSolver(body, solverSection)
if activeIn:
self._handleElectrostaticConstants()
#self._handleElectrostaticBndConditions()
#self._handleElectrostaticInitial(activeIn)
#self._handleElectrostaticBodyForces(activeIn)
self._handleElectrostaticMaterial(activeIn)
def _getElectrostaticSolver(self, equation):
s = self._createLinearSolver(equation)
s["Equation"] = "Stat Elec Solver" # equation.Name
s["Procedure"] = sifio.FileAttr("StatElecSolve/StatElecSolver")
s["Variable"] = self._getUniqueVarName("Potential")
s["Variable DOFs"] = 1
s["Calculate Electric Field"] = equation.CalculateElectricField
s["Calculate Electric Flux"] = equation.CalculateElectricFlux
s["Calculate Electric Energy"] = equation.CalculateElectricEnergy
s["Calculate Surface Charge"] = equation.CalculateSurfaceCharge
s["Displace mesh"] = False
s["Exec Solver"] = "Always"
s["Stabilize"] = equation.Stabilize
s["Bubbles"] = equation.Bubbles
s["Optimize Bandwidth"] = True
return s
def _handleElectrostaticConstants(self):
self._constant(
"Permittivity Of Vacuum",
getConstant("PermittivityOfVacuum", "T^4*I^2/(L*M)"))
def _handleElectrostaticMaterial(self, bodies):
for obj in self._getMember("App::MaterialObject"):
m = obj.Material
refs = (
obj.References[0][1]
if obj.References
else self._getAllBodies())
for name in (n for n in refs if n in bodies):
if "RelativePermittivity" in m:
self._material(
name, "Relative Permittivity",
float(m["RelativePermittivity"]))
def _handleElasticity(self):
activeIn = []
for equation in self.solver.Group:

View File

@@ -86,6 +86,16 @@ class ElasticityViewProxy(BaseViewProxy):
return ":/icons/fem-equation-elasticity.svg"
class ElectrostaticViewProxy(BaseViewProxy):
def getIcon(self):
return ":/icons/fem-equation-electrostatic.svg"
class ElectrostaticProxy(BaseProxy):
pass
class FlowProxy(BaseProxy):
pass