FEM: constant vacuum permittivity, add object to overwrite constant

This commit is contained in:
Bernd Hahnebach
2020-06-29 17:46:43 +02:00
parent 986aca5b82
commit 84aba55ea8
8 changed files with 166 additions and 1 deletions

View File

@@ -107,6 +107,7 @@ SET(FemMesh_SRCS
SET(FemObjects_SRCS
femobjects/__init__.py
femobjects/base_fempythonobject.py
femobjects/constant_vacuumpermittivity.py
femobjects/constraint_bodyheatsource.py
femobjects/constraint_electrostaticpotential.py
femobjects/constraint_flowvelocity.py
@@ -390,6 +391,7 @@ SET(FemGuiViewProvider_SRCS
femviewprovider/__init__.py
femviewprovider/view_base_femconstraint.py
femviewprovider/view_base_femobject.py
femviewprovider/view_constant_vacuumpermittivity.py
femviewprovider/view_constraint_bodyheatsource.py
femviewprovider/view_constraint_electrostaticpotential.py
femviewprovider/view_constraint_flowvelocity.py

View File

@@ -56,6 +56,8 @@ using namespace FemGui;
qApp->translate("Workbench", "&Thermal Constraints");
qApp->translate("Workbench", "Constraints without solver");
qApp->translate("Workbench", "&Constraints without solver");
qApp->translate("Workbench", "Overwrite Constants");
qApp->translate("Workbench", "&Overwrite Constants");
//
qApp->translate("Workbench", "Mesh");
qApp->translate("Workbench", "M&esh");
@@ -285,6 +287,10 @@ Gui::MenuItem* Workbench::setupMenuBar() const
<< "FEM_ConstraintGear"
<< "FEM_ConstraintPulley";
Gui::MenuItem* constants = new Gui::MenuItem;
constants->setCommand("&Overwrite Constants");
*constants << "FEM_ConstantVacuumPermittivity";
Gui::MenuItem* model = new Gui::MenuItem;
root->insertItem(item, model);
model->setCommand("M&odel");
@@ -300,7 +306,9 @@ Gui::MenuItem* Workbench::setupMenuBar() const
<< mech
<< thermal
<< "Separator"
<< nosolver;
<< nosolver
<< "Separator"
<< constants;
Gui::MenuItem* mesh = new Gui::MenuItem;
root->insertItem(item, mesh);

View File

@@ -56,6 +56,22 @@ def makeAnalysis(
return obj
# ********* constant objects *********************************************************************
def makeConstantVacuumPermittivity(
doc,
name="ConstantVacuumPermittivity"
):
"""makeConstantVacuumPermittivity(document, [name]):
makes a Fem ConstantVacuumPermittivity object"""
obj = doc.addObject("Fem::ConstraintPython", name)
from femobjects import constant_vacuumpermittivity
constant_vacuumpermittivity.ConstantVacuumPermittivity(obj)
if FreeCAD.GuiUp:
from femviewprovider import view_constant_vacuumpermittivity
view_constant_vacuumpermittivity.VPConstantVacuumPermittivity(obj.ViewObject)
return obj
# ********* constraint objects *******************************************************************
def makeConstraintBearing(
doc,

View File

@@ -133,6 +133,19 @@ class _ClippingPlaneRemoveAll(CommandManager):
FreeCADGui.doCommand(line1 + line2 + line3)
class _ConstantVacuumPermittivity(CommandManager):
"The FEM_ConstantVacuumPermittivity command definition"
def __init__(self):
super(_ConstantVacuumPermittivity, self).__init__()
self.pixmap = "fem-solver-analysis-thermomechanical.svg"
self.menuetext = "Constant vacuum permittivity"
self.tooltip = "Creates a FEM constant vacuum permittivity to overwrite standard value"
self.is_active = "with_document"
self.is_active = "with_analysis"
self.do_activated = "add_obj_on_gui_noset_edit"
class _ConstraintBodyHeatSource(CommandManager):
"The FEM_ConstraintBodyHeatSource command definition"
@@ -787,6 +800,10 @@ FreeCADGui.addCommand(
"FEM_ClippingPlaneRemoveAll",
_ClippingPlaneRemoveAll()
)
FreeCADGui.addCommand(
"FEM_ConstantVacuumPermittivity",
_ConstantVacuumPermittivity()
)
FreeCADGui.addCommand(
"FEM_ConstraintBodyHeatSource",
_ConstraintBodyHeatSource()

View File

@@ -0,0 +1,50 @@
# ***************************************************************************
# * Copyright (c) 2020 Bernd Hahnebach <bernd@bimstatik.org> *
# * *
# * 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 constant vacuum permittivity object"
__author__ = "Bernd Hahnebach"
__url__ = "http://www.freecadweb.org"
## @package constant_vacuumpermittivity
# \ingroup FEM
# \brief FreeCAD FEM constant vacuum permittivity object
from FreeCAD import Units
from femtools import constants
from . import base_fempythonobject
class ConstantVacuumPermittivity(base_fempythonobject.BaseFemPythonObject):
Type = "Fem::ConstantVacuumPermittivity"
def __init__(self, obj):
super(ConstantVacuumPermittivity, self).__init__(obj)
obj.addProperty(
"App::PropertyVacuumPermittivity",
"VacuumPermittivity",
"Constants",
"Set the permittivity of vacuum"
)
obj.VacuumPermittivity = Units.Quantity(constants.vacuum_permittivity())

View File

@@ -158,6 +158,10 @@ class TestObjectType(unittest.TestCase):
"Fem::FemAnalysis",
type_of_obj(ObjectsFem.makeAnalysis(doc))
)
self.assertEqual(
"Fem::ConstantVacuumPermittivity",
type_of_obj(ObjectsFem.makeConstantVacuumPermittivity(doc))
)
self.assertEqual(
"Fem::ConstraintBearing",
type_of_obj(ObjectsFem.makeConstraintBearing(doc))
@@ -363,6 +367,10 @@ class TestObjectType(unittest.TestCase):
ObjectsFem.makeAnalysis(doc),
"Fem::FemAnalysis"
))
self.assertTrue(is_of_type(
ObjectsFem.makeConstantVacuumPermittivity(doc),
"Fem::ConstantVacuumPermittivity"
))
self.assertTrue(is_of_type(
ObjectsFem.makeConstraintBearing(doc),
"Fem::ConstraintBearing"
@@ -579,6 +587,21 @@ class TestObjectType(unittest.TestCase):
"Fem::FemAnalysis"
))
# ConstantVacuumPermittivity
constant_vacuumpermittivity = ObjectsFem.makeConstantVacuumPermittivity(doc)
self.assertTrue(is_derived_from(
constant_vacuumpermittivity,
"App::DocumentObject"
))
self.assertTrue(is_derived_from(
constant_vacuumpermittivity,
"Fem::ConstraintPython"
))
self.assertTrue(is_derived_from(
constant_vacuumpermittivity,
"Fem::ConstantVacuumPermittivity"
))
# ConstraintBearing
constraint_bearing = ObjectsFem.makeConstraintBearing(doc)
self.assertTrue(is_derived_from(
@@ -1301,6 +1324,11 @@ class TestObjectType(unittest.TestCase):
doc
).isDerivedFrom("Fem::FemAnalysis")
)
self.assertTrue(
ObjectsFem.makeConstantVacuumPermittivity(
doc
).isDerivedFrom("Fem::ConstraintPython")
)
self.assertTrue(
ObjectsFem.makeConstraintBearing(
doc
@@ -1549,6 +1577,7 @@ def create_all_fem_objects_doc(
):
analysis = ObjectsFem.makeAnalysis(doc)
analysis.addObject(ObjectsFem.makeConstantVacuumPermittivity(doc))
analysis.addObject(ObjectsFem.makeConstraintBearing(doc))
analysis.addObject(ObjectsFem.makeConstraintBodyHeatSource(doc))
analysis.addObject(ObjectsFem.makeConstraintContact(doc))

View File

@@ -238,6 +238,11 @@ class AnalysisMember():
"""
# get member
# constants
self.cota_vacuumpermittivity = self.get_several_member(
"Fem::ConstantVacuumPermittivity"
)
# materials
std_mats = self.get_several_member(
"Fem::MaterialCommon"

View File

@@ -0,0 +1,38 @@
# ***************************************************************************
# * Copyright (c) 2020 Bernd Hahnebach <bernd@bimstatik.org> *
# * *
# * 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 constant vacuum permittivity ViewProvider for the document object"
__author__ = "Bernd Hahnebach"
__url__ = "http://www.freecadweb.org"
## @package view_constant_vacuumpermittivity
# \ingroup FEM
# \brief FreeCAD FEM Constant VacuumPermittivity ViewProvider
from . import view_base_femconstraint
class VPConstantVacuumPermittivity(view_base_femconstraint.VPBaseFemConstraint):
def getIcon(self):
return ":/icons/fem-solver-analysis-thermomechanical.svg"