From 52da15b815b4ccfc38d62a2b8c97eafc44af23c1 Mon Sep 17 00:00:00 2001 From: HoWil Date: Mon, 25 May 2020 15:46:00 +0200 Subject: [PATCH] FEM: add elmer electric force equation object --- src/Mod/Fem/CMakeLists.txt | 1 + src/Mod/Fem/Gui/Resources/Fem.qrc | 1 + .../icons/FEM_EquationElectricforce.svg | 79 +++++++++++++++++++ .../Resources/ui/ElectrostaticPotential.ui | 13 ++- src/Mod/Fem/Gui/Workbench.cpp | 2 + src/Mod/Fem/ObjectsFem.py | 12 +++ src/Mod/Fem/femcommands/commands.py | 15 ++++ .../constraint_electrostaticpotential.py | 10 ++- .../elmer/equations/electricforce.py | 53 +++++++++++++ src/Mod/Fem/femsolver/elmer/solver.py | 2 + src/Mod/Fem/femsolver/equationbase.py | 10 +++ .../view_constraint_electrostaticpotential.py | 5 ++ 12 files changed, 198 insertions(+), 5 deletions(-) create mode 100644 src/Mod/Fem/Gui/Resources/icons/FEM_EquationElectricforce.svg create mode 100644 src/Mod/Fem/femsolver/elmer/equations/electricforce.py diff --git a/src/Mod/Fem/CMakeLists.txt b/src/Mod/Fem/CMakeLists.txt index aab9e6d57a..d253e19186 100755 --- a/src/Mod/Fem/CMakeLists.txt +++ b/src/Mod/Fem/CMakeLists.txt @@ -159,6 +159,7 @@ SET(FemSolverElmer_SRCS SET(FemSolverElmerEquations_SRCS femsolver/elmer/equations/__init__.py + femsolver/elmer/equations/electricforce.py femsolver/elmer/equations/electrostatic.py femsolver/elmer/equations/elasticity.py femsolver/elmer/equations/equation.py diff --git a/src/Mod/Fem/Gui/Resources/Fem.qrc b/src/Mod/Fem/Gui/Resources/Fem.qrc index a02c0332c2..986e630862 100755 --- a/src/Mod/Fem/Gui/Resources/Fem.qrc +++ b/src/Mod/Fem/Gui/Resources/Fem.qrc @@ -35,6 +35,7 @@ icons/FEM_ElementGeometry2D.svg icons/FEM_ElementRotation1D.svg icons/FEM_EquationElasticity.svg + icons/FEM_EquationElectricforce.svg icons/FEM_EquationElectrostatic.svg icons/FEM_EquationFlow.svg icons/FEM_EquationFluxsolver.svg diff --git a/src/Mod/Fem/Gui/Resources/icons/FEM_EquationElectricforce.svg b/src/Mod/Fem/Gui/Resources/icons/FEM_EquationElectricforce.svg new file mode 100644 index 0000000000..3ca9b4d762 --- /dev/null +++ b/src/Mod/Fem/Gui/Resources/icons/FEM_EquationElectricforce.svg @@ -0,0 +1,79 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + image/svg+xml + + + + + [Alexander Gryson] + + + fem-warp + 2017-03-11 + http://www.freecadweb.org/wiki/index.php?title=Artwork + + + FreeCAD + + + FreeCAD/src/Mod/ + + + FreeCAD LGPL2+ + + + https://www.gnu.org/copyleft/lesser.html + + + [agryson] Alexander Gryson + + + + + + + + + Fes + \ No newline at end of file diff --git a/src/Mod/Fem/Gui/Resources/ui/ElectrostaticPotential.ui b/src/Mod/Fem/Gui/Resources/ui/ElectrostaticPotential.ui index 3e34d1718d..e0b1a1b981 100644 --- a/src/Mod/Fem/Gui/Resources/ui/ElectrostaticPotential.ui +++ b/src/Mod/Fem/Gui/Resources/ui/ElectrostaticPotential.ui @@ -7,7 +7,7 @@ 0 0 400 - 154 + 180 @@ -41,7 +41,7 @@ - + @@ -110,13 +110,20 @@ - + Capacity Body: + + + + Calculate Electric Force + + + diff --git a/src/Mod/Fem/Gui/Workbench.cpp b/src/Mod/Fem/Gui/Workbench.cpp index b93d94dfb1..162e50eb9a 100755 --- a/src/Mod/Fem/Gui/Workbench.cpp +++ b/src/Mod/Fem/Gui/Workbench.cpp @@ -158,6 +158,7 @@ Gui::ToolBarItem* Workbench::setupToolBars() const << "FEM_EquationElectrostatic" << "FEM_EquationFlow" << "FEM_EquationFluxsolver" + << "FEM_EquationElectricforce" << "FEM_EquationHeat" << "Separator" << "FEM_SolverControl" @@ -287,6 +288,7 @@ Gui::MenuItem* Workbench::setupMenuBar() const << "FEM_EquationElectrostatic" << "FEM_EquationFlow" << "FEM_EquationFluxsolver" + << "FEM_EquationElectricforce" << "FEM_EquationHeat" << "Separator" << "FEM_SolverControl" diff --git a/src/Mod/Fem/ObjectsFem.py b/src/Mod/Fem/ObjectsFem.py index b469725960..3542c4a92c 100644 --- a/src/Mod/Fem/ObjectsFem.py +++ b/src/Mod/Fem/ObjectsFem.py @@ -638,6 +638,18 @@ def makeEquationElasticity( return obj +def makeEquationElectricforce( + doc, + base_solver +): + """makeEquationElectricforce(document, base_solver): + creates a FEM Electricforce equation for a solver""" + obj = doc.SolverElmer.addObject( + doc.SolverElmer.Proxy.createEquation(doc.SolverElmer.Document, "Electricforce") + )[0] + return obj + + def makeEquationElectrostatic( doc, base_solver diff --git a/src/Mod/Fem/femcommands/commands.py b/src/Mod/Fem/femcommands/commands.py index a544ae5d24..0c88c89b62 100644 --- a/src/Mod/Fem/femcommands/commands.py +++ b/src/Mod/Fem/femcommands/commands.py @@ -294,6 +294,17 @@ class _EquationFluxsolver(CommandManager): self.do_activated = "add_obj_on_gui_selobj_noset_edit" +class _EquationElectricforce(CommandManager): + "The FEM_EquationElectricforce command definition" + + def __init__(self): + super(_EquationElectricforce, self).__init__() + self.menuetext = "Electricforce equation" + self.tooltip = "Creates a FEM equation for electric forces" + self.is_active = "with_solver_elmer" + self.do_activated = "add_obj_on_gui_selobj_noset_edit" + + class _EquationHeat(CommandManager): "The FEM_EquationHeat command definition" @@ -821,6 +832,10 @@ FreeCADGui.addCommand( "FEM_EquationFluxsolver", _EquationFluxsolver() ) +FreeCADGui.addCommand( + "FEM_EquationElectricforce", + _EquationElectricforce() +) FreeCADGui.addCommand( "FEM_EquationHeat", _EquationHeat() diff --git a/src/Mod/Fem/femobjects/constraint_electrostaticpotential.py b/src/Mod/Fem/femobjects/constraint_electrostaticpotential.py index 62e5c634eb..caa7fe9402 100644 --- a/src/Mod/Fem/femobjects/constraint_electrostaticpotential.py +++ b/src/Mod/Fem/femobjects/constraint_electrostaticpotential.py @@ -62,13 +62,19 @@ class ConstraintElectrostaticPotential(base_fempythonobject.BaseFemPythonObject) "ElectricInfinity", "Parameter", "Electric Infinity" - ) + ), + obj.addProperty( + "App::PropertyBool", + "ElectricForcecalculation", + "Parameter", + "Electric Force Calculation" + ), obj.addProperty( "App::PropertyInteger", "CapacitanceBody", "Parameter", "Capacitance Body" - ) + ), obj.addProperty( "App::PropertyBool", "CapacitanceBodyEnabled", diff --git a/src/Mod/Fem/femsolver/elmer/equations/electricforce.py b/src/Mod/Fem/femsolver/elmer/equations/electricforce.py new file mode 100644 index 0000000000..ce1b27d289 --- /dev/null +++ b/src/Mod/Fem/femsolver/elmer/equations/electricforce.py @@ -0,0 +1,53 @@ +# *************************************************************************** +# * Copyright (c) 2020 Wilfried Hortschitz * +# * * +# * This file is part of the FreeCAD CAx development system. * +# * * +# * 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__ = "FreeCAD FEM solver Elmer equation object Electricforce" +__author__ = "Wilfried Hortschitz" +__url__ = "http://www.freecadweb.org" + +## \addtogroup FEM +# @{ + +from femtools import femutils +from ... import equationbase +from . import linear + + +def create(doc, name="Electricforce"): + return femutils.createObject( + doc, name, Proxy, ViewProxy) + + +class Proxy(linear.Proxy, equationbase.ElectricforceProxy): + + Type = "Fem::EquationElectricforce" + + def __init__(self, obj): + super(Proxy, self).__init__(obj) + obj.Priority = 5 + + +class ViewProxy(linear.ViewProxy, equationbase.ElectricforceViewProxy): + pass + +## @} diff --git a/src/Mod/Fem/femsolver/elmer/solver.py b/src/Mod/Fem/femsolver/elmer/solver.py index e24ff49a72..7858948c3f 100644 --- a/src/Mod/Fem/femsolver/elmer/solver.py +++ b/src/Mod/Fem/femsolver/elmer/solver.py @@ -33,6 +33,7 @@ from .equations import elasticity from .equations import electrostatic from .equations import flow from .equations import fluxsolver +from .equations import electricforce from .equations import heat from .. import run from .. import solverbase @@ -54,6 +55,7 @@ class Proxy(solverbase.Proxy): "Elasticity": elasticity, "Electrostatic": electrostatic, "Fluxsolver": fluxsolver, + "Electricforce": electricforce, "Flow": flow, } diff --git a/src/Mod/Fem/femsolver/equationbase.py b/src/Mod/Fem/femsolver/equationbase.py index a2f1d32860..8a238ce453 100644 --- a/src/Mod/Fem/femsolver/equationbase.py +++ b/src/Mod/Fem/femsolver/equationbase.py @@ -109,6 +109,16 @@ class FluxsolverProxy(BaseProxy): pass +class ElectricforceViewProxy(BaseViewProxy): + + def getIcon(self): + return ":/icons/FEM_EquationElectricforce.svg" + + +class ElectricforceProxy(BaseProxy): + pass + + class FlowProxy(BaseProxy): pass diff --git a/src/Mod/Fem/femviewprovider/view_constraint_electrostaticpotential.py b/src/Mod/Fem/femviewprovider/view_constraint_electrostaticpotential.py index 549cd68ee4..8835a72953 100644 --- a/src/Mod/Fem/femviewprovider/view_constraint_electrostaticpotential.py +++ b/src/Mod/Fem/femviewprovider/view_constraint_electrostaticpotential.py @@ -114,6 +114,9 @@ class _TaskPanel(object): self._paramWidget.electricInfinityBox.setChecked( self._obj.ElectricInfinity) + self._paramWidget.electricForcecalculationBox.setChecked( + self._obj.ElectricForcecalculation) + self._paramWidget.capacitanceBodyBox.setChecked( not self._obj.CapacitanceBodyEnabled) self._paramWidget.capacitanceBody_spinBox.setValue( @@ -142,6 +145,8 @@ class _TaskPanel(object): self._obj.ElectricInfinity = self._paramWidget.electricInfinityBox.isChecked() + self._obj.ElectricForcecalculation = self._paramWidget.electricForcecalculationBox.isChecked() + self._obj.CapacitanceBodyEnabled = \ not self._paramWidget.capacitanceBodyBox.isChecked() if self._obj.CapacitanceBodyEnabled: