Fem: Update electromagnetics boundary conditions

This commit is contained in:
marioalexis
2025-01-20 00:33:19 -03:00
parent 30c7efbc60
commit 0194070ce9
4 changed files with 176 additions and 232 deletions

View File

@@ -14,12 +14,12 @@
<string>Analysis feature properties</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<item row="0" column="0">
<widget class="QGroupBox" name="gb_boundary_condition">
<property name="title">
<string></string>
</property>
<layout class="QGridLayout" name="gridLayout_4">
<layout class="QFormLayout" name="gridLayout_4">
<item row="0" column="0">
<widget class="QLabel" name="lbl_boundary_condition">
<property name="text">
@@ -41,9 +41,9 @@
<property name="checkable">
<bool>false</bool>
</property>
<layout class="QGridLayout" name="gridLayout_6">
<item row="0" column="0">
<layout class="QGridLayout" name="gridLayout">
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<layout class="QFormLayout" name="gridLayout">
<item row="0" column="0">
<widget class="QCheckBox" name="ckb_potential">
<property name="text">
@@ -75,8 +75,8 @@
</item>
</layout>
</item>
<item row="1" column="0">
<widget class="QCheckBox" name="vectorFieldBox">
<item row="3" column="0">
<widget class="QCheckBox" name="ckb_electromagnetic">
<property name="toolTip">
<string>To define scalar potential and magnetic vector potential</string>
</property>
@@ -88,8 +88,11 @@
</property>
</widget>
</item>
<item row="2" column="0">
<widget class="QGroupBox" name="vectorFieldGB">
<item row="4" column="0">
<widget class="QGroupBox" name="gb_electromagnetic">
<property name="title">
<string></string>
</property>
<property name="enabled">
<bool>true</bool>
</property>
@@ -100,10 +103,7 @@ with a harmonic/oscillating driving force</string>
<property name="checkable">
<bool>false</bool>
</property>
<property name="checked">
<bool>false</bool>
</property>
<layout class="QGridLayout" name="gridLayout_3">
<layout class="QGridLayout" name="gridLayout_3" columnstretch="0,0,255,0,255">
<item row="0" column="2">
<widget class="QLabel" name="labelReal">
<property name="enabled">
@@ -136,9 +136,6 @@ with a harmonic/oscillating driving force</string>
</item>
<item row="1" column="1">
<widget class="QCheckBox" name="ckb_av_re">
<property name="toolTip">
<string>unspecified</string>
</property>
<property name="text">
<string/>
</property>
@@ -147,13 +144,10 @@ with a harmonic/oscillating driving force</string>
<item row="1" column="2">
<widget class="Gui::QuantitySpinBox" name="qsb_av_re">
<property name="enabled">
<bool>false</bool>
<bool>true</bool>
</property>
<property name="toolTip">
<string>Potential as specified above</string>
</property>
<property name="readOnly">
<bool>true</bool>
<string>Real part of scalar potential</string>
</property>
<property name="keyboardTracking">
<bool>true</bool>
@@ -171,9 +165,6 @@ with a harmonic/oscillating driving force</string>
</item>
<item row="1" column="3">
<widget class="QCheckBox" name="ckb_av_im">
<property name="toolTip">
<string>unspecified</string>
</property>
<property name="text">
<string/>
</property>
@@ -213,9 +204,6 @@ with a harmonic/oscillating driving force</string>
</item>
<item row="2" column="1">
<widget class="QCheckBox" name="ckb_av_re_1">
<property name="toolTip">
<string>unspecified</string>
</property>
<property name="text">
<string/>
</property>
@@ -246,9 +234,6 @@ Note: has no effect if a solid was selected</string>
</item>
<item row="2" column="3">
<widget class="QCheckBox" name="ckb_av_im_1">
<property name="toolTip">
<string>unspecified</string>
</property>
<property name="text">
<string/>
</property>
@@ -289,9 +274,6 @@ Note: has no effect if a solid was selected</string>
</item>
<item row="3" column="1">
<widget class="QCheckBox" name="ckb_av_re_2">
<property name="toolTip">
<string>unspecified</string>
</property>
<property name="text">
<string/>
</property>
@@ -322,9 +304,6 @@ Note: has no effect if a solid was selected</string>
</item>
<item row="3" column="3">
<widget class="QCheckBox" name="ckb_av_im_2">
<property name="toolTip">
<string>unspecified</string>
</property>
<property name="text">
<string/>
</property>
@@ -365,9 +344,6 @@ Note: has no effect if a solid was selected</string>
</item>
<item row="4" column="1">
<widget class="QCheckBox" name="ckb_av_re_3">
<property name="toolTip">
<string>unspecified</string>
</property>
<property name="text">
<string/>
</property>
@@ -398,9 +374,6 @@ Note: has no effect if a solid was selected</string>
</item>
<item row="4" column="3">
<widget class="QCheckBox" name="ckb_av_im_3">
<property name="toolTip">
<string>unspecified</string>
</property>
<property name="text">
<string/>
</property>
@@ -432,64 +405,28 @@ Note: has no effect if a solid was selected</string>
</layout>
</widget>
</item>
<item row="3" column="0">
<widget class="QCheckBox" name="ckb_electric_infinity">
<property name="enabled">
<bool>true</bool>
</property>
<property name="toolTip">
<string>Whether the boundary condition defines a farfield potential</string>
</property>
<property name="text">
<string>Farfield / Electric infinity</string>
</property>
</widget>
</item>
<item row="4" column="0">
<widget class="QCheckBox" name="ckb_potential_constant">
<property name="toolTip">
<string>Whether the boundary condition defines a constant potential</string>
</property>
<property name="text">
<string>Potential Constant</string>
</property>
</widget>
</item>
<item row="5" column="0">
<widget class="QCheckBox" name="ckb_electric_forcecalculation">
<property name="toolTip">
<string>Whether the boundary condition is for the electric force</string>
</property>
<property name="text">
<string>Calculate Electric Force</string>
</property>
</widget>
</item>
<item row="6" column="0">
<layout class="QGridLayout" name="gridLayout_2">
<item row="0" column="0">
<widget class="QCheckBox" name="ckb_capacitance_body">
<property name="text">
<string>Capacitance Body:</string>
<item>
<layout class="QGridLayout" name="gridLayout">
<item row="3" column="0">
<widget class="QCheckBox" name="ckb_electric_infinity">
<property name="enabled">
<bool>true</bool>
</property>
<property name="toolTip">
<string>Enabled by 'Calculate Capacity Matrix' in Electrostatic equation</string>
<string>Whether the boundary condition defines a farfield potential</string>
</property>
<property name="text">
<string>Electric Infinity</string>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QSpinBox" name="spb_capacitance_body">
<item row="3" column="1">
<widget class="QCheckBox" name="ckb_potential_constant">
<property name="toolTip">
<string>Counter of the body (or face) with a capacitance</string>
<string>Whether the boundary condition defines a constant potential</string>
</property>
<property name="enabled">
<bool>false</bool>
</property>
<property name="minimum">
<number>1</number>
</property>
<property name="value">
<number>1</number>
<property name="text">
<string>Potential Constant</string>
</property>
</widget>
</item>
@@ -503,7 +440,7 @@ Note: has no effect if a solid was selected</string>
<property name="title">
<string>Neumann</string>
</property>
<layout class="QGridLayout" name="gridLayout_8">
<layout class="QFormLayout" name="gridLayout_8">
<item row="0" column="0">
<widget class="QLabel" name="surfacechargedensityLbl">
<property name="text">
@@ -524,6 +461,41 @@ Note: has no effect if a solid was selected</string>
</layout>
</widget>
</item>
<item row="3" column="0">
<widget class="QGroupBox" name="gb_boundary_condition">
<property name="title">
<string>Capacitance</string>
</property>
<layout class="QFormLayout" name="gridLayout">
<item row="6" column="0">
<widget class="QCheckBox" name="ckb_capacitance_body">
<property name="text">
<string>Capacitance Body:</string>
</property>
<property name="toolTip">
<string>Enabled by 'Calculate Capacity Matrix' in Electrostatic equation</string>
</property>
</widget>
</item>
<item row="6" column="1">
<widget class="Gui::IntSpinBox" name="spb_capacitance_body">
<property name="toolTip">
<string>Counter of the body (or face) with a capacitance</string>
</property>
<property name="enabled">
<bool>false</bool>
</property>
<property name="minimum">
<number>1</number>
</property>
<property name="value">
<number>1</number>
</property>
</widget>
</item>
</layout>
</widget>
</item>
</layout>
</widget>
<customwidgets>
@@ -532,9 +504,11 @@ Note: has no effect if a solid was selected</string>
<extends>QWidget</extends>
<header>Gui/QuantitySpinBox.h</header>
</customwidget>
<customwidget>
<class>Gui::IntSpinBox</class>
<extends>QWidget</extends>
<header>Gui/SpinBox.h</header>
</customwidget>
</customwidgets>
<resources/>
<buttongroups>
<buttongroup name="BCtypeBG"/>
</buttongroups>
</ui>

