FEM: elmer, add electrostatic equation

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

View File

@@ -143,6 +143,7 @@ SET(FemEquationsElmer_SRCS
femsolver/elmer/equations/linear.py
femsolver/elmer/equations/nonlinear.py
femsolver/elmer/equations/elasticity.py
femsolver/elmer/equations/electrostatic.py
femsolver/elmer/equations/heat.py
femsolver/elmer/equations/flow.py
)

View File

@@ -102,6 +102,7 @@ INSTALL(
femsolver/elmer/equations/linear.py
femsolver/elmer/equations/nonlinear.py
femsolver/elmer/equations/elasticity.py
femsolver/elmer/equations/electrostatic.py
femsolver/elmer/equations/heat.py
femsolver/elmer/equations/flow.py
DESTINATION

View File

@@ -35,6 +35,7 @@
<file>icons/fem-DataAlongLine.svg</file>
<file>icons/fem-data.svg</file>
<file>icons/fem-elmer.png</file>
<file>icons/fem-equation-electrostatic.svg</file>
<file>icons/fem-equation-elasticity.svg</file>
<file>icons/fem-equation-flow.svg</file>
<file>icons/fem-equation-heat.svg</file>

View File

@@ -0,0 +1,287 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<svg
xmlns:dc="http://purl.org/dc/elements/1.1/"
xmlns:cc="http://creativecommons.org/ns#"
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:svg="http://www.w3.org/2000/svg"
xmlns="http://www.w3.org/2000/svg"
xmlns:xlink="http://www.w3.org/1999/xlink"
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
version="1.1"
id="svg2"
height="64"
width="64"
sodipodi:docname="fem-equation-electrostatic.svg"
inkscape:version="0.92.2 (unknown)">
<sodipodi:namedview
pagecolor="#ffffff"
bordercolor="#666666"
borderopacity="1"
objecttolerance="10"
gridtolerance="10"
guidetolerance="10"
inkscape:pageopacity="0"
inkscape:pageshadow="2"
inkscape:window-width="1920"
inkscape:window-height="1053"
id="namedview13"
showgrid="false"
inkscape:zoom="7.375"
inkscape:cx="50.711007"
inkscape:cy="36.580584"
inkscape:window-x="0"
inkscape:window-y="27"
inkscape:window-maximized="1"
inkscape:current-layer="svg2" />
<defs
id="defs4">
<linearGradient
id="linearGradient959">
<stop
style="stop-color:#cc0000;stop-opacity:1"
offset="0"
id="stop957" />
<stop
id="stop955"
offset="1"
style="stop-color:#729fcf;stop-opacity:1" />
</linearGradient>
<linearGradient
inkscape:collect="always"
id="linearGradient940">
<stop
style="stop-color:#000000;stop-opacity:1;"
offset="0"
id="stop936" />
<stop
style="stop-color:#000000;stop-opacity:0;"
offset="1"
id="stop938" />
</linearGradient>
<linearGradient
id="linearGradient882">
<stop
id="stop876"
offset="0"
style="stop-color:#73d216;stop-opacity:1" />
<stop
style="stop-color:#729fcf;stop-opacity:1"
offset="1"
id="stop878" />
</linearGradient>
<linearGradient
id="linearGradient3802">
<stop
id="stop3804"
offset="0"
style="stop-color:#2e3436;stop-opacity:1" />
<stop
id="stop3806"
offset="1"
style="stop-color:#555753;stop-opacity:1" />
</linearGradient>
<linearGradient
gradientUnits="userSpaceOnUse"
y2="42"
x2="47"
y1="58"
x1="49"
id="linearGradient3808"
xlink:href="#linearGradient3802" />
<linearGradient
inkscape:collect="always"
id="linearGradient3767">
<stop
style="stop-color:#edd400;stop-opacity:1"
offset="0"
id="stop3769" />
<stop
style="stop-color:#fce94f;stop-opacity:1"
offset="1"
id="stop3771" />
</linearGradient>
<linearGradient
inkscape:collect="always"
xlink:href="#linearGradient3767"
id="linearGradient985"
gradientUnits="userSpaceOnUse"
gradientTransform="translate(0,-4)"
x1="32.567314"
y1="41.431564"
x2="5.3436856"
y2="34.638504" />
<linearGradient
gradientTransform="translate(-48.762712,7.1864407)"
inkscape:collect="always"
xlink:href="#linearGradient882"
id="linearGradient4039"
x1="89.610168"
y1="46.389832"
x2="91.338982"
y2="32.542374"
gradientUnits="userSpaceOnUse" />
<linearGradient
id="linearGradient4033">
<stop
style="stop-color:#73d216;stop-opacity:1"
offset="0"
id="stop4035" />
<stop
id="stop4041"
offset="0.5"
style="stop-color:#729fcf;stop-opacity:1" />
<stop
style="stop-color:#cc0000;stop-opacity:1"
offset="1"
id="stop4037" />
</linearGradient>
<linearGradient
inkscape:collect="always"
xlink:href="#linearGradient940"
id="linearGradient942"
x1="14.474576"
y1="24.519833"
x2="32"
y2="28.99441"
gradientUnits="userSpaceOnUse" />
<linearGradient
inkscape:collect="always"
xlink:href="#linearGradient959"
id="linearGradient951"
gradientUnits="userSpaceOnUse"
x1="14.474576"
y1="22.892714"
x2="23.237288"
y2="26.757122" />
<linearGradient
inkscape:collect="always"
xlink:href="#linearGradient959"
id="linearGradient968"
gradientUnits="userSpaceOnUse"
x1="13.324029"
y1="31.713572"
x2="6.5543613"
y2="46.508171" />
</defs>
<metadata
id="metadata7">
<rdf:RDF>
<cc:Work
rdf:about="">
<dc:format>image/svg+xml</dc:format>
<dc:type
rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
<dc:title></dc:title>
<dc:creator>
<cc:Agent>
<dc:title>[Alexander Gryson]</dc:title>
</cc:Agent>
</dc:creator>
<dc:title>fem-warp</dc:title>
<dc:date>2017-03-11</dc:date>
<dc:relation>http://www.freecadweb.org/wiki/index.php?title=Artwork</dc:relation>
<dc:publisher>
<cc:Agent>
<dc:title>FreeCAD</dc:title>
</cc:Agent>
</dc:publisher>
<dc:identifier>FreeCAD/src/Mod/</dc:identifier>
<dc:rights>
<cc:Agent>
<dc:title>FreeCAD LGPL2+</dc:title>
</cc:Agent>
</dc:rights>
<cc:license>https://www.gnu.org/copyleft/lesser.html</cc:license>
<dc:contributor>
<cc:Agent>
<dc:title>[agryson] Alexander Gryson</dc:title>
</cc:Agent>
</dc:contributor>
</cc:Work>
</rdf:RDF>
</metadata>
<path
style="fill:none;stroke:#000000;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"
d="m 55.818182,23.636364 c 0.242424,0 0.242424,0 0,0 z"
id="path2422"
inkscape:connector-curvature="0" />
<path
style="fill:none;stroke:#edd400;stroke-width:2;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"
d="m 39.01243,20.433833 -0.01226,33.535301 20.001105,-8.300993 3.6e-4,-31.867363 z"
id="path3775"
inkscape:connector-curvature="0"
sodipodi:nodetypes="ccccc" />
<path
style="fill:url(#linearGradient968);fill-opacity:1;stroke:#302b00;stroke-width:2;stroke-linecap:butt;stroke-linejoin:round;stroke-opacity:1"
d="M 31,7 3,13 v 38 l 28,-8 z"
id="path987"
inkscape:connector-curvature="0"
sodipodi:nodetypes="ccccc" />
<path
style="fill:none;fill-rule:evenodd;stroke:#000000;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"
d="m 10.169492,14.237288 c 5.968641,-17.70434 27.042427,-9.2173878 33.084745,4.881356"
id="path996"
inkscape:connector-curvature="0"
sodipodi:nodetypes="cc" />
<path
style="fill:none;fill-rule:evenodd;stroke:#000000;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"
d="m 28.61017,11.254237 c 6.128377,-11.64119256 26.317296,-8.3090838 27.932203,4.61017"
id="path998"
inkscape:connector-curvature="0" />
<path
style="fill:none;fill-rule:evenodd;stroke:#000000;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"
d="m 28.20339,42.847458 c 4.499846,10.358397 17.048397,20.21115 23.728813,7.457627"
id="path1002"
inkscape:connector-curvature="0" />
<path
style="fill:none;fill-rule:evenodd;stroke:#000000;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"
d="M 7.1864407,37.830509 39.186441,46.508475"
id="path1004"
inkscape:connector-curvature="0"
sodipodi:nodetypes="cc" />
<path
style="fill:none;fill-rule:evenodd;stroke:#000000;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"
d="M 13.423729,29.830509 36.61017,36.881356"
id="path1006"
inkscape:connector-curvature="0"
sodipodi:nodetypes="cc" />
<path
style="fill:none;fill-rule:evenodd;stroke:#000000;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"
d="m 21.830508,18.847458 c 6.452194,2.008476 12.785072,4.896737 18.983051,7.322034"
id="path1008"
inkscape:connector-curvature="0" />
<path
style="fill:none;fill-rule:evenodd;stroke:#000000;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"
d="m 26.440678,14.644068 22.779661,9.084746"
id="path1010"
inkscape:connector-curvature="0"
sodipodi:nodetypes="cc" />
<path
style="fill:none;fill-rule:evenodd;stroke:#000000;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"
d="M 6.2372881,17.220339 C 15.225151,20.610746 30.815089,27.151576 40,29.830509"
id="path1012"
inkscape:connector-curvature="0"
sodipodi:nodetypes="cc" />
<path
style="fill:none;fill-rule:evenodd;stroke:#000000;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"
d="m 27.118644,39.322034 c 5.616408,1.757311 11.082312,4.851848 16.949153,6.372881"
id="path1014"
inkscape:connector-curvature="0" />
<path
style="fill:none;fill-rule:evenodd;stroke:#000000;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"
d="m 13.016949,44.610169 c 2.083238,9.437775 17.076914,15.720233 24.271187,8.949153"
id="path1016"
inkscape:connector-curvature="0" />
<path
style="fill:none;fill-rule:evenodd;stroke:#000000;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"
d="M 3.5254238,47.322034 C -1.3974185,65.573528 42.983051,72.691425 42.983051,52.745762"
id="path1000"
inkscape:connector-curvature="0"
sodipodi:nodetypes="cc" />
<path
style="fill:url(#linearGradient4039);fill-opacity:1;stroke:#302b00;stroke-width:2;stroke-linecap:butt;stroke-linejoin:round;stroke-opacity:1;font-variant-east_asian:normal;opacity:1;vector-effect:none;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;marker:none"
d="M 61,11 V 47 L 37,57 V 19 Z"
id="path2995"
inkscape:connector-curvature="0" />
</svg>

After

Width:  |  Height:  |  Size: 10 KiB

View File

@@ -116,6 +116,7 @@ Gui::ToolBarItem* Workbench::setupToolBars() const
<< "Separator"
<< "FEM_AddEquationHeat"
<< "FEM_AddEquationElasticity"
<< "FEM_AddEquationElectrostatic"
<< "FEM_AddEquationFlow"
<< "Separator"
<< "FEM_SolverControl"
@@ -218,6 +219,7 @@ Gui::MenuItem* Workbench::setupMenuBar() const
<< "Separator"
<< "FEM_AddEquationHeat"
<< "FEM_AddEquationElasticity"
<< "FEM_AddEquationElectrostatic"
<< "FEM_AddEquationFlow"
<< "Separator"
<< "FEM_SolverControl"

View File

@@ -84,6 +84,19 @@ class Elasticity(_Base):
}
class Electrostatic(_Base):
def getSpecifier(self):
return "Electrostatic"
def GetResources(self):
return {
'Pixmap': 'fem-equation-electrostatic',
'MenuText': "Electrostatic Equation",
'ToolTip': "Creates a FEM equation for electrostatic"
}
class Flow(_Base):
def getSpecifier(self):
@@ -99,4 +112,5 @@ class Flow(_Base):
Gui.addCommand('FEM_AddEquationHeat', Heat())
Gui.addCommand('FEM_AddEquationElasticity', Elasticity())
Gui.addCommand('FEM_AddEquationElectrostatic', Electrostatic())
Gui.addCommand('FEM_AddEquationFlow', Flow())

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