Fem: Fix vector potential unit and use enumeration property for boundary condition

This commit is contained in:
marioalexis
2025-01-12 10:17:56 -03:00
parent 9ad7bd37e3
commit 30c7efbc60
4 changed files with 766 additions and 790 deletions

View File

@@ -13,56 +13,46 @@
<property name="windowTitle">
<string>Analysis feature properties</string>
</property>
<layout class="QGridLayout" name="gridLayout_4">
<item row="0" column="0">
<widget class="QRadioButton" name="dirichletBC_RB">
<property name="text">
<string>Dirichlet</string>
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<widget class="QGroupBox" name="gb_boundary_condition">
<property name="title">
<string></string>
</property>
<property name="checked">
<bool>true</bool>
</property>
<attribute name="buttonGroup">
<string notr="true">BCtypeBG</string>
</attribute>
</widget>
</item>
<item row="10" column="0">
<widget class="QRadioButton" name="neumannBC_RB">
<property name="text">
<string>Neumann</string>
</property>
<attribute name="buttonGroup">
<string notr="true">BCtypeBG</string>
</attribute>
<layout class="QGridLayout" name="gridLayout_4">
<item row="0" column="0">
<widget class="QLabel" name="lbl_boundary_condition">
<property name="text">
<string>Boundary Condition:</string>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QComboBox" name="cb_boundary_condition"/>
</item>
</layout>
</widget>
</item>
<item row="1" column="0">
<widget class="QGroupBox" name="dirichletGB">
<widget class="QGroupBox" name="gb_dirichlet">
<property name="title">
<string/>
<string>Dirichlet</string>
</property>
<property name="checkable">
<bool>false</bool>
</property>
<layout class="QGridLayout" name="gridLayout_6">
<item row="3" column="0">
<widget class="QCheckBox" name="electricInfinityBox">
<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="0" column="0">
<layout class="QGridLayout" name="gridLayout">
<item row="0" column="2">
<widget class="Gui::QuantitySpinBox" name="potentialQSB">
<item row="0" column="0">
<widget class="QCheckBox" name="ckb_potential">
<property name="text">
<string>Potential:</string>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="Gui::QuantitySpinBox" name="qsb_potential">
<property name="enabled">
<bool>false</bool>
</property>
@@ -73,13 +63,7 @@
<bool>true</bool>
</property>
<property name="unit" stdset="0">
<string notr="true"/>
</property>
<property name="minimum">
<double>-1000000000000000000000.000000000000000</double>
</property>
<property name="maximum">
<double>1000000000000000000000.000000000000000</double>
<string notr="true">V</string>
</property>
<property name="singleStep">
<double>1.000000000000000</double>
@@ -89,45 +73,18 @@
</property>
</widget>
</item>
<item row="0" column="0">
<widget class="QLabel" name="potentialLbl">
<property name="text">
<string>Potential:</string>
</property>
</widget>
</item>
<item row="0" column="3">
<widget class="QCheckBox" name="potentialBox">
<property name="text">
<string>unspecified</string>
</property>
<property name="checked">
<bool>true</bool>
</property>
</widget>
</item>
<item row="0" column="1">
<spacer name="horizontalSpacer">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
</layout>
</item>
<item row="4" column="0">
<widget class="QCheckBox" name="potentialConstantBox">
<item row="1" column="0">
<widget class="QCheckBox" name="vectorFieldBox">
<property name="toolTip">
<string>Whether the boundary condition defines a constant potential</string>
<string>To define scalar potential and magnetic vector potential</string>
</property>
<property name="text">
<string>Potential Constant</string>
<string>Electromagnetic Potential</string>
</property>
<property name="checked">
<bool>true</bool>
</property>
</widget>
</item>
@@ -147,7 +104,7 @@ with a harmonic/oscillating driving force</string>
<bool>false</bool>
</property>
<layout class="QGridLayout" name="gridLayout_3">
<item row="0" column="1">
<item row="0" column="2">
<widget class="QLabel" name="labelReal">
<property name="enabled">
<bool>true</bool>
@@ -157,7 +114,7 @@ with a harmonic/oscillating driving force</string>
</property>
</widget>
</item>
<item row="0" column="3">
<item row="0" column="4">
<widget class="QLabel" name="labelImaginary">
<property name="enabled">
<bool>true</bool>
@@ -178,16 +135,20 @@ with a harmonic/oscillating driving force</string>
</widget>
</item>
<item row="1" column="1">
<widget class="Gui::QuantitySpinBox" name="realScalarQSB">
<widget class="QCheckBox" name="ckb_av_re">
<property name="toolTip">
<string>unspecified</string>
</property>
<property name="text">
<string/>
</property>
</widget>
</item>
<item row="1" column="2">
<widget class="Gui::QuantitySpinBox" name="qsb_av_re">
<property name="enabled">
<bool>false</bool>
</property>
<property name="minimumSize">
<size>
<width>100</width>
<height>20</height>
</size>
</property>
<property name="toolTip">
<string>Potential as specified above</string>
</property>
@@ -200,12 +161,6 @@ with a harmonic/oscillating driving force</string>
<property name="unit" stdset="0">
<string notr="true">V</string>
</property>
<property name="minimum">
<double>-1000000000000000000000.000000000000000</double>
</property>
<property name="maximum">
<double>1000000000000000000000.000000000000000</double>
</property>
<property name="singleStep">
<double>1.000000000000000</double>
</property>
@@ -215,16 +170,20 @@ with a harmonic/oscillating driving force</string>
</widget>
</item>
<item row="1" column="3">
<widget class="Gui::QuantitySpinBox" name="imagScalarQSB">
<widget class="QCheckBox" name="ckb_av_im">
<property name="toolTip">
<string>unspecified</string>
</property>
<property name="text">
<string/>
</property>
</widget>
</item>
<item row="1" column="4">
<widget class="Gui::QuantitySpinBox" name="qsb_av_im">
<property name="enabled">
<bool>true</bool>
</property>
<property name="minimumSize">
<size>
<width>100</width>
<height>20</height>
</size>
</property>
<property name="toolTip">
<string>Imaginary part of scalar potential</string>
</property>
@@ -234,12 +193,6 @@ with a harmonic/oscillating driving force</string>
<property name="unit" stdset="0">
<string notr="true">V</string>
</property>
<property name="minimum">
<double>-1000000000000000000000.000000000000000</double>
</property>
<property name="maximum">
<double>1000000000000000000000.000000000000000</double>
</property>
<property name="singleStep">
<double>1.000000000000000</double>
</property>
@@ -248,16 +201,6 @@ with a harmonic/oscillating driving force</string>
</property>
</widget>
</item>
<item row="1" column="4">
<widget class="QCheckBox" name="imScalarunspecBox">
<property name="toolTip">
<string>unspecified</string>
</property>
<property name="text">
<string/>
</property>
</widget>
</item>
<item row="2" column="0">
<widget class="QLabel" name="labelX">
<property name="enabled">
@@ -269,16 +212,20 @@ with a harmonic/oscillating driving force</string>
</widget>
</item>
<item row="2" column="1">
<widget class="Gui::QuantitySpinBox" name="realXQSB">
<widget class="QCheckBox" name="ckb_av_re_1">
<property name="toolTip">
<string>unspecified</string>
</property>
<property name="text">
<string/>
</property>
</widget>
</item>
<item row="2" column="2">
<widget class="Gui::QuantitySpinBox" name="qsb_av_re_1">
<property name="enabled">
<bool>true</bool>
</property>
<property name="minimumSize">
<size>
<width>100</width>
<height>20</height>
</size>
</property>
<property name="toolTip">
<string>Real part of potential x-component
Note: has no effect if a solid was selected</string>
@@ -287,13 +234,7 @@ Note: has no effect if a solid was selected</string>
<bool>true</bool>
</property>
<property name="unit" stdset="0">
<string notr="true">V</string>
</property>
<property name="minimum">
<double>-1000000000000000000000.000000000000000</double>
</property>
<property name="maximum">
<double>1000000000000000000000.000000000000000</double>
<string notr="true">Wb/m</string>
</property>
<property name="singleStep">
<double>1.000000000000000</double>
@@ -303,8 +244,8 @@ Note: has no effect if a solid was selected</string>
</property>
</widget>
</item>
<item row="2" column="2">
<widget class="QCheckBox" name="reXunspecBox">
<item row="2" column="3">
<widget class="QCheckBox" name="ckb_av_im_1">
<property name="toolTip">
<string>unspecified</string>
</property>
@@ -313,17 +254,11 @@ Note: has no effect if a solid was selected</string>
</property>
</widget>
</item>
<item row="2" column="3">
<widget class="Gui::QuantitySpinBox" name="imagXQSB">
<item row="2" column="4">
<widget class="Gui::QuantitySpinBox" name="qsb_av_im_1">
<property name="enabled">
<bool>true</bool>
</property>
<property name="minimumSize">
<size>
<width>100</width>
<height>20</height>
</size>
</property>
<property name="toolTip">
<string>Imaginary part of potential x-component
Note: has no effect if a solid was selected</string>
@@ -332,13 +267,7 @@ Note: has no effect if a solid was selected</string>
<bool>true</bool>
</property>
<property name="unit" stdset="0">
<string notr="true">V</string>
</property>
<property name="minimum">
<double>-1000000000000000000000.000000000000000</double>
</property>
<property name="maximum">
<double>1000000000000000000000.000000000000000</double>
<string notr="true">Wb/m</string>
</property>
<property name="singleStep">
<double>1.000000000000000</double>
@@ -348,16 +277,6 @@ Note: has no effect if a solid was selected</string>
</property>
</widget>
</item>
<item row="2" column="4">
<widget class="QCheckBox" name="imXunspecBox">
<property name="toolTip">
<string>unspecified</string>
</property>
<property name="text">
<string/>
</property>
</widget>
</item>
<item row="3" column="0">
<widget class="QLabel" name="labelY">
<property name="enabled">
@@ -369,16 +288,20 @@ Note: has no effect if a solid was selected</string>
</widget>
</item>
<item row="3" column="1">
<widget class="Gui::QuantitySpinBox" name="realYQSB">
<widget class="QCheckBox" name="ckb_av_re_2">
<property name="toolTip">
<string>unspecified</string>
</property>
<property name="text">
<string/>
</property>
</widget>
</item>
<item row="3" column="2">
<widget class="Gui::QuantitySpinBox" name="qsb_av_re_2">
<property name="enabled">
<bool>true</bool>
</property>
<property name="minimumSize">
<size>
<width>100</width>
<height>20</height>
</size>
</property>
<property name="toolTip">
<string>Real part of potential y-component
Note: has no effect if a solid was selected</string>
@@ -387,13 +310,7 @@ Note: has no effect if a solid was selected</string>
<bool>true</bool>
</property>
<property name="unit" stdset="0">
<string notr="true">V</string>
</property>
<property name="minimum">
<double>-1000000000000000000000.000000000000000</double>
</property>
<property name="maximum">
<double>1000000000000000000000.000000000000000</double>
<string notr="true">Wb/m</string>
</property>
<property name="singleStep">
<double>1.000000000000000</double>
@@ -403,8 +320,8 @@ Note: has no effect if a solid was selected</string>
</property>
</widget>
</item>
<item row="3" column="2">
<widget class="QCheckBox" name="reYunspecBox">
<item row="3" column="3">
<widget class="QCheckBox" name="ckb_av_im_2">
<property name="toolTip">
<string>unspecified</string>
</property>
@@ -413,17 +330,11 @@ Note: has no effect if a solid was selected</string>
</property>
</widget>
</item>
<item row="3" column="3">
<widget class="Gui::QuantitySpinBox" name="imagYQSB">
<item row="3" column="4">
<widget class="Gui::QuantitySpinBox" name="qsb_av_im_2">
<property name="enabled">
<bool>true</bool>
</property>
<property name="minimumSize">
<size>
<width>100</width>
<height>20</height>
</size>
</property>
<property name="toolTip">
<string>Imaginary part of potential y-component
Note: has no effect if a solid was selected</string>
@@ -432,13 +343,7 @@ Note: has no effect if a solid was selected</string>
<bool>true</bool>
</property>
<property name="unit" stdset="0">
<string notr="true">V</string>
</property>
<property name="minimum">
<double>-1000000000000000000000.000000000000000</double>
</property>
<property name="maximum">
<double>1000000000000000000000.000000000000000</double>
<string notr="true">Wb/m</string>
</property>
<property name="singleStep">
<double>1.000000000000000</double>
@@ -448,16 +353,6 @@ Note: has no effect if a solid was selected</string>
</property>
</widget>
</item>
<item row="3" column="4">
<widget class="QCheckBox" name="imYunspecBox">
<property name="toolTip">
<string>unspecified</string>
</property>
<property name="text">
<string/>
</property>
</widget>
</item>
<item row="4" column="0">
<widget class="QLabel" name="labelZ">
<property name="enabled">
@@ -469,16 +364,20 @@ Note: has no effect if a solid was selected</string>
</widget>
</item>
<item row="4" column="1">
<widget class="Gui::QuantitySpinBox" name="realZQSB">
<widget class="QCheckBox" name="ckb_av_re_3">
<property name="toolTip">
<string>unspecified</string>
</property>
<property name="text">
<string/>
</property>
</widget>
</item>
<item row="4" column="2">
<widget class="Gui::QuantitySpinBox" name="qsb_av_re_3">
<property name="enabled">
<bool>true</bool>
</property>
<property name="minimumSize">
<size>
<width>100</width>
<height>20</height>
</size>
</property>
<property name="toolTip">
<string>Real part of potential z-component
Note: has no effect if a solid was selected</string>
@@ -487,13 +386,7 @@ Note: has no effect if a solid was selected</string>
<bool>true</bool>
</property>
<property name="unit" stdset="0">
<string notr="true">V</string>
</property>
<property name="minimum">
<double>-1000000000000000000000.000000000000000</double>
</property>
<property name="maximum">
<double>1000000000000000000000.000000000000000</double>
<string notr="true">Wb/m</string>
</property>
<property name="singleStep">
<double>1.000000000000000</double>
@@ -503,8 +396,8 @@ Note: has no effect if a solid was selected</string>
</property>
</widget>
</item>
<item row="4" column="2">
<widget class="QCheckBox" name="reZunspecBox">
<item row="4" column="3">
<widget class="QCheckBox" name="ckb_av_im_3">
<property name="toolTip">
<string>unspecified</string>
</property>
@@ -513,17 +406,11 @@ Note: has no effect if a solid was selected</string>
</property>
</widget>
</item>
<item row="4" column="3">
<widget class="Gui::QuantitySpinBox" name="imagZQSB">
<item row="4" column="4">
<widget class="Gui::QuantitySpinBox" name="qsb_av_im_3">
<property name="enabled">
<bool>true</bool>
</property>
<property name="minimumSize">
<size>
<width>100</width>
<height>20</height>
</size>
</property>
<property name="toolTip">
<string>Imaginary part of potential z-component
Note: has no effect if a solid was selected</string>
@@ -532,13 +419,7 @@ Note: has no effect if a solid was selected</string>
<bool>true</bool>
</property>
<property name="unit" stdset="0">
<string notr="true">V</string>
</property>
<property name="minimum">
<double>-1000000000000000000000.000000000000000</double>
</property>
<property name="maximum">
<double>1000000000000000000000.000000000000000</double>
<string notr="true">Wb/m</string>
</property>
<property name="singleStep">
<double>1.000000000000000</double>
@@ -548,62 +429,62 @@ Note: has no effect if a solid was selected</string>
</property>
</widget>
</item>
<item row="4" column="4">
<widget class="QCheckBox" name="imZunspecBox">
<property name="toolTip">
<string>unspecified</string>
</property>
<property name="text">
<string/>
</property>
</widget>
</item>
</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="QLabel" name="capacityBody_label">
<widget class="QCheckBox" name="ckb_capacitance_body">
<property name="text">
<string extracomment="Enabled by 'Calculate Capacity Matrix' in Electrostatic equation">Capacitance Body:</string>
<string>Capacitance Body:</string>
</property>
<property name="toolTip">
<string>Enabled by 'Calculate Capacity Matrix' in Electrostatic equation</string>
</property>
</widget>
</item>
<item row="0" column="1">
<spacer name="horizontalSpacer_2">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item row="0" column="2">
<widget class="QCheckBox" name="capacitanceBodyBox">
<property name="text">
<string>unspecified</string>
</property>
<property name="checked">
<bool>true</bool>
</property>
</widget>
</item>
<item row="0" column="3">
<widget class="QSpinBox" name="capacitanceBody_spinBox">
<property name="maximumSize">
<size>
<width>55</width>
<height>16777215</height>
</size>
</property>
<widget class="QSpinBox" 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>
@@ -614,87 +495,31 @@ Note: has no effect if a solid was selected</string>
</item>
</layout>
</item>
<item row="1" column="0">
<widget class="QCheckBox" name="vectorFieldBox">
<property name="toolTip">
<string>To define a vector field</string>
</property>
<property name="text">
<string>Vector Field</string>
</property>
<property name="checked">
<bool>true</bool>
</property>
</widget>
</item>
<item row="5" column="0">
<widget class="QCheckBox" name="electricForcecalculationBox">
<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>
</layout>
</widget>
</item>
<item row="11" column="0">
<widget class="QGroupBox" name="neumannGB">
<item row="2" column="0">
<widget class="QGroupBox" name="gb_neumann">
<property name="title">
<string/>
<string>Neumann</string>
</property>
<property name="alignment">
<set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter</set>
</property>
<layout class="QGridLayout" name="gridLayout_8" rowminimumheight="0,0">
<layout class="QGridLayout" name="gridLayout_8">
<item row="0" column="0">
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
<widget class="QLabel" name="surfacechargedensityLbl">
<property name="text">
<string>Surface Charge Density:</string>
</property>
</widget>
</item>
<item>
<spacer name="horizontalSpacer_3">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="Gui::QuantitySpinBox" name="surfacechargedensityQSB">
<property name="toolTip">
<string>Surface Charge density</string>
</property>
<property name="unit" stdset="0">
<string notr="true"/>
</property>
</widget>
</item>
</layout>
<widget class="QLabel" name="surfacechargedensityLbl">
<property name="text">
<string>Surface Charge Density:</string>
</property>
</widget>
</item>
<item row="1" column="0">
<spacer name="verticalSpacer">
<property name="orientation">
<enum>Qt::Vertical</enum>
<item row="0" column="1">
<widget class="Gui::QuantitySpinBox" name="qsb_surface_charge_density">
<property name="toolTip">
<string>Surface charge density</string>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>40</height>
</size>
<property name="unit" stdset="0">
<string notr="true">C/m^2</string>
</property>
</spacer>
</widget>
</item>
</layout>
</widget>
@@ -709,168 +534,6 @@ Note: has no effect if a solid was selected</string>
</customwidget>
</customwidgets>
<resources/>
<connections>
<connection>
<sender>capacitanceBodyBox</sender>
<signal>toggled(bool)</signal>
<receiver>capacitanceBody_spinBox</receiver>
<slot>setDisabled(bool)</slot>
<hints>
<hint type="sourcelabel">
<x>262</x>
<y>116</y>
</hint>
<hint type="destinationlabel">
<x>323</x>
<y>116</y>
</hint>
</hints>
</connection>
<connection>
<sender>potentialBox</sender>
<signal>toggled(bool)</signal>
<receiver>potentialQSB</receiver>
<slot>setDisabled(bool)</slot>
<hints>
<hint type="sourcelabel">
<x>301</x>
<y>19</y>
</hint>
<hint type="destinationlabel">
<x>206</x>
<y>19</y>
</hint>
</hints>
</connection>
<connection>
<sender>potentialQSB</sender>
<signal>valueChanged(Base::Quantity)</signal>
<receiver>realScalarQSB</receiver>
<slot>setValue(Base::Quantity)</slot>
<hints>
<hint type="sourcelabel">
<x>126</x>
<y>19</y>
</hint>
<hint type="destinationlabel">
<x>103</x>
<y>98</y>
</hint>
</hints>
</connection>
<connection>
<sender>reZunspecBox</sender>
<signal>toggled(bool)</signal>
<receiver>realZQSB</receiver>
<slot>setDisabled(bool)</slot>
<hints>
<hint type="sourcelabel">
<x>179</x>
<y>178</y>
</hint>
<hint type="destinationlabel">
<x>103</x>
<y>176</y>
</hint>
</hints>
</connection>
<connection>
<sender>reYunspecBox</sender>
<signal>toggled(bool)</signal>
<receiver>realYQSB</receiver>
<slot>setDisabled(bool)</slot>
<hints>
<hint type="sourcelabel">
<x>179</x>
<y>148</y>
</hint>
<hint type="destinationlabel">
<x>103</x>
<y>150</y>
</hint>
</hints>
</connection>
<connection>
<sender>imXunspecBox</sender>
<signal>toggled(bool)</signal>
<receiver>imagXQSB</receiver>
<slot>setDisabled(bool)</slot>
<hints>
<hint type="sourcelabel">
<x>339</x>
<y>128</y>
</hint>
<hint type="destinationlabel">
<x>258</x>
<y>127</y>
</hint>
</hints>
</connection>
<connection>
<sender>reXunspecBox</sender>
<signal>toggled(bool)</signal>
<receiver>realXQSB</receiver>
<slot>setDisabled(bool)</slot>
<hints>
<hint type="sourcelabel">
<x>179</x>
<y>128</y>
</hint>
<hint type="destinationlabel">
<x>103</x>
<y>124</y>
</hint>
</hints>
</connection>
<connection>
<sender>imZunspecBox</sender>
<signal>toggled(bool)</signal>
<receiver>imagZQSB</receiver>
<slot>setDisabled(bool)</slot>
<hints>
<hint type="sourcelabel">
<x>339</x>
<y>178</y>
</hint>
<hint type="destinationlabel">
<x>258</x>
<y>179</y>
</hint>
</hints>
</connection>
<connection>
<sender>imYunspecBox</sender>
<signal>toggled(bool)</signal>
<receiver>imagYQSB</receiver>
<slot>setDisabled(bool)</slot>
<hints>
<hint type="sourcelabel">
<x>339</x>
<y>148</y>
</hint>
<hint type="destinationlabel">
<x>258</x>
<y>153</y>
</hint>
</hints>
</connection>
<connection>
<sender>imScalarunspecBox</sender>
<signal>toggled(bool)</signal>
<receiver>imagScalarQSB</receiver>
<slot>setDisabled(bool)</slot>
<hints>
<hint type="sourcelabel">
<x>339</x>
<y>98</y>
</hint>
<hint type="destinationlabel">
<x>258</x>
<y>101</y>
</hint>
</hints>
</connection>
</connections>
<buttongroups>
<buttongroup name="BCtypeBG"/>
</buttongroups>