View File

@@ -32,6 +32,8 @@ __url__ = "https://www.freecad.org"
# \ingroup FEM
# \brief constraint electrostatic potential object
from FreeCAD import Base
from . import base_fempythonobject
_PropHelper = base_fempythonobject._PropHelper
@@ -68,12 +70,30 @@ class ConstraintElectrostaticPotential(base_fempythonobject.BaseFemPythonObject)
value=True,
)
)
prop.append(
_PropHelper(
type="App::PropertyElectricPotential",
name="AV_re",
group="Electromagnetic Potential",
doc="Real part of scalar potential",
value="0 V",
)
)
prop.append(
_PropHelper(
type="App::PropertyElectricPotential",
name="AV_im",
group="Electromagnetic Potential",
doc="Imaginary part of scalar potential",
value="0 V",
)
)
prop.append(
_PropHelper(
type="App::PropertyElectromagneticPotential",
name="AV_re_1",
group="Vector Potential",
doc="Real part of potential x-component",
group="Electromagnetic Potential",
doc="Real part of vector potential x-component",
value="0 Wb/m",
)
)
@@ -81,8 +101,8 @@ class ConstraintElectrostaticPotential(base_fempythonobject.BaseFemPythonObject)
_PropHelper(
type="App::PropertyElectromagneticPotential",
name="AV_re_2",
group="Vector Potential",
doc="Real part of potential y-component",
group="Electromagnetic Potential",
doc="Real part of vector potential y-component",
value="0 Wb/m",
)
)
@@ -90,8 +110,8 @@ class ConstraintElectrostaticPotential(base_fempythonobject.BaseFemPythonObject)
_PropHelper(
type="App::PropertyElectromagneticPotential",
name="AV_re_3",
group="Vector Potential",
doc="Real part of potential z-component",
group="Electromagnetic Potential",
doc="Real part of vector potential z-component",
value="0 Wb/m",
)
)
@@ -99,8 +119,8 @@ class ConstraintElectrostaticPotential(base_fempythonobject.BaseFemPythonObject)
_PropHelper(
type="App::PropertyElectromagneticPotential",
name="AV_im_1",
group="Vector Potential",
doc="Imaginary part of potential x-component",
group="Electromagnetic Potential",
doc="Imaginary part of vector potential x-component",
value="0 Wb/m",
)
)
@@ -108,8 +128,8 @@ class ConstraintElectrostaticPotential(base_fempythonobject.BaseFemPythonObject)
_PropHelper(
type="App::PropertyElectromagneticPotential",
name="AV_im_2",
group="Vector Potential",
doc="Imaginary part of potential y-component",
group="Electromagnetic Potential",
doc="Imaginary part of vector potential y-component",
value="0 Wb/m",
)
)
@@ -117,8 +137,8 @@ class ConstraintElectrostaticPotential(base_fempythonobject.BaseFemPythonObject)
_PropHelper(
type="App::PropertyElectromagneticPotential",
name="AV_im_3",
group="Vector Potential",
doc="Imaginary part of potential z-component",
group="Electromagnetic Potential",
doc="Imaginary part of vector potential z-component",
value="0 Wb/m",
)
)
@@ -140,20 +160,11 @@ class ConstraintElectrostaticPotential(base_fempythonobject.BaseFemPythonObject)
value=["Dirichlet", "Neumann"],
)
)
prop.append(
_PropHelper(
type="App::PropertyElectricPotential",
name="AV_im",
group="Parameter",
doc="Imaginary part of scalar potential",
value="0 V",
)
)
prop.append(
_PropHelper(
type="App::PropertyBool",
name="AV_re_1_Disabled",
group="Vector Potential",
group="Electromagnetic Potential",
doc="",
value=True,
)
@@ -162,7 +173,7 @@ class ConstraintElectrostaticPotential(base_fempythonobject.BaseFemPythonObject)
_PropHelper(
type="App::PropertyBool",
name="AV_re_2_Disabled",
group="Vector Potential",
group="Electromagnetic Potential",
doc="",
value=True,
)
@@ -171,7 +182,7 @@ class ConstraintElectrostaticPotential(base_fempythonobject.BaseFemPythonObject)
_PropHelper(
type="App::PropertyBool",
name="AV_re_3_Disabled",
group="Vector Potential",
group="Electromagnetic Potential",
doc="",
value=True,
)
@@ -180,7 +191,7 @@ class ConstraintElectrostaticPotential(base_fempythonobject.BaseFemPythonObject)
_PropHelper(
type="App::PropertyBool",
name="AV_im_1_Disabled",
group="Vector Potential",
group="Electromagnetic Potential",
doc="",
value=True,
)
@@ -189,7 +200,7 @@ class ConstraintElectrostaticPotential(base_fempythonobject.BaseFemPythonObject)
_PropHelper(
type="App::PropertyBool",
name="AV_im_2_Disabled",
group="Vector Potential",
group="Electromagnetic Potential",
doc="",
value=True,
)
@@ -198,7 +209,16 @@ class ConstraintElectrostaticPotential(base_fempythonobject.BaseFemPythonObject)
_PropHelper(
type="App::PropertyBool",
name="AV_im_3_Disabled",
group="Vector Potential",
group="Electromagnetic Potential",
doc="",
value=True,
)
)
prop.append(
_PropHelper(
type="App::PropertyBool",
name="AV_re_Disabled",
group="Electromagnetic Potential",
doc="",
value=True,
)
@@ -207,7 +227,7 @@ class ConstraintElectrostaticPotential(base_fempythonobject.BaseFemPythonObject)
_PropHelper(
type="App::PropertyBool",
name="AV_im_Disabled",
group="Vector Potential",
group="Electromagnetic Potential",
doc="",
value=True,
)

View File

@@ -31,6 +31,7 @@ __url__ = "https://www.freecad.org"
from FreeCAD import Console
from FreeCAD import Units
from femtools import femutils
from .. import sifio
from .. import writer as general_writer
@@ -289,29 +290,27 @@ class MgDynwriter:
currentDensity = float(obj.CurrentDensity_im_1.getValueAs("A/m^2"))
self.write.boundary(name, "Current Density Im 1", round(currentDensity, 6))
if hasattr(obj, "PotentialEnabled"):
# check for PotentialEnabled not Potential since PotentialEnabled was
# added later and only with this the vectorial properties are available
if obj.PotentialEnabled:
potential = float(obj.Potential.getValueAs("V"))
if femutils.is_derived_from(obj, "Fem::ConstraintElectrostaticPotential"):
if not obj.AV_re_Disabled:
potential = obj.AV_re.getValueAs("V").Value
if equation.IsHarmonic:
self.write.boundary(name, "AV re", round(potential, 6))
else:
self.write.boundary(name, "AV", round(potential, 6))
if not obj.AV_re_1_Disabled:
potential = float(obj.AV_re_1.getValueAs("V"))
potential = obj.AV_re_1.getValueAs("Wb/m").Value
if equation.IsHarmonic:
self.write.boundary(name, "AV re {e} 1", round(potential, 6))
else:
self.write.boundary(name, "AV {e} 1", round(potential, 6))
if not obj.AV_re_2_Disabled:
potential = float(obj.AV_re_2.getValueAs("V"))
potential = obj.AV_re_2.getValueAs("Wb/m").Value
if equation.IsHarmonic:
self.write.boundary(name, "AV re {e} 2", round(potential, 6))
else:
self.write.boundary(name, "AV {e} 2", round(potential, 6))
if not obj.AV_re_3_Disabled:
potential = float(obj.AV_re_3.getValueAs("V"))
potential = obj.AV_re_3.getValueAs("Wb/m").Value
if equation.IsHarmonic:
self.write.boundary(name, "AV re {e} 3", round(potential, 6))
else:
@@ -319,16 +318,16 @@ class MgDynwriter:
# imaginaries are only needed for harmonic equation
if equation.IsHarmonic:
if not obj.AV_im_Disabled:
potential = float(obj.AV_im.getValueAs("V"))
potential = obj.AV_im.getValueAs("V").Value
self.write.boundary(name, "AV im", round(potential, 6))
if not obj.AV_im_1_Disabled:
potential = float(obj.AV_im_1.getValueAs("V"))
potential = obj.AV_im_1.getValueAs("Wb/m").Value
self.write.boundary(name, "AV im {e} 1", round(potential, 6))
if not obj.AV_im_2_Disabled:
potential = float(obj.AV_im_2.getValueAs("V"))
potential = obj.AV_im_2.getValueAs("Wb/m").Value
self.write.boundary(name, "AV im {e} 2", round(potential, 6))
if not obj.AV_im_3_Disabled:
potential = float(obj.AV_im_3.getValueAs("V"))
potential = obj.AV_im_3.getValueAs("Wb/m").Value
self.write.boundary(name, "AV im {e} 3", round(potential, 6))
def handleMagnetodynamicBndConditions(self, equation):

View File

@@ -70,23 +70,10 @@ class _TaskPanel(base_femtaskpanel._BaseTaskPanel):
self._partVisible = None
self._meshVisible = None
# start with vector inputs hidden if no vector is set
if (
self.obj.AV_re_1_Disabled
and self.obj.AV_re_2_Disabled
and self.obj.AV_re_3_Disabled
and self.obj.AV_im_Disabled
and self.obj.AV_im_1_Disabled
and self.obj.AV_im_2_Disabled
and self.obj.AV_im_3_Disabled
):
self._vectorField_visibility(False)
self.parameter_widget.vectorFieldBox.setChecked(False)
QtCore.QObject.connect(
self.parameter_widget.vectorFieldBox,
self.parameter_widget.ckb_electromagnetic,
QtCore.SIGNAL("toggled(bool)"),
self._vectorField_visibility,
self.electromagnetic_enabled_changed,
)
QtCore.QObject.connect(
self.parameter_widget.cb_boundary_condition,
@@ -108,6 +95,11 @@ class _TaskPanel(base_femtaskpanel._BaseTaskPanel):
QtCore.SIGNAL("toggled(bool)"),
self.av_re_enabled_changed,
)
QtCore.QObject.connect(
self.parameter_widget.qsb_av_re,
QtCore.SIGNAL("valueChanged(Base::Quantity)"),
self.av_re_changed,
)
QtCore.QObject.connect(
self.parameter_widget.ckb_av_re_1,
QtCore.SIGNAL("toggled(bool)"),
@@ -198,11 +190,6 @@ class _TaskPanel(base_femtaskpanel._BaseTaskPanel):
QtCore.SIGNAL("toggled(bool)"),
self.electric_infinity_changed,
)
QtCore.QObject.connect(
self.parameter_widget.ckb_electric_forcecalculation,
QtCore.SIGNAL("toggled(bool)"),
self.electric_forcecalculation_changed,
)
QtCore.QObject.connect(
self.parameter_widget.qsb_surface_charge_density,
QtCore.SIGNAL("valueChanged(Base::Quantity)"),
@@ -211,9 +198,6 @@ class _TaskPanel(base_femtaskpanel._BaseTaskPanel):
self.init_parameter_widget()
def _vectorField_visibility(self, visible):
self.parameter_widget.vectorFieldGB.setVisible(visible)
def open(self):
if self._mesh is not None and self._part is not None:
self._meshVisible = self._mesh.ViewObject.isVisible()
@@ -249,6 +233,7 @@ class _TaskPanel(base_femtaskpanel._BaseTaskPanel):
self.potential = self.obj.Potential
self.potential_enabled = self.obj.PotentialEnabled
self.av_re = self.obj.AV_re
self.av_re_1 = self.obj.AV_re_1
self.av_re_2 = self.obj.AV_re_2
self.av_re_3 = self.obj.AV_re_3
@@ -257,11 +242,11 @@ class _TaskPanel(base_femtaskpanel._BaseTaskPanel):
self.av_im_2 = self.obj.AV_im_2
self.av_im_3 = self.obj.AV_im_3
self.av_re_enabled = not self.obj.PotentialEnabled
self.av_re_enabled = not self.obj.AV_re_Disabled
self.av_im_enabled = not self.obj.AV_im_Disabled
self.av_re_1_enabled = not self.obj.AV_re_1_Disabled
self.av_re_2_enabled = not self.obj.AV_re_2_Disabled
self.av_re_3_enabled = not self.obj.AV_re_3_Disabled
self.av_im_enabled = not self.obj.AV_im_Disabled
self.av_im_1_enabled = not self.obj.AV_im_1_Disabled
self.av_im_2_enabled = not self.obj.AV_im_2_Disabled
self.av_im_3_enabled = not self.obj.AV_im_3_Disabled
@@ -269,16 +254,15 @@ class _TaskPanel(base_femtaskpanel._BaseTaskPanel):
self.boundary_condition = self.obj.BoundaryCondition
self.potential_constant = self.obj.PotentialConstant
self.electric_infinity = self.obj.ElectricInfinity
self.electric_forcecalculation = self.obj.ElectricForcecalculation
self.capacitance_body_enabled = self.obj.CapacitanceBodyEnabled
self.capacitance_body = self.obj.CapacitanceBody
self.surface_charge_density = self.obj.SurfaceChargeDensity
def _set_params(self):
self.obj.Potential = self.potential
self.obj.PotentialEnabled = self.potential_enabled
self.obj.AV_re = self.av_re
self.obj.AV_re_1 = self.av_re_1
self.obj.AV_re_2 = self.av_re_2
self.obj.AV_re_3 = self.av_re_3
@@ -287,10 +271,11 @@ class _TaskPanel(base_femtaskpanel._BaseTaskPanel):
self.obj.AV_im_2 = self.av_im_2
self.obj.AV_im_3 = self.av_im_3
self.obj.AV_re_Disabled = not self.av_re_enabled
self.obj.AV_im_Disabled = not self.av_im_enabled
self.obj.AV_re_1_Disabled = not self.av_re_1_enabled
self.obj.AV_re_2_Disabled = not self.av_re_2_enabled
self.obj.AV_re_3_Disabled = not self.av_re_3_enabled
self.obj.AV_im_Disabled = not self.av_im_enabled
self.obj.AV_im_1_Disabled = not self.av_im_1_enabled
self.obj.AV_im_2_Disabled = not self.av_im_2_enabled
self.obj.AV_im_3_Disabled = not self.av_im_3_enabled
@@ -298,7 +283,6 @@ class _TaskPanel(base_femtaskpanel._BaseTaskPanel):
self.obj.BoundaryCondition = self.boundary_condition
self.obj.PotentialConstant = self.potential_constant
self.obj.ElectricInfinity = self.electric_infinity
self.obj.ElectricForcecalculation = self.electric_forcecalculation
self.obj.CapacitanceBodyEnabled = self.capacitance_body_enabled
self.obj.CapacitanceBody = self.capacitance_body
@@ -313,11 +297,15 @@ class _TaskPanel(base_femtaskpanel._BaseTaskPanel):
)
self.parameter_widget.ckb_potential.setChecked(self.potential_enabled)
# the vector potentials
self.parameter_widget.qsb_av_re.setProperty("value", self.potential)
# scalar potential
self.parameter_widget.qsb_av_re.setProperty("value", self.av_re)
self.parameter_widget.qsb_av_re.setEnabled(self.av_re_enabled)
FreeCADGui.ExpressionBinding(self.parameter_widget.qsb_av_re).bind(self.obj, "Potential")
FreeCADGui.ExpressionBinding(self.parameter_widget.qsb_av_re).bind(self.obj, "AV_re")
self.parameter_widget.qsb_av_im.setProperty("value", self.av_im)
self.parameter_widget.qsb_av_im.setEnabled(self.av_im_enabled)
FreeCADGui.ExpressionBinding(self.parameter_widget.qsb_av_im).bind(self.obj, "AV_im")
# vector potential
self.parameter_widget.qsb_av_re_1.setProperty("value", self.av_re_1)
self.parameter_widget.qsb_av_re_1.setEnabled(self.av_re_1_enabled)
FreeCADGui.ExpressionBinding(self.parameter_widget.qsb_av_re_1).bind(self.obj, "AV_re_1")
@@ -327,9 +315,7 @@ class _TaskPanel(base_femtaskpanel._BaseTaskPanel):
self.parameter_widget.qsb_av_re_3.setProperty("value", self.av_re_3)
self.parameter_widget.qsb_av_re_3.setEnabled(self.av_re_3_enabled)
FreeCADGui.ExpressionBinding(self.parameter_widget.qsb_av_re_3).bind(self.obj, "AV_re_3")
self.parameter_widget.qsb_av_im.setProperty("value", self.av_im)
self.parameter_widget.qsb_av_im.setEnabled(self.av_im_enabled)
FreeCADGui.ExpressionBinding(self.parameter_widget.qsb_av_im).bind(self.obj, "AV_im")
self.parameter_widget.qsb_av_im_1.setProperty("value", self.av_im_1)
self.parameter_widget.qsb_av_im_1.setEnabled(self.av_im_1_enabled)
FreeCADGui.ExpressionBinding(self.parameter_widget.qsb_av_im_1).bind(self.obj, "AV_im_1")
@@ -340,6 +326,7 @@ class _TaskPanel(base_femtaskpanel._BaseTaskPanel):
self.parameter_widget.qsb_av_im_3.setEnabled(self.av_im_3_enabled)
FreeCADGui.ExpressionBinding(self.parameter_widget.qsb_av_im_3).bind(self.obj, "AV_im_3")
self.parameter_widget.ckb_av_re.setChecked(self.av_re_enabled)
self.parameter_widget.ckb_av_re_1.setChecked(self.av_re_1_enabled)
self.parameter_widget.ckb_av_re_2.setChecked(self.av_re_2_enabled)
self.parameter_widget.ckb_av_re_3.setChecked(self.av_re_3_enabled)
@@ -352,12 +339,11 @@ class _TaskPanel(base_femtaskpanel._BaseTaskPanel):
self.parameter_widget.ckb_electric_infinity.setChecked(self.electric_infinity)
self.parameter_widget.ckb_electric_forcecalculation.setChecked(
self.electric_forcecalculation
)
self.parameter_widget.ckb_capacitance_body.setChecked(self.capacitance_body_enabled)
self.parameter_widget.spb_capacitance_body.setValue(self.capacitance_body)
self.parameter_widget.spb_capacitance_body.setProperty("value", self.capacitance_body)
FreeCADGui.ExpressionBinding(self.parameter_widget.spb_capacitance_body).bind(
self.obj, "CapacitanceBody"
)
self.parameter_widget.qsb_surface_charge_density.setProperty(
"value", self.surface_charge_density
@@ -367,10 +353,22 @@ class _TaskPanel(base_femtaskpanel._BaseTaskPanel):
)
self.bc_enum = self.obj.getEnumerationsOfProperty("BoundaryCondition")
self.parameter_widget.cb_boundary_condition.addItems(self.bc_enum)
index = self.bc_enum.index(self.boundary_condition)
self.parameter_widget.cb_boundary_condition.addItems(self.bc_enum)
self.parameter_widget.cb_boundary_condition.setCurrentIndex(index)
self.boundary_condition_changed(index)
# start with electromagnetic inputs hidden if no field is set
if not (
self.av_re_enabled
or self.av_im_enabled
or self.av_re_1_enabled
or self.av_re_2_enabled
or self.av_re_3_enabled
or self.av_im_1_enabled
or self.av_im_2_enabled
or self.av_im_3_enabled
):
self.parameter_widget.ckb_electromagnetic.setChecked(False)
def potential_changed(self, value):
self.potential = value
@@ -379,6 +377,9 @@ class _TaskPanel(base_femtaskpanel._BaseTaskPanel):
self.potential_enabled = value
self.parameter_widget.qsb_potential.setEnabled(value)
def electromagnetic_enabled_changed(self, value):
self.parameter_widget.gb_electromagnetic.setVisible(value)
def av_re_enabled_changed(self, value):
self.av_re_enabled = value
self.parameter_widget.qsb_av_re.setEnabled(value)
@@ -411,6 +412,9 @@ class _TaskPanel(base_femtaskpanel._BaseTaskPanel):
self.av_im_3_enabled = value
self.parameter_widget.qsb_av_im_3.setEnabled(value)
def av_re_changed(self, value):
self.av_re = value
def av_re_1_changed(self, value):
self.av_re_1 = value
@@ -438,9 +442,6 @@ class _TaskPanel(base_femtaskpanel._BaseTaskPanel):
def electric_infinity_changed(self, value):
self.electric_infinity = value
def electric_forcecalculation_changed(self, value):
self.electric_forcecalculation = value
def capacitance_body_enabled_changed(self, value):
self.capacitance_body_enabled = value
self.parameter_widget.spb_capacitance_body.setEnabled(value)
@@ -460,53 +461,3 @@ class _TaskPanel(base_femtaskpanel._BaseTaskPanel):
elif self.boundary_condition == "Neumann":
self.parameter_widget.gb_neumann.setEnabled(True)
self.parameter_widget.gb_dirichlet.setEnabled(False)
def _applyPotentialChanges(self, enabledBox, potentialQSB):
enabled = enabledBox.isChecked()
potential = None
try:
potential = potentialQSB.property("value")
except ValueError:
FreeCAD.Console.PrintMessage(
"Wrong input. Not recognised input: '{}' "
"Potential has not been set.\n".format(potentialQSB.text())
)
potential = "0.0 mm^2*kg/(s^3*A)"
return enabled, potential
def _applyWidgetChanges(self):
# apply the voltages and their enabled state
self.obj.AV_re_1_Disabled, self.obj.AV_re_1 = self._applyPotentialChanges(
self.parameter_widget.reXunspecBox, self.parameter_widget.realXQSB
)
self.obj.AV_re_2_Disabled, self.obj.AV_re_2 = self._applyPotentialChanges(
self.parameter_widget.reYunspecBox, self.parameter_widget.realYQSB
)
self.obj.AV_re_3_Disabled, self.obj.AV_re_3 = self._applyPotentialChanges(
self.parameter_widget.reZunspecBox, self.parameter_widget.realZQSB
)
self.obj.AV_im_Disabled, self.obj.AV_im = self._applyPotentialChanges(
self.parameter_widget.imScalarunspecBox, self.parameter_widget.imagScalarQSB
)
self.obj.AV_im_1_Disabled, self.obj.AV_im_1 = self._applyPotentialChanges(
self.parameter_widget.imXunspecBox, self.parameter_widget.imagXQSB
)
self.obj.AV_im_2_Disabled, self.obj.AV_im_2 = self._applyPotentialChanges(
self.parameter_widget.imYunspecBox, self.parameter_widget.imagYQSB
)
self.obj.AV_im_3_Disabled, self.obj.AV_im_3 = self._applyPotentialChanges(
self.parameter_widget.imZunspecBox, self.parameter_widget.imagZQSB
)
# because this is an enable the others are disabled, reverse
self.obj.PotentialEnabled = not self.obj.PotentialEnabled
self.obj.PotentialConstant = self.parameter_widget.potentialConstantBox.isChecked()
self.obj.ElectricInfinity = self.parameter_widget.electricInfinityBox.isChecked()
calc_is_checked = self.parameter_widget.electricForcecalculationBox.isChecked()
self.obj.ElectricForcecalculation = calc_is_checked # two lines because max line length
self.obj.SurfaceChargeDensity = self.parameter_widget.surfacechargedensityQSB.property(
"value"
)