View File

@@ -2,6 +2,7 @@
# * Copyright (c) 2017 Markus Hovorka <m.hovorka@live.de> *
# * Copyright (c) 2020 Bernd Hahnebach <bernd@bimstatik.org> *
# * Copyright (c) 2023 Uwe Stöhr <uwestoehr@lyx.org> *
# * Copyright (c) 2024 Mario Passaglia <mpassaglia[at]cbc.uba.ar> *
# * *
# * This file is part of the FreeCAD CAx development system. *
# * *
@@ -24,7 +25,7 @@
# ***************************************************************************
__title__ = "FreeCAD FEM constraint electrostatic potential document object"
__author__ = "Markus Hovorka, Bernd Hahnebach, Uwe Stöhr"
__author__ = "Markus Hovorka, Bernd Hahnebach, Uwe Stöhr, Mario Passaglia"
__url__ = "https://www.freecad.org"
## @package constraint_electrostaticpotential
@@ -33,6 +34,8 @@ __url__ = "https://www.freecad.org"
from . import base_fempythonobject
_PropHelper = base_fempythonobject._PropHelper
class ConstraintElectrostaticPotential(base_fempythonobject.BaseFemPythonObject):
@@ -40,178 +43,243 @@ class ConstraintElectrostaticPotential(base_fempythonobject.BaseFemPythonObject)
def __init__(self, obj):
super().__init__(obj)
self.add_properties(obj)
for prop in self._get_properties():
prop.add_to_object(obj)
def _get_properties(self):
prop = []
prop.append(
_PropHelper(
type="App::PropertyElectricPotential",
name="Potential",
group="Parameter",
doc="Electric Potential",
value="1 V",
)
)
prop.append(
_PropHelper(
type="App::PropertyBool",
name="PotentialEnabled",
group="Parameter",
doc="Enable electric potential",
value=True,
)
)
prop.append(
_PropHelper(
type="App::PropertyElectromagneticPotential",
name="AV_re_1",
group="Vector Potential",
doc="Real part of potential x-component",
value="0 Wb/m",
)
)
prop.append(
_PropHelper(
type="App::PropertyElectromagneticPotential",
name="AV_re_2",
group="Vector Potential",
doc="Real part of potential y-component",
value="0 Wb/m",
)
)
prop.append(
_PropHelper(
type="App::PropertyElectromagneticPotential",
name="AV_re_3",
group="Vector Potential",
doc="Real part of potential z-component",
value="0 Wb/m",
)
)
prop.append(
_PropHelper(
type="App::PropertyElectromagneticPotential",
name="AV_im_1",
group="Vector Potential",
doc="Imaginary part of potential x-component",
value="0 Wb/m",
)
)
prop.append(
_PropHelper(
type="App::PropertyElectromagneticPotential",
name="AV_im_2",
group="Vector Potential",
doc="Imaginary part of potential y-component",
value="0 Wb/m",
)
)
prop.append(
_PropHelper(
type="App::PropertyElectromagneticPotential",
name="AV_im_3",
group="Vector Potential",
doc="Imaginary part of potential z-component",
value="0 Wb/m",
)
)
prop.append(
_PropHelper(
type="App::PropertySurfaceChargeDensity",
name="SurfaceChargeDensity",
group="Parameter",
doc="Free surface charge density",
value="0 C/m^2",
)
)
prop.append(
_PropHelper(
type="App::PropertyEnumeration",
name="BoundaryCondition",
group="Parameter",
doc="Set boundary condition type",
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",
doc="",
value=True,
)
)
prop.append(
_PropHelper(
type="App::PropertyBool",
name="AV_re_2_Disabled",
group="Vector Potential",
doc="",
value=True,
)
)
prop.append(
_PropHelper(
type="App::PropertyBool",
name="AV_re_3_Disabled",
group="Vector Potential",
doc="",
value=True,
)
)
prop.append(
_PropHelper(
type="App::PropertyBool",
name="AV_im_1_Disabled",
group="Vector Potential",
doc="",
value=True,
)
)
prop.append(
_PropHelper(
type="App::PropertyBool",
name="AV_im_2_Disabled",
group="Vector Potential",
doc="",
value=True,
)
)
prop.append(
_PropHelper(
type="App::PropertyBool",
name="AV_im_3_Disabled",
group="Vector Potential",
doc="",
value=True,
)
)
prop.append(
_PropHelper(
type="App::PropertyBool",
name="AV_im_Disabled",
group="Vector Potential",
doc="",
value=True,
)
)
prop.append(
_PropHelper(
type="App::PropertyBool",
name="PotentialConstant",
group="Parameter",
doc="",
value=False,
)
)
prop.append(
_PropHelper(
type="App::PropertyBool",
name="ElectricInfinity",
group="Parameter",
doc="Electric Infinity",
value=False,
)
)
prop.append(
_PropHelper(
type="App::PropertyBool",
name="ElectricForcecalculation",
group="Parameter",
doc="Electric force calculation",
value=False,
)
)
prop.append(
_PropHelper(
type="App::PropertyInteger",
name="CapacitanceBody",
group="Parameter",
doc="Capacitance body",
value=0,
)
)
prop.append(
_PropHelper(
type="App::PropertyBool",
name="CapacitanceBodyEnabled",
group="Parameter",
doc="Capacitance body enabled",
value=False,
)
)
return prop
def onDocumentRestored(self, obj):
self.add_properties(obj)
# update old project with new properties
for prop in self._get_properties():
try:
obj.getPropertyByName(prop.name)
except Base.PropertyError:
prop.add_to_object(obj)
def add_properties(self, obj):
if not hasattr(obj, "Potential"):
obj.addProperty(
"App::PropertyElectricPotential", "Potential", "Parameter", "Electric Potential"
)
obj.setPropertyStatus("Potential", "LockDynamic")
# setting 1 V assures that the unit does not switch to mV
# and the constraint holds usually Volts
obj.Potential = "1 V"
if not hasattr(obj, "AV_re_1"):
obj.addProperty(
"App::PropertyElectricPotential",
"AV_re_1",
"Vector Potential",
"Real part of potential x-component",
)
obj.setPropertyStatus("AV_re_1", "LockDynamic")
obj.AV_re_1 = "0 V"
if not hasattr(obj, "AV_re_2"):
obj.addProperty(
"App::PropertyElectricPotential",
"AV_re_2",
"Vector Potential",
"Real part of potential y-component",
)
obj.setPropertyStatus("AV_re_2", "LockDynamic")
obj.AV_re_2 = "0 V"
if not hasattr(obj, "AV_re_3"):
obj.addProperty(
"App::PropertyElectricPotential",
"AV_re_3",
"Vector Potential",
"Real part of potential z-component",
)
obj.setPropertyStatus("AV_re_3", "LockDynamic")
obj.AV_re_3 = "0 V"
if not hasattr(obj, "AV_im"):
obj.addProperty(
"App::PropertyElectricPotential",
"AV_im",
"Vector Potential",
"Imaginary part of scalar potential",
)
obj.setPropertyStatus("AV_im", "LockDynamic")
obj.AV_im = "0 V"
if not hasattr(obj, "AV_im_1"):
obj.addProperty(
"App::PropertyElectricPotential",
"AV_im_1",
"Vector Potential",
"Imaginary part of potential x-component",
)
obj.setPropertyStatus("AV_im_1", "LockDynamic")
obj.AV_im_1 = "0 V"
if not hasattr(obj, "AV_im_2"):
obj.addProperty(
"App::PropertyElectricPotential",
"AV_im_2",
"Vector Potential",
"Imaginary part of potential y-component",
)
obj.setPropertyStatus("AV_im_2", "LockDynamic")
obj.AV_im_2 = "0 V"
if not hasattr(obj, "AV_im_3"):
obj.addProperty(
"App::PropertyElectricPotential",
"AV_im_3",
"Vector Potential",
"Imaginary part of potential z-component",
)
obj.setPropertyStatus("AV_im_3", "LockDynamic")
obj.AV_im_3 = "0 V"
# now the enable bools
if not hasattr(obj, "PotentialEnabled"):
obj.addProperty(
"App::PropertyBool", "PotentialEnabled", "Parameter", "Potential Enabled"
)
obj.setPropertyStatus("PotentialEnabled", "LockDynamic")
obj.PotentialEnabled = True
if not hasattr(obj, "AV_re_1_Disabled"):
obj.addProperty("App::PropertyBool", "AV_re_1_Disabled", "Vector Potential", "")
obj.setPropertyStatus("AV_re_1_Disabled", "LockDynamic")
obj.AV_re_1_Disabled = True
if not hasattr(obj, "AV_re_2_Disabled"):
obj.addProperty("App::PropertyBool", "AV_re_2_Disabled", "Vector Potential", "")
obj.setPropertyStatus("AV_re_2_Disabled", "LockDynamic")
obj.AV_re_2_Disabled = True
if not hasattr(obj, "AV_re_3_Disabled"):
obj.addProperty("App::PropertyBool", "AV_re_3_Disabled", "Vector Potential", "")
obj.setPropertyStatus("AV_re_3_Disabled", "LockDynamic")
obj.AV_re_3_Disabled = True
if not hasattr(obj, "AV_im_Disabled"):
obj.addProperty("App::PropertyBool", "AV_im_Disabled", "Vector Potential", "")
obj.setPropertyStatus("AV_im_Disabled", "LockDynamic")
obj.AV_im_Disabled = True
if not hasattr(obj, "AV_im_1_Disabled"):
obj.addProperty("App::PropertyBool", "AV_im_1_Disabled", "Vector Potential", "")
obj.setPropertyStatus("AV_im_1_Disabled", "LockDynamic")
obj.AV_im_1_Disabled = True
if not hasattr(obj, "AV_im_2_Disabled"):
obj.addProperty("App::PropertyBool", "AV_im_2_Disabled", "Vector Potential", "")
obj.setPropertyStatus("AV_im_2_Disabled", "LockDynamic")
obj.AV_im_2_Disabled = True
if not hasattr(obj, "AV_im_3_Disabled"):
obj.addProperty("App::PropertyBool", "AV_im_3_Disabled", "Vector Potential", "")
obj.setPropertyStatus("AV_im_3_Disabled", "LockDynamic")
obj.AV_im_3_Disabled = True
if not hasattr(obj, "PotentialConstant"):
obj.addProperty(
"App::PropertyBool", "PotentialConstant", "Parameter", "Potential Constant"
)
obj.setPropertyStatus("PotentialConstant", "LockDynamic")
obj.PotentialConstant = False
if not hasattr(obj, "ElectricInfinity"):
obj.addProperty(
"App::PropertyBool", "ElectricInfinity", "Parameter", "Electric Infinity"
)
obj.setPropertyStatus("ElectricInfinity", "LockDynamic")
obj.ElectricInfinity = False
if not hasattr(obj, "ElectricForcecalculation"):
obj.addProperty(
"App::PropertyBool",
"ElectricForcecalculation",
"Parameter",
"Electric Force Calculation",
)
obj.setPropertyStatus("ElectricForcecalculation", "LockDynamic")
obj.ElectricForcecalculation = False
if not hasattr(obj, "CapacitanceBody"):
obj.addProperty(
"App::PropertyInteger", "CapacitanceBody", "Parameter", "Capacitance Body"
)
obj.setPropertyStatus("CapacitanceBody", "LockDynamic")
obj.CapacitanceBody = 0
if not hasattr(obj, "CapacitanceBodyEnabled"):
obj.addProperty(
"App::PropertyBool",
"CapacitanceBodyEnabled",
"Parameter",
"Capacitance Body Enabled",
)
obj.setPropertyStatus("CapacitanceBodyEnabled", "LockDynamic")
obj.CapacitanceBodyEnabled = False
if not hasattr(obj, "SurfaceChargeDensity"):
obj.addProperty(
"App::PropertySurfaceChargeDensity",
"SurfaceChargeDensity",
"Parameter",
"(free) Surface Charge Density",
)
obj.setPropertyStatus("SurfaceChargeDensity", "LockDynamic")
obj.SurfaceChargeDensity = "0.0 s*A/mm^2"
if not hasattr(obj, "Dirichlet"):
obj.addProperty(
"App::PropertyBool",
"Dirichlet",
"Parameter",
"Dirichlet (true) or Neumann (false) type BC",
)
obj.setPropertyStatus("Dirichlet", "LockDynamic")
obj.Dirichlet = True
# convert old potential float to Volt
if prop.name == "Potential":
prop.handle_change_type(
obj,
old_type="App::PropertyFloat",
convert_old_value=lambda x: "{} V".format(1e6 * x),
)
# fix unit for magnetic vector potential properties
if prop.name in ("AV_re_1", "AV_re_2", "AV_re_3", "AV_im_1", "AV_im_2", "AV_im_3"):
prop.handle_change_type(
obj,
old_type="App::PropertyElectricPotential",
convert_old_value=lambda x: "{} Wb/m".format(x.getValueAs("V").Value),
)

View File

@@ -125,26 +125,17 @@ class ESwriter:
# output the FreeCAD label as comment
if obj.Label:
self.write.boundary(name, "! FreeCAD Name", obj.Label)
if obj.Dirichlet:
if obj.BoundaryCondition == "Dirichlet":
if obj.PotentialEnabled:
if hasattr(obj, "Potential"):
# Potential was once a float and scaled not fitting SI units
if isinstance(obj.Potential, float):
savePotential = obj.Potential
obj.removeProperty("Potential")
obj.addProperty(
"App::PropertyElectricPotential",
"Potential",
"Parameter",
"Electric Potential",
)
# scale to match SI units
obj.Potential = savePotential * 1e6
potential = float(obj.Potential.getValueAs("V"))
self.write.boundary(name, "Potential", potential)
elif not obj.Dirichlet and hasattr(obj, "SurfaceChargeDensity"):
sc_density = float(obj.SurfaceChargeDensity.getValueAs("A*s/m^2"))
self.write.boundary(name, "Surface Charge Density", sc_density)
self.write.boundary(
name, "Potential", obj.Potential.getValueAs("V").Value
)
elif obj.BoundaryCondition == "Neumann":
self.write.boundary(
name,
"Surface Charge Density",
obj.SurfaceChargeDensity.getValueAs("C/m^2").Value,
)
if obj.PotentialConstant:
self.write.boundary(name, "Potential Constant", True)
if obj.ElectricInfinity:
@@ -152,8 +143,7 @@ class ESwriter:
if obj.ElectricForcecalculation:
self.write.boundary(name, "Calculate Electric Force", True)
if obj.CapacitanceBodyEnabled:
if hasattr(obj, "CapacitanceBody"):
self.write.boundary(name, "Capacitance Body", obj.CapacitanceBody)
self.write.boundary(name, "Capacitance Body", obj.CapacitanceBody)
self.write.handled(obj)

View File

@@ -2,6 +2,7 @@
# * Copyright (c) 2017 Markus Hovorka <m.hovorka@live.de> *
# * Copyright (c) 2020 Bernd Hahnebach <bernd@bimstatik.org> *
# * Copyright (c) 2023 Uwe Stöhr <uwestoehr@lyx.org> *
# * Copyright (c) 2024 Mario Passaglia <mpassaglia[at]cbc.uba.ar> *
# * *
# * This file is part of the FreeCAD CAx development system. *
# * *
@@ -24,7 +25,7 @@
# ***************************************************************************
__title__ = "FreeCAD FEM constraint electrostatic potential task panel for the document object"
__author__ = "Markus Hovorka, Bernd Hahnebach, Uwe Stöhr, André Kapelrud"
__author__ = "Markus Hovorka, Bernd Hahnebach, Uwe Stöhr, André Kapelrud, Mario Passaglia"
__url__ = "https://www.freecad.org"
## @package task_constraint_electrostaticpotential
@@ -46,10 +47,9 @@ class _TaskPanel(base_femtaskpanel._BaseTaskPanel):
def __init__(self, obj):
super().__init__(obj)
self._paramWidget = FreeCADGui.PySideUic.loadUi(
self.parameter_widget = FreeCADGui.PySideUic.loadUi(
FreeCAD.getHomePath() + "Mod/Fem/Resources/ui/ElectrostaticPotential.ui"
)
self._initParamWidget()
# geometry selection widget
# start with Solid in list!
@@ -58,7 +58,7 @@ class _TaskPanel(base_femtaskpanel._BaseTaskPanel):
)
# form made from param and selection widget
self.form = [self._paramWidget, self._selectionWidget]
self.form = [self.parameter_widget, self._selectionWidget]
analysis = obj.getParentGroup()
self._mesh = None
@@ -81,22 +81,138 @@ class _TaskPanel(base_femtaskpanel._BaseTaskPanel):
and self.obj.AV_im_3_Disabled
):
self._vectorField_visibility(False)
self._paramWidget.vectorFieldBox.setChecked(False)
self.parameter_widget.vectorFieldBox.setChecked(False)
QtCore.QObject.connect(
self._paramWidget.vectorFieldBox,
self.parameter_widget.vectorFieldBox,
QtCore.SIGNAL("toggled(bool)"),
self._vectorField_visibility,
)
QtCore.QObject.connect(
self.parameter_widget.cb_boundary_condition,
QtCore.SIGNAL("currentIndexChanged(int)"),
self.boundary_condition_changed,
)
QtCore.QObject.connect(
self.parameter_widget.ckb_potential,
QtCore.SIGNAL("toggled(bool)"),
self.potential_enabled_changed,
)
QtCore.QObject.connect(
self.parameter_widget.qsb_potential,
QtCore.SIGNAL("valueChanged(Base::Quantity)"),
self.potential_changed,
)
QtCore.QObject.connect(
self.parameter_widget.ckb_av_re,
QtCore.SIGNAL("toggled(bool)"),
self.av_re_enabled_changed,
)
QtCore.QObject.connect(
self.parameter_widget.ckb_av_re_1,
QtCore.SIGNAL("toggled(bool)"),
self.av_re_1_enabled_changed,
)
QtCore.QObject.connect(
self.parameter_widget.qsb_av_re_1,
QtCore.SIGNAL("valueChanged(Base::Quantity)"),
self.av_re_1_changed,
)
QtCore.QObject.connect(
self.parameter_widget.ckb_av_re_2,
QtCore.SIGNAL("toggled(bool)"),
self.av_re_2_enabled_changed,
)
QtCore.QObject.connect(
self.parameter_widget.qsb_av_re_2,
QtCore.SIGNAL("valueChanged(Base::Quantity)"),
self.av_re_2_changed,
)
QtCore.QObject.connect(
self.parameter_widget.ckb_av_re_3,
QtCore.SIGNAL("toggled(bool)"),
self.av_re_3_enabled_changed,
)
QtCore.QObject.connect(
self.parameter_widget.qsb_av_re_3,
QtCore.SIGNAL("valueChanged(Base::Quantity)"),
self.av_re_3_changed,
)
QtCore.QObject.connect(
self.parameter_widget.ckb_av_im,
QtCore.SIGNAL("toggled(bool)"),
self.av_im_enabled_changed,
)
QtCore.QObject.connect(
self.parameter_widget.qsb_av_im,
QtCore.SIGNAL("valueChanged(Base::Quantity)"),
self.av_im_changed,
)
QtCore.QObject.connect(
self.parameter_widget.ckb_av_im_1,
QtCore.SIGNAL("toggled(bool)"),
self.av_im_1_enabled_changed,
)
QtCore.QObject.connect(
self.parameter_widget.qsb_av_im_1,
QtCore.SIGNAL("valueChanged(Base::Quantity)"),
self.av_im_1_changed,
)
QtCore.QObject.connect(
self.parameter_widget.ckb_av_im_2,
QtCore.SIGNAL("toggled(bool)"),
self.av_im_2_enabled_changed,
)
QtCore.QObject.connect(
self.parameter_widget.qsb_av_im_2,
QtCore.SIGNAL("valueChanged(Base::Quantity)"),
self.av_im_2_changed,
)
QtCore.QObject.connect(
self.parameter_widget.ckb_av_im_3,
QtCore.SIGNAL("toggled(bool)"),
self.av_im_3_enabled_changed,
)
QtCore.QObject.connect(
self.parameter_widget.qsb_av_im_3,
QtCore.SIGNAL("valueChanged(Base::Quantity)"),
self.av_im_3_changed,
)
QtCore.QObject.connect(
self.parameter_widget.ckb_capacitance_body,
QtCore.SIGNAL("toggled(bool)"),
self.capacitance_body_enabled_changed,
)
QtCore.QObject.connect(
self.parameter_widget.spb_capacitance_body,
QtCore.SIGNAL("valueChanged(int)"),
self.capacitance_body_changed,
)
QtCore.QObject.connect(
self.parameter_widget.ckb_potential_constant,
QtCore.SIGNAL("toggled(bool)"),
self.potential_constant_changed,
)
QtCore.QObject.connect(
self.parameter_widget.ckb_electric_infinity,
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)"),
self.surface_charge_density_changed,
)
def _BCtype_clicked(self, button):
self._BCtype(button == self._paramWidget.dirichletBC_RB)
def _BCtype(self, isDirichlet):
self._paramWidget.neumannGB.setEnabled(not isDirichlet)
self._paramWidget.dirichletGB.setEnabled(isDirichlet)
self.init_parameter_widget()
def _vectorField_visibility(self, visible):
self._paramWidget.vectorFieldGB.setVisible(visible)
self.parameter_widget.vectorFieldGB.setVisible(visible)
def open(self):
if self._mesh is not None and self._part is not None:
@@ -113,7 +229,7 @@ class _TaskPanel(base_femtaskpanel._BaseTaskPanel):
def accept(self):
if self.obj.References != self._selectionWidget.references:
self.obj.References = self._selectionWidget.references
self._applyWidgetChanges()
self._set_params()
self._selectionWidget.finish_selection()
self._restoreVisibility()
return super().accept()
@@ -129,64 +245,222 @@ class _TaskPanel(base_femtaskpanel._BaseTaskPanel):
else:
self._part.ViewObject.hide()
def _initParamWidget(self):
self._paramWidget.potentialQSB.setProperty("value", self.obj.Potential)
FreeCADGui.ExpressionBinding(self._paramWidget.potentialQSB).bind(self.obj, "Potential")
self._paramWidget.potentialBox.setChecked(not self.obj.PotentialEnabled)
def _get_params(self):
self.potential = self.obj.Potential
self.potential_enabled = self.obj.PotentialEnabled
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
self.av_im = self.obj.AV_im
self.av_im_1 = self.obj.AV_im_1
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_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
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_1 = self.av_re_1
self.obj.AV_re_2 = self.av_re_2
self.obj.AV_re_3 = self.av_re_3
self.obj.AV_im = self.av_im
self.obj.AV_im_1 = self.av_im_1
self.obj.AV_im_2 = self.av_im_2
self.obj.AV_im_3 = self.av_im_3
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
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
self.obj.SurfaceChargeDensity = self.surface_charge_density
def init_parameter_widget(self):
self._get_params()
self.parameter_widget.qsb_potential.setProperty("value", self.potential)
FreeCADGui.ExpressionBinding(self.parameter_widget.qsb_potential).bind(
self.obj, "Potential"
)
self.parameter_widget.ckb_potential.setChecked(self.potential_enabled)
# the vector potentials
# realScalarQSB always the same value as potentialQSB
self._paramWidget.realScalarQSB.setProperty("value", self.obj.Potential)
FreeCADGui.ExpressionBinding(self._paramWidget.realScalarQSB).bind(self.obj, "Potential")
self._paramWidget.realXQSB.setProperty("value", self.obj.AV_re_1)
FreeCADGui.ExpressionBinding(self._paramWidget.realXQSB).bind(self.obj, "AV_re_1")
self._paramWidget.realYQSB.setProperty("value", self.obj.AV_re_2)
FreeCADGui.ExpressionBinding(self._paramWidget.realYQSB).bind(self.obj, "AV_re_2")
self._paramWidget.realZQSB.setProperty("value", self.obj.AV_re_3)
FreeCADGui.ExpressionBinding(self._paramWidget.realZQSB).bind(self.obj, "AV_re_3")
self._paramWidget.imagScalarQSB.setProperty("value", self.obj.AV_im)
FreeCADGui.ExpressionBinding(self._paramWidget.imagScalarQSB).bind(self.obj, "AV_im")
self._paramWidget.imagXQSB.setProperty("value", self.obj.AV_im_1)
FreeCADGui.ExpressionBinding(self._paramWidget.imagXQSB).bind(self.obj, "AV_im_1")
self._paramWidget.imagYQSB.setProperty("value", self.obj.AV_im_2)
FreeCADGui.ExpressionBinding(self._paramWidget.imagYQSB).bind(self.obj, "AV_im_2")
self._paramWidget.imagZQSB.setProperty("value", self.obj.AV_im_3)
FreeCADGui.ExpressionBinding(self._paramWidget.imagZQSB).bind(self.obj, "AV_im_3")
self.parameter_widget.qsb_av_re.setProperty("value", self.potential)
self.parameter_widget.qsb_av_re.setEnabled(self.av_re_enabled)
FreeCADGui.ExpressionBinding(self.parameter_widget.qsb_av_re).bind(self.obj, "Potential")
self._paramWidget.reXunspecBox.setChecked(self.obj.AV_re_1_Disabled)
self._paramWidget.reYunspecBox.setChecked(self.obj.AV_re_2_Disabled)
self._paramWidget.reZunspecBox.setChecked(self.obj.AV_re_3_Disabled)
self._paramWidget.imScalarunspecBox.setChecked(self.obj.AV_im_Disabled)
self._paramWidget.imXunspecBox.setChecked(self.obj.AV_im_1_Disabled)
self._paramWidget.imYunspecBox.setChecked(self.obj.AV_im_2_Disabled)
self._paramWidget.imZunspecBox.setChecked(self.obj.AV_im_3_Disabled)
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")
self.parameter_widget.qsb_av_re_2.setProperty("value", self.av_re_2)
self.parameter_widget.qsb_av_re_2.setEnabled(self.av_re_2_enabled)
FreeCADGui.ExpressionBinding(self.parameter_widget.qsb_av_re_2).bind(self.obj, "AV_re_2")
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")
self.parameter_widget.qsb_av_im_2.setProperty("value", self.av_im_2)
self.parameter_widget.qsb_av_im_2.setEnabled(self.av_im_2_enabled)
FreeCADGui.ExpressionBinding(self.parameter_widget.qsb_av_im_2).bind(self.obj, "AV_im_2")
self.parameter_widget.qsb_av_im_3.setProperty("value", self.av_im_3)
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._paramWidget.potentialConstantBox.setChecked(self.obj.PotentialConstant)
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)
self.parameter_widget.ckb_av_im.setChecked(self.av_im_enabled)
self.parameter_widget.ckb_av_im_1.setChecked(self.av_im_1_enabled)
self.parameter_widget.ckb_av_im_2.setChecked(self.av_im_2_enabled)
self.parameter_widget.ckb_av_im_3.setChecked(self.av_im_3_enabled)
self._paramWidget.electricInfinityBox.setChecked(self.obj.ElectricInfinity)
self.parameter_widget.ckb_potential_constant.setChecked(self.potential_constant)
self._paramWidget.electricForcecalculationBox.setChecked(self.obj.ElectricForcecalculation)
self.parameter_widget.ckb_electric_infinity.setChecked(self.electric_infinity)
self._paramWidget.capacitanceBodyBox.setChecked(not self.obj.CapacitanceBodyEnabled)
self._paramWidget.capacitanceBody_spinBox.setValue(self.obj.CapacitanceBody)
self._paramWidget.capacitanceBody_spinBox.setEnabled(
not self._paramWidget.capacitanceBodyBox.isChecked()
self.parameter_widget.ckb_electric_forcecalculation.setChecked(
self.electric_forcecalculation
)
# neumann/dirichlet radiogroup selection
self._paramWidget.BCtypeBG.buttonClicked.connect(self._BCtype_clicked)
if self.obj.Dirichlet:
self._paramWidget.dirichletBC_RB.click()
else:
self._paramWidget.neumannBC_RB.click()
self.parameter_widget.ckb_capacitance_body.setChecked(self.capacitance_body_enabled)
self.parameter_widget.spb_capacitance_body.setValue(self.capacitance_body)
self._paramWidget.surfacechargedensityQSB.setProperty(
"value", self.obj.SurfaceChargeDensity
self.parameter_widget.qsb_surface_charge_density.setProperty(
"value", self.surface_charge_density
)
FreeCADGui.ExpressionBinding(self._paramWidget.surfacechargedensityQSB).bind(
FreeCADGui.ExpressionBinding(self.parameter_widget.qsb_surface_charge_density).bind(
self.obj, "SurfaceChargeDensity"
)
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.setCurrentIndex(index)
self.boundary_condition_changed(index)
def potential_changed(self, value):
self.potential = value
def potential_enabled_changed(self, value):
self.potential_enabled = value
self.parameter_widget.qsb_potential.setEnabled(value)
def av_re_enabled_changed(self, value):
self.av_re_enabled = value
self.parameter_widget.qsb_av_re.setEnabled(value)
def av_re_1_enabled_changed(self, value):
self.av_re_1_enabled = value
self.parameter_widget.qsb_av_re_1.setEnabled(value)
def av_re_2_enabled_changed(self, value):
self.av_re_2_enabled = value
self.parameter_widget.qsb_av_re_2.setEnabled(value)
def av_re_3_enabled_changed(self, value):
self.av_re_3_enabled = value
self.parameter_widget.qsb_av_re_3.setEnabled(value)
def av_im_enabled_changed(self, value):
self.av_im_enabled = value
self.parameter_widget.qsb_av_im.setEnabled(value)
def av_im_1_enabled_changed(self, value):
self.av_im_1_enabled = value
self.parameter_widget.qsb_av_im_1.setEnabled(value)
def av_im_2_enabled_changed(self, value):
self.av_im_2_enabled = value
self.parameter_widget.qsb_av_im_2.setEnabled(value)
def av_im_3_enabled_changed(self, value):
self.av_im_3_enabled = value
self.parameter_widget.qsb_av_im_3.setEnabled(value)
def av_re_1_changed(self, value):
self.av_re_1 = value
def av_re_2_changed(self, value):
self.av_re_2 = value
def av_re_3_changed(self, value):
self.av_re_3 = value
def av_im_changed(self, value):
self.av_im = value
def av_im_1_changed(self, value):
self.av_im_1 = value
def av_im_2_changed(self, value):
self.av_im_2 = value
def av_im_3_changed(self, value):
self.av_im_3 = value
def potential_constant_changed(self, value):
self.potential_constant = value
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)
def capacitance_body_changed(self, value):
self.capacitance_body = value
self.parameter_widget.spb_capacitance_body.setValue(value)
def surface_charge_density_changed(self, value):
self.surface_charge_density = value
def boundary_condition_changed(self, index):
self.boundary_condition = self.bc_enum[index]
if self.boundary_condition == "Dirichlet":
self.parameter_widget.gb_neumann.setEnabled(False)
self.parameter_widget.gb_dirichlet.setEnabled(True)
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
@@ -202,56 +476,37 @@ class _TaskPanel(base_femtaskpanel._BaseTaskPanel):
def _applyWidgetChanges(self):
# apply the voltages and their enabled state
self.obj.PotentialEnabled, self.obj.Potential = self._applyPotentialChanges(
self._paramWidget.potentialBox, self._paramWidget.potentialQSB
)
self.obj.AV_re_1_Disabled, self.obj.AV_re_1 = self._applyPotentialChanges(
self._paramWidget.reXunspecBox, self._paramWidget.realXQSB
self.parameter_widget.reXunspecBox, self.parameter_widget.realXQSB
)
self.obj.AV_re_2_Disabled, self.obj.AV_re_2 = self._applyPotentialChanges(
self._paramWidget.reYunspecBox, self._paramWidget.realYQSB
self.parameter_widget.reYunspecBox, self.parameter_widget.realYQSB
)
self.obj.AV_re_3_Disabled, self.obj.AV_re_3 = self._applyPotentialChanges(
self._paramWidget.reZunspecBox, self._paramWidget.realZQSB
self.parameter_widget.reZunspecBox, self.parameter_widget.realZQSB
)
self.obj.AV_im_Disabled, self.obj.AV_im = self._applyPotentialChanges(
self._paramWidget.imScalarunspecBox, self._paramWidget.imagScalarQSB
self.parameter_widget.imScalarunspecBox, self.parameter_widget.imagScalarQSB
)
self.obj.AV_im_1_Disabled, self.obj.AV_im_1 = self._applyPotentialChanges(
self._paramWidget.imXunspecBox, self._paramWidget.imagXQSB
self.parameter_widget.imXunspecBox, self.parameter_widget.imagXQSB
)
self.obj.AV_im_2_Disabled, self.obj.AV_im_2 = self._applyPotentialChanges(
self._paramWidget.imYunspecBox, self._paramWidget.imagYQSB
self.parameter_widget.imYunspecBox, self.parameter_widget.imagYQSB
)
self.obj.AV_im_3_Disabled, self.obj.AV_im_3 = self._applyPotentialChanges(
self._paramWidget.imZunspecBox, self._paramWidget.imagZQSB
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._paramWidget.potentialConstantBox.isChecked()
self.obj.PotentialConstant = self.parameter_widget.potentialConstantBox.isChecked()
self.obj.ElectricInfinity = self._paramWidget.electricInfinityBox.isChecked()
self.obj.ElectricInfinity = self.parameter_widget.electricInfinityBox.isChecked()
calc_is_checked = self._paramWidget.electricForcecalculationBox.isChecked()
calc_is_checked = self.parameter_widget.electricForcecalculationBox.isChecked()
self.obj.ElectricForcecalculation = calc_is_checked # two lines because max line length
self.obj.CapacitanceBodyEnabled = not self._paramWidget.capacitanceBodyBox.isChecked()
if self.obj.CapacitanceBodyEnabled:
self._paramWidget.capacitanceBody_spinBox.setEnabled(True)
self.obj.CapacitanceBody = self._paramWidget.capacitanceBody_spinBox.value()
self.obj.Dirichlet = self._paramWidget.dirichletBC_RB.isChecked()
try:
self.obj.SurfaceChargeDensity = self._paramWidget.surfacechargedensityQSB.property(
"value"
)
except ValueError:
FreeCAD.Console.PrintMessage(
"Wrong input. Not recognised input: '{}' "
"SurfaceChargeDensity has not been set.\n".format(
self._paramWidget.surfacechargedensityQSB.text()
)
)
self.obj.SurfaceChargeDensity = "0.0 s*A/(mm^2)"
self.obj.SurfaceChargeDensity = self.parameter_widget.surfacechargedensityQSB.property(
"value"
)