Fem: Improve magnetization
This commit is contained in:
@@ -13,326 +13,197 @@
|
||||
<property name="windowTitle">
|
||||
<string>Analysis feature properties</string>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="gridLayout">
|
||||
<item row="0" column="0" colspan="2">
|
||||
<widget class="QLabel" name="magnetizationLbl">
|
||||
<property name="text">
|
||||
<string>Magnetization</string>
|
||||
<layout class="QVBoxLayout" name="vlt_0">
|
||||
<item row="0" column="0">
|
||||
<widget class="QGroupBox" name="gb_custom">
|
||||
<property name="title">
|
||||
<string></string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="1">
|
||||
<widget class="QLabel" name="labelReal">
|
||||
<property name="enabled">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Real</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="3">
|
||||
<widget class="QLabel" name="labelImaginary">
|
||||
<property name="enabled">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Imaginary</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="0">
|
||||
<widget class="QLabel" name="labelX">
|
||||
<property name="enabled">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>x</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="1">
|
||||
<widget class="Gui::QuantitySpinBox" name="realXQSB">
|
||||
<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</string>
|
||||
</property>
|
||||
<property name="keyboardTracking">
|
||||
<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>
|
||||
</property>
|
||||
<property name="singleStep">
|
||||
<double>1.000000000000000</double>
|
||||
</property>
|
||||
<property name="value">
|
||||
<double>1.000000000000000</double>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="2">
|
||||
<widget class="QCheckBox" name="reXunspecBox">
|
||||
<property name="toolTip">
|
||||
<string>unspecified</string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string/>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="3">
|
||||
<widget class="Gui::QuantitySpinBox" name="imagXQSB">
|
||||
<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</string>
|
||||
</property>
|
||||
<property name="keyboardTracking">
|
||||
<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>
|
||||
</property>
|
||||
<property name="singleStep">
|
||||
<double>1.000000000000000</double>
|
||||
</property>
|
||||
<property name="value">
|
||||
<double>1.000000000000000</double>
|
||||
</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">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>y</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="3" column="1">
|
||||
<widget class="Gui::QuantitySpinBox" name="realYQSB">
|
||||
<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</string>
|
||||
</property>
|
||||
<property name="keyboardTracking">
|
||||
<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>
|
||||
</property>
|
||||
<property name="singleStep">
|
||||
<double>1.000000000000000</double>
|
||||
</property>
|
||||
<property name="value">
|
||||
<double>1.000000000000000</double>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="3" column="2">
|
||||
<widget class="QCheckBox" name="reYunspecBox">
|
||||
<property name="toolTip">
|
||||
<string>unspecified</string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string/>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="3" column="3">
|
||||
<widget class="Gui::QuantitySpinBox" name="imagYQSB">
|
||||
<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</string>
|
||||
</property>
|
||||
<property name="keyboardTracking">
|
||||
<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>
|
||||
</property>
|
||||
<property name="singleStep">
|
||||
<double>1.000000000000000</double>
|
||||
</property>
|
||||
<property name="value">
|
||||
<double>1.000000000000000</double>
|
||||
</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">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>z</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="4" column="1">
|
||||
<widget class="Gui::QuantitySpinBox" name="realZQSB">
|
||||
<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</string>
|
||||
</property>
|
||||
<property name="keyboardTracking">
|
||||
<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>
|
||||
</property>
|
||||
<property name="singleStep">
|
||||
<double>1.000000000000000</double>
|
||||
</property>
|
||||
<property name="value">
|
||||
<double>1.000000000000000</double>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="4" column="2">
|
||||
<widget class="QCheckBox" name="reZunspecBox">
|
||||
<property name="toolTip">
|
||||
<string>unspecified</string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string/>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="4" column="3">
|
||||
<widget class="Gui::QuantitySpinBox" name="imagZQSB">
|
||||
<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</string>
|
||||
</property>
|
||||
<property name="keyboardTracking">
|
||||
<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>
|
||||
</property>
|
||||
<property name="singleStep">
|
||||
<double>1.000000000000000</double>
|
||||
</property>
|
||||
<property name="value">
|
||||
<double>1.000000000000000</double>
|
||||
</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>
|
||||
<string>Imaginary part is only used for equations
|
||||
with harmonic/oscillating driving current</string>
|
||||
</property>
|
||||
<property name="checkable">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="gridLayout_3" columnstretch="0,255,255">
|
||||
<item row="0" column="1">
|
||||
<widget class="QLabel" name="l_custom_real">
|
||||
<property name="enabled">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Real</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="2">
|
||||
<widget class="QLabel" name="l_custom_imag">
|
||||
<property name="enabled">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Imaginary</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="0">
|
||||
<widget class="QCheckBox" name="ckb_magnetization_1">
|
||||
<property name="text">
|
||||
<string>x</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="1">
|
||||
<widget class="Gui::QuantitySpinBox" name="qsb_magnetization_re_1">
|
||||
<property name="enabled">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="toolTip">
|
||||
<string>Real part of magnetization x-component</string>
|
||||
</property>
|
||||
<property name="keyboardTracking">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="unit" stdset="0">
|
||||
<string notr="true">A/m</string>
|
||||
</property>
|
||||
<property name="singleStep">
|
||||
<double>1.000000000000000</double>
|
||||
</property>
|
||||
<property name="value">
|
||||
<double>0.000000000000000</double>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="2">
|
||||
<widget class="Gui::QuantitySpinBox" name="qsb_magnetization_im_1">
|
||||
<property name="enabled">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="toolTip">
|
||||
<string>Imaginary part of magnetization x-component</string>
|
||||
</property>
|
||||
<property name="keyboardTracking">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="unit" stdset="0">
|
||||
<string notr="true">A/m</string>
|
||||
</property>
|
||||
<property name="singleStep">
|
||||
<double>1.000000000000000</double>
|
||||
</property>
|
||||
<property name="value">
|
||||
<double>0.000000000000000</double>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="0">
|
||||
<widget class="QCheckBox" name="ckb_magnetization_2">
|
||||
<property name="text">
|
||||
<string>y</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="1">
|
||||
<widget class="Gui::QuantitySpinBox" name="qsb_magnetization_re_2">
|
||||
<property name="enabled">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="toolTip">
|
||||
<string>Real part of magnetization y-component</string>
|
||||
</property>
|
||||
<property name="keyboardTracking">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="unit" stdset="0">
|
||||
<string notr="true">A/m</string>
|
||||
</property>
|
||||
<property name="singleStep">
|
||||
<double>1.000000000000000</double>
|
||||
</property>
|
||||
<property name="value">
|
||||
<double>0.000000000000000</double>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="2">
|
||||
<widget class="Gui::QuantitySpinBox" name="qsb_magnetization_im_2">
|
||||
<property name="enabled">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="toolTip">
|
||||
<string>Imaginary part of magnetization y-component</string>
|
||||
</property>
|
||||
<property name="keyboardTracking">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="unit" stdset="0">
|
||||
<string notr="true">A/m</string>
|
||||
</property>
|
||||
<property name="singleStep">
|
||||
<double>1.000000000000000</double>
|
||||
</property>
|
||||
<property name="value">
|
||||
<double>0.000000000000000</double>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="3" column="0">
|
||||
<widget class="QCheckBox" name="ckb_magnetization_3">
|
||||
<property name="text">
|
||||
<string>z</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="3" column="1">
|
||||
<widget class="Gui::QuantitySpinBox" name="qsb_magnetization_re_3">
|
||||
<property name="enabled">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="toolTip">
|
||||
<string>Real part of magnetization z-component</string>
|
||||
</property>
|
||||
<property name="keyboardTracking">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="unit" stdset="0">
|
||||
<string notr="true">A/m</string>
|
||||
</property>
|
||||
<property name="singleStep">
|
||||
<double>1.000000000000000</double>
|
||||
</property>
|
||||
<property name="value">
|
||||
<double>0.000000000000000</double>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="3" column="2">
|
||||
<widget class="Gui::QuantitySpinBox" name="qsb_magnetization_im_3">
|
||||
<property name="enabled">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="toolTip">
|
||||
<string>Imaginary part of magnetization z-component</string>
|
||||
</property>
|
||||
<property name="keyboardTracking">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="unit" stdset="0">
|
||||
<string notr="true">A/m</string>
|
||||
</property>
|
||||
<property name="singleStep">
|
||||
<double>1.000000000000000</double>
|
||||
</property>
|
||||
<property name="value">
|
||||
<double>0.000000000000000</double>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
@@ -345,102 +216,4 @@
|
||||
</customwidget>
|
||||
</customwidgets>
|
||||
<resources/>
|
||||
<connections>
|
||||
<connection>
|
||||
<sender>reXunspecBox</sender>
|
||||
<signal>toggled(bool)</signal>
|
||||
<receiver>realXQSB</receiver>
|
||||
<slot>setDisabled(bool)</slot>
|
||||
<hints>
|
||||
<hint type="sourcelabel">
|
||||
<x>152</x>
|
||||
<y>61</y>
|
||||
</hint>
|
||||
<hint type="destinationlabel">
|
||||
<x>80</x>
|
||||
<y>61</y>
|
||||
</hint>
|
||||
</hints>
|
||||
</connection>
|
||||
<connection>
|
||||
<sender>reYunspecBox</sender>
|
||||
<signal>toggled(bool)</signal>
|
||||
<receiver>realYQSB</receiver>
|
||||
<slot>setDisabled(bool)</slot>
|
||||
<hints>
|
||||
<hint type="sourcelabel">
|
||||
<x>152</x>
|
||||
<y>87</y>
|
||||
</hint>
|
||||
<hint type="destinationlabel">
|
||||
<x>80</x>
|
||||
<y>87</y>
|
||||
</hint>
|
||||
</hints>
|
||||
</connection>
|
||||
<connection>
|
||||
<sender>imZunspecBox</sender>
|
||||
<signal>toggled(bool)</signal>
|
||||
<receiver>imagZQSB</receiver>
|
||||
<slot>setDisabled(bool)</slot>
|
||||
<hints>
|
||||
<hint type="sourcelabel">
|
||||
<x>297</x>
|
||||
<y>113</y>
|
||||
</hint>
|
||||
<hint type="destinationlabel">
|
||||
<x>224</x>
|
||||
<y>113</y>
|
||||
</hint>
|
||||
</hints>
|
||||
</connection>
|
||||
<connection>
|
||||
<sender>imYunspecBox</sender>
|
||||
<signal>toggled(bool)</signal>
|
||||
<receiver>imagYQSB</receiver>
|
||||
<slot>setDisabled(bool)</slot>
|
||||
<hints>
|
||||
<hint type="sourcelabel">
|
||||
<x>297</x>
|
||||
<y>87</y>
|
||||
</hint>
|
||||
<hint type="destinationlabel">
|
||||
<x>224</x>
|
||||
<y>87</y>
|
||||
</hint>
|
||||
</hints>
|
||||
</connection>
|
||||
<connection>
|
||||
<sender>imXunspecBox</sender>
|
||||
<signal>toggled(bool)</signal>
|
||||
<receiver>imagXQSB</receiver>
|
||||
<slot>setDisabled(bool)</slot>
|
||||
<hints>
|
||||
<hint type="sourcelabel">
|
||||
<x>297</x>
|
||||
<y>61</y>
|
||||
</hint>
|
||||
<hint type="destinationlabel">
|
||||
<x>224</x>
|
||||
<y>61</y>
|
||||
</hint>
|
||||
</hints>
|
||||
</connection>
|
||||
<connection>
|
||||
<sender>reZunspecBox</sender>
|
||||
<signal>toggled(bool)</signal>
|
||||
<receiver>realZQSB</receiver>
|
||||
<slot>setDisabled(bool)</slot>
|
||||
<hints>
|
||||
<hint type="sourcelabel">
|
||||
<x>152</x>
|
||||
<y>113</y>
|
||||
</hint>
|
||||
<hint type="destinationlabel">
|
||||
<x>80</x>
|
||||
<y>113</y>
|
||||
</hint>
|
||||
</hints>
|
||||
</connection>
|
||||
</connections>
|
||||
</ui>
|
||||
|
||||
@@ -194,7 +194,7 @@ def setup(doc=None, solvertype="elmer"):
|
||||
Magnetization.Magnetization_re_1 = "7500.000 A/m"
|
||||
Magnetization.Magnetization_re_2 = "7500.000 A/m"
|
||||
Magnetization.Magnetization_re_3 = "7500.000 A/m"
|
||||
Magnetization.Magnetization_re_2_Disabled = False
|
||||
Magnetization.EnableMagnetization_2 = True
|
||||
analysis.addObject(Magnetization)
|
||||
|
||||
# mesh
|
||||
|
||||
@@ -248,14 +248,14 @@ def setup(doc=None, solvertype="elmer"):
|
||||
Magnetization_lower = ObjectsFem.makeConstraintMagnetization(doc, "Magnetization_Lower_End")
|
||||
Magnetization_lower.References = [(BooleanFragments, "Face1")]
|
||||
Magnetization_lower.Magnetization_re_1 = "-7500.0 A/m"
|
||||
Magnetization_lower.Magnetization_re_1_Disabled = False
|
||||
Magnetization_lower.EnableMagnetization_1 = True
|
||||
analysis.addObject(Magnetization_lower)
|
||||
|
||||
# magnetization upper
|
||||
Magnetization_upper = ObjectsFem.makeConstraintMagnetization(doc, "Magnetization_Upper_End")
|
||||
Magnetization_upper.References = [(BooleanFragments, "Face2")]
|
||||
Magnetization_upper.Magnetization_re_1 = "7500.0 A/m"
|
||||
Magnetization_upper.Magnetization_re_1_Disabled = False
|
||||
Magnetization_upper.EnableMagnetization_1 = True
|
||||
analysis.addObject(Magnetization_upper)
|
||||
|
||||
# mesh
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
# ***************************************************************************
|
||||
# * Copyright (c) 2023 Uwe Stöhr <uwestoehr@lyx.org> *
|
||||
# * Copyright (c) 2025 Mario Passaglia <mpassaglia[at]cbc.uba.ar> *
|
||||
# * *
|
||||
# * This file is part of the FreeCAD CAx development system. *
|
||||
# * *
|
||||
@@ -22,15 +23,19 @@
|
||||
# ***************************************************************************
|
||||
|
||||
__title__ = "FreeCAD FEM constraint magnetization document object"
|
||||
__author__ = "Uwe Stöhr"
|
||||
__author__ = "Uwe Stöhr, Mario Passaglia"
|
||||
__url__ = "https://www.freecad.org"
|
||||
|
||||
## @package constraint_magnetization
|
||||
# \ingroup FEM
|
||||
# \brief constraint magnetization source object
|
||||
|
||||
from FreeCAD import Base
|
||||
|
||||
from . import base_fempythonobject
|
||||
|
||||
_PropHelper = base_fempythonobject._PropHelper
|
||||
|
||||
|
||||
class ConstraintMagnetization(base_fempythonobject.BaseFemPythonObject):
|
||||
|
||||
@@ -38,101 +43,132 @@ class ConstraintMagnetization(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::PropertyMagnetization",
|
||||
name="Magnetization_re_1",
|
||||
group="Magnetization Vector",
|
||||
doc="Real part of magnetization x-component",
|
||||
value="0 A/m",
|
||||
)
|
||||
)
|
||||
prop.append(
|
||||
_PropHelper(
|
||||
type="App::PropertyMagnetization",
|
||||
name="Magnetization_re_2",
|
||||
group="Magnetization Vector",
|
||||
doc="Real part of magnetization y-component",
|
||||
value="0 A/m",
|
||||
)
|
||||
)
|
||||
prop.append(
|
||||
_PropHelper(
|
||||
type="App::PropertyMagnetization",
|
||||
name="Magnetization_re_3",
|
||||
group="Magnetization Vector",
|
||||
doc="Real part of magnetization z-component",
|
||||
value="0 A/m",
|
||||
)
|
||||
)
|
||||
prop.append(
|
||||
_PropHelper(
|
||||
type="App::PropertyMagnetization",
|
||||
name="Magnetization_im_1",
|
||||
group="Magnetization Vector",
|
||||
doc="Imaginary part of magnetization x-component",
|
||||
value="0 A/m",
|
||||
)
|
||||
)
|
||||
prop.append(
|
||||
_PropHelper(
|
||||
type="App::PropertyMagnetization",
|
||||
name="Magnetization_im_2",
|
||||
group="Magnetization Vector",
|
||||
doc="Imaginary part of magnetization y-component",
|
||||
value="0 A/m",
|
||||
)
|
||||
)
|
||||
prop.append(
|
||||
_PropHelper(
|
||||
type="App::PropertyMagnetization",
|
||||
name="Magnetization_im_3",
|
||||
group="Magnetization Vector",
|
||||
doc="Imaginary part of magnetization z-component",
|
||||
value="0 A/m",
|
||||
)
|
||||
)
|
||||
prop.append(
|
||||
_PropHelper(
|
||||
type="App::PropertyBool",
|
||||
name="EnableMagnetization_1",
|
||||
group="Magnetization Vector",
|
||||
doc="Enable magnetization x component",
|
||||
value=False,
|
||||
)
|
||||
)
|
||||
prop.append(
|
||||
_PropHelper(
|
||||
type="App::PropertyBool",
|
||||
name="EnableMagnetization_2",
|
||||
group="Magnetization Vector",
|
||||
doc="Enable magnetization y component",
|
||||
value=False,
|
||||
)
|
||||
)
|
||||
prop.append(
|
||||
_PropHelper(
|
||||
type="App::PropertyBool",
|
||||
name="EnableMagnetization_3",
|
||||
group="Magnetization Vector",
|
||||
doc="Enable magnetization z component",
|
||||
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, "Magnetization_re_1"):
|
||||
obj.addProperty(
|
||||
"App::PropertyMagnetization",
|
||||
"Magnetization_re_1",
|
||||
"Vector Potential",
|
||||
"Real part of magnetization x-component",
|
||||
)
|
||||
obj.setPropertyStatus("Magnetization_re_1", "LockDynamic")
|
||||
obj.Magnetization_re_1 = "0 A/m"
|
||||
if not hasattr(obj, "Magnetization_re_2"):
|
||||
obj.addProperty(
|
||||
"App::PropertyMagnetization",
|
||||
"Magnetization_re_2",
|
||||
"Vector Potential",
|
||||
"Real part of magnetization y-component",
|
||||
)
|
||||
obj.setPropertyStatus("Magnetization_re_2", "LockDynamic")
|
||||
obj.Magnetization_re_2 = "0 A/m"
|
||||
if not hasattr(obj, "Magnetization_re_3"):
|
||||
obj.addProperty(
|
||||
"App::PropertyMagnetization",
|
||||
"Magnetization_re_3",
|
||||
"Vector Potential",
|
||||
"Real part of magnetization z-component",
|
||||
)
|
||||
obj.setPropertyStatus("Magnetization_re_3", "LockDynamic")
|
||||
obj.Magnetization_re_3 = "0 A/m"
|
||||
if not hasattr(obj, "Magnetization_im_1"):
|
||||
obj.addProperty(
|
||||
"App::PropertyMagnetization",
|
||||
"Magnetization_im_1",
|
||||
"Vector Potential",
|
||||
"Imaginary part of magnetization x-component",
|
||||
)
|
||||
obj.setPropertyStatus("Magnetization_im_1", "LockDynamic")
|
||||
obj.Magnetization_im_1 = "0 A/m"
|
||||
if not hasattr(obj, "Magnetization_im_2"):
|
||||
obj.addProperty(
|
||||
"App::PropertyMagnetization",
|
||||
"Magnetization_im_2",
|
||||
"Vector Potential",
|
||||
"Imaginary part of magnetization y-component",
|
||||
)
|
||||
obj.setPropertyStatus("Magnetization_im_2", "LockDynamic")
|
||||
obj.Magnetization_im_2 = "0 A/m"
|
||||
if not hasattr(obj, "Magnetization_im_3"):
|
||||
obj.addProperty(
|
||||
"App::PropertyMagnetization",
|
||||
"Magnetization_im_3",
|
||||
"Vector Potential",
|
||||
"Imaginary part of magnetization z-component",
|
||||
)
|
||||
obj.setPropertyStatus("Magnetization_im_3", "LockDynamic")
|
||||
obj.Magnetization_im_3 = "0 A/m"
|
||||
# enable current density properties from old properties
|
||||
try:
|
||||
obj.EnableMagnetization_1 = not obj.getPropertyByName(
|
||||
"Magnetization_re_1_Disabled"
|
||||
) or not obj.getPropertyByName("Magnetization_im_1_Disabled")
|
||||
|
||||
# now the enable bools
|
||||
if not hasattr(obj, "Magnetization_re_1_Disabled"):
|
||||
obj.addProperty(
|
||||
"App::PropertyBool", "Magnetization_re_1_Disabled", "Vector Potential", ""
|
||||
)
|
||||
obj.setPropertyStatus("Magnetization_re_1_Disabled", "LockDynamic")
|
||||
obj.Magnetization_re_1_Disabled = True
|
||||
if not hasattr(obj, "Magnetization_re_2_Disabled"):
|
||||
obj.addProperty(
|
||||
"App::PropertyBool", "Magnetization_re_2_Disabled", "Vector Potential", ""
|
||||
)
|
||||
obj.setPropertyStatus("Magnetization_re_2_Disabled", "LockDynamic")
|
||||
obj.Magnetization_re_2_Disabled = True
|
||||
if not hasattr(obj, "Magnetization_re_3_Disabled"):
|
||||
obj.addProperty(
|
||||
"App::PropertyBool", "Magnetization_re_3_Disabled", "Vector Potential", ""
|
||||
)
|
||||
obj.setPropertyStatus("Magnetization_re_3_Disabled", "LockDynamic")
|
||||
obj.Magnetization_re_3_Disabled = True
|
||||
if not hasattr(obj, "Magnetization_im_1_Disabled"):
|
||||
obj.addProperty(
|
||||
"App::PropertyBool", "Magnetization_im_1_Disabled", "Vector Potential", ""
|
||||
)
|
||||
obj.setPropertyStatus("Magnetization_im_1_Disabled", "LockDynamic")
|
||||
obj.Magnetization_im_1_Disabled = True
|
||||
if not hasattr(obj, "Magnetization_im_2_Disabled"):
|
||||
obj.addProperty(
|
||||
"App::PropertyBool", "Magnetization_im_2_Disabled", "Vector Potential", ""
|
||||
)
|
||||
obj.setPropertyStatus("Magnetization_im_2_Disabled", "LockDynamic")
|
||||
obj.Magnetization_im_2_Disabled = True
|
||||
if not hasattr(obj, "Magnetization_im_3_Disabled"):
|
||||
obj.addProperty(
|
||||
"App::PropertyBool", "Magnetization_im_3_Disabled", "Vector Potential", ""
|
||||
)
|
||||
obj.setPropertyStatus("Magnetization_im_3_Disabled", "LockDynamic")
|
||||
obj.Magnetization_im_3_Disabled = True
|
||||
obj.EnableMagnetization_2 = not obj.getPropertyByName(
|
||||
"Magnetization_re_2_Disabled"
|
||||
) or not obj.getPropertyByName("Magnetization_im_2_Disabled")
|
||||
|
||||
obj.EnableMagnetization_3 = not obj.getPropertyByName(
|
||||
"Magnetization_re_3_Disabled"
|
||||
) or not obj.getPropertyByName("Magnetization_im_3_Disabled")
|
||||
|
||||
# remove old properties
|
||||
obj.setPropertyStatus("Magnetization_re_1_Disabled", "-LockDynamic")
|
||||
obj.removeProperty("Magnetization_re_1_Disabled")
|
||||
obj.setPropertyStatus("Magnetization_re_2_Disabled", "-LockDynamic")
|
||||
obj.removeProperty("Magnetization_re_2_Disabled")
|
||||
obj.setPropertyStatus("Magnetization_re_3_Disabled", "-LockDynamic")
|
||||
obj.removeProperty("Magnetization_re_3_Disabled")
|
||||
obj.setPropertyStatus("Magnetization_im_1_Disabled", "-LockDynamic")
|
||||
obj.removeProperty("Magnetization_im_1_Disabled")
|
||||
obj.setPropertyStatus("Magnetization_im_2_Disabled", "-LockDynamic")
|
||||
obj.removeProperty("Magnetization_im_2_Disabled")
|
||||
obj.setPropertyStatus("Magnetization_im_3_Disabled", "-LockDynamic")
|
||||
obj.removeProperty("Magnetization_im_3_Disabled")
|
||||
|
||||
except Base.PropertyError:
|
||||
pass
|
||||
|
||||
@@ -144,20 +144,20 @@ class MgDyn2Dwriter:
|
||||
currentDensity = obj.NormalCurrentDensity_im.getValueAs("A/m^2").Value
|
||||
self.write.bodyForce(name, "Current Density Im", round(currentDensity, 6))
|
||||
|
||||
if hasattr(obj, "Magnetization_re_1"):
|
||||
if femutils.is_derived_from(obj, "Fem::ConstraintMagnetization"):
|
||||
# output only if magnetization is enabled and needed
|
||||
if not obj.Magnetization_re_1_Disabled:
|
||||
if obj.EnableMagnetization_1:
|
||||
magnetization = float(obj.Magnetization_re_1.getValueAs("A/m"))
|
||||
self.write.material(name, "Magnetization 1", round(magnetization, 6))
|
||||
if not obj.Magnetization_re_2_Disabled:
|
||||
if obj.EnableMagnetization_2:
|
||||
magnetization = float(obj.Magnetization_re_2.getValueAs("A/m"))
|
||||
self.write.material(name, "Magnetization 2", round(magnetization, 6))
|
||||
# imaginaries are only needed for harmonic equation
|
||||
if equation.IsHarmonic:
|
||||
if not obj.Magnetization_im_1_Disabled:
|
||||
if obj.EnableMagnetization_1:
|
||||
magnetization = float(obj.Magnetization_im_1.getValueAs("A/m"))
|
||||
self.write.material(name, "Magnetization Im 1", round(magnetization, 6))
|
||||
if not obj.Magnetization_im_2_Disabled:
|
||||
if obj.EnableMagnetization_2:
|
||||
magnetization = float(obj.Magnetization_im_2.getValueAs("A/m"))
|
||||
self.write.material(name, "Magnetization Im 2", round(magnetization, 6))
|
||||
|
||||
|
||||
@@ -185,26 +185,26 @@ class MgDynwriter:
|
||||
currentDensity = float(obj.CurrentDensity_im_3.getValueAs("A/m^2"))
|
||||
self.write.bodyForce(name, "Current Density Im 3", round(currentDensity, 6))
|
||||
|
||||
if hasattr(obj, "Magnetization_im_1"):
|
||||
if femutils.is_derived_from(obj, "Fem::ConstraintMagnetization"):
|
||||
# output only if magnetization is enabled and needed
|
||||
if not obj.Magnetization_re_1_Disabled:
|
||||
if obj.EnableMagnetization_1:
|
||||
magnetization = float(obj.Magnetization_re_1.getValueAs("A/m"))
|
||||
self.write.bodyForce(name, "Magnetization 1", magnetization)
|
||||
if not obj.Magnetization_re_2_Disabled:
|
||||
if obj.EnableMagnetization_2:
|
||||
magnetization = float(obj.Magnetization_re_2.getValueAs("A/m"))
|
||||
self.write.bodyForce(name, "Magnetization 2", magnetization)
|
||||
if not obj.Magnetization_re_3_Disabled:
|
||||
if obj.EnableMagnetization_3:
|
||||
magnetization = float(obj.Magnetization_re_3.getValueAs("A/m"))
|
||||
self.write.bodyForce(name, "Magnetization 3", magnetization)
|
||||
# imaginaries are only needed for harmonic equation
|
||||
if equation.IsHarmonic:
|
||||
if not obj.Magnetization_im_1_Disabled:
|
||||
if obj.EnableMagnetization_1:
|
||||
magnetization = float(obj.Magnetization_im_1.getValueAs("A/m"))
|
||||
self.write.bodyForce(name, "Magnetization Im 1", magnetization)
|
||||
if not obj.Magnetization_im_2_Disabled:
|
||||
if obj.EnableMagnetization_2:
|
||||
magnetization = float(obj.Magnetization_im_2.getValueAs("A/m"))
|
||||
self.write.bodyForce(name, "Magnetization Im 2", magnetization)
|
||||
if not obj.Magnetization_im_3_Disabled:
|
||||
if obj.EnableMagnetization_3:
|
||||
magnetization = float(obj.Magnetization_im_3.getValueAs("A/m"))
|
||||
self.write.bodyForce(name, "Magnetization Im 3", magnetization)
|
||||
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
# ***************************************************************************
|
||||
# * Copyright (c) 2023 Uwe Stöhr <uwestoehr@lyx.org> *
|
||||
# * Copyright (c) 2025 Mario Passaglia <mpassaglia[at]cbc.uba.ar> *
|
||||
# * *
|
||||
# * This file is part of the FreeCAD CAx development system. *
|
||||
# * *
|
||||
@@ -22,13 +23,15 @@
|
||||
# ***************************************************************************
|
||||
|
||||
__title__ = "FreeCAD FEM constraint magnetization task panel for the document object"
|
||||
__author__ = "Uwe Stöhr"
|
||||
__author__ = "Uwe Stöhr, Mario Passaglia"
|
||||
__url__ = "https://www.freecad.org"
|
||||
|
||||
## @package task_constraint_magnetization
|
||||
# \ingroup FEM
|
||||
# \brief task panel for constraint magnetization object
|
||||
|
||||
from PySide import QtCore
|
||||
|
||||
import FreeCAD
|
||||
import FreeCADGui
|
||||
|
||||
@@ -43,19 +46,18 @@ 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/Magnetization.ui"
|
||||
)
|
||||
self._initParamWidget()
|
||||
|
||||
# geometry selection widget
|
||||
# magnetization is always a body force for 3D, therefore only allow solid
|
||||
self._selectionWidget = selection_widgets.GeometryElementsSelection(
|
||||
self._selection_widget = selection_widgets.GeometryElementsSelection(
|
||||
obj.References, ["Solid", "Face"], True, False
|
||||
)
|
||||
|
||||
# form made from param and selection widget
|
||||
self.form = [self._paramWidget, self._selectionWidget]
|
||||
self.form = [self.parameter_widget, self._selection_widget]
|
||||
|
||||
analysis = obj.getParentGroup()
|
||||
self._mesh = None
|
||||
@@ -67,6 +69,54 @@ class _TaskPanel(base_femtaskpanel._BaseTaskPanel):
|
||||
self._partVisible = None
|
||||
self._meshVisible = None
|
||||
|
||||
QtCore.QObject.connect(
|
||||
self.parameter_widget.ckb_magnetization_1,
|
||||
QtCore.SIGNAL("toggled(bool)"),
|
||||
self.magnetization_1_enabled_changed,
|
||||
)
|
||||
QtCore.QObject.connect(
|
||||
self.parameter_widget.qsb_magnetization_re_1,
|
||||
QtCore.SIGNAL("valueChanged(Base::Quantity)"),
|
||||
self.magnetization_re_1_changed,
|
||||
)
|
||||
QtCore.QObject.connect(
|
||||
self.parameter_widget.ckb_magnetization_2,
|
||||
QtCore.SIGNAL("toggled(bool)"),
|
||||
self.magnetization_2_enabled_changed,
|
||||
)
|
||||
QtCore.QObject.connect(
|
||||
self.parameter_widget.qsb_magnetization_re_2,
|
||||
QtCore.SIGNAL("valueChanged(Base::Quantity)"),
|
||||
self.magnetization_re_2_changed,
|
||||
)
|
||||
QtCore.QObject.connect(
|
||||
self.parameter_widget.ckb_magnetization_3,
|
||||
QtCore.SIGNAL("toggled(bool)"),
|
||||
self.magnetization_3_enabled_changed,
|
||||
)
|
||||
QtCore.QObject.connect(
|
||||
self.parameter_widget.qsb_magnetization_re_3,
|
||||
QtCore.SIGNAL("valueChanged(Base::Quantity)"),
|
||||
self.magnetization_re_3_changed,
|
||||
)
|
||||
QtCore.QObject.connect(
|
||||
self.parameter_widget.qsb_magnetization_im_1,
|
||||
QtCore.SIGNAL("valueChanged(Base::Quantity)"),
|
||||
self.magnetization_im_1_changed,
|
||||
)
|
||||
QtCore.QObject.connect(
|
||||
self.parameter_widget.qsb_magnetization_im_2,
|
||||
QtCore.SIGNAL("valueChanged(Base::Quantity)"),
|
||||
self.magnetization_im_2_changed,
|
||||
)
|
||||
QtCore.QObject.connect(
|
||||
self.parameter_widget.qsb_magnetization_im_3,
|
||||
QtCore.SIGNAL("valueChanged(Base::Quantity)"),
|
||||
self.magnetization_im_3_changed,
|
||||
)
|
||||
|
||||
self.init_parameter_widget()
|
||||
|
||||
def open(self):
|
||||
if self._mesh is not None and self._part is not None:
|
||||
self._meshVisible = self._mesh.ViewObject.isVisible()
|
||||
@@ -76,14 +126,14 @@ class _TaskPanel(base_femtaskpanel._BaseTaskPanel):
|
||||
|
||||
def reject(self):
|
||||
self._restoreVisibility()
|
||||
self._selectionWidget.finish_selection()
|
||||
self._selection_widget.finish_selection()
|
||||
return super().reject()
|
||||
|
||||
def accept(self):
|
||||
if self.obj.References != self._selectionWidget.references:
|
||||
self.obj.References = self._selectionWidget.references
|
||||
self._applyWidgetChanges()
|
||||
self._selectionWidget.finish_selection()
|
||||
if self.obj.References != self._selection_widget.references:
|
||||
self.obj.References = self._selection_widget.references
|
||||
self._set_params()
|
||||
self._selection_widget.finish_selection()
|
||||
self._restoreVisibility()
|
||||
return super().accept()
|
||||
|
||||
@@ -98,81 +148,102 @@ class _TaskPanel(base_femtaskpanel._BaseTaskPanel):
|
||||
else:
|
||||
self._part.ViewObject.hide()
|
||||
|
||||
def _initParamWidget(self):
|
||||
self._paramWidget.realXQSB.setProperty("value", self.obj.Magnetization_re_1)
|
||||
FreeCADGui.ExpressionBinding(self._paramWidget.realXQSB).bind(
|
||||
def _get_params(self):
|
||||
self.magnetization_re_1 = self.obj.Magnetization_re_1
|
||||
self.magnetization_re_2 = self.obj.Magnetization_re_2
|
||||
self.magnetization_re_3 = self.obj.Magnetization_re_3
|
||||
self.magnetization_im_1 = self.obj.Magnetization_im_1
|
||||
self.magnetization_im_2 = self.obj.Magnetization_im_2
|
||||
self.magnetization_im_3 = self.obj.Magnetization_im_3
|
||||
|
||||
self.magnetization_1_enabled = self.obj.EnableMagnetization_1
|
||||
self.magnetization_2_enabled = self.obj.EnableMagnetization_2
|
||||
self.magnetization_3_enabled = self.obj.EnableMagnetization_3
|
||||
|
||||
def _set_params(self):
|
||||
self.obj.Magnetization_re_1 = self.magnetization_re_1
|
||||
self.obj.Magnetization_re_2 = self.magnetization_re_2
|
||||
self.obj.Magnetization_re_3 = self.magnetization_re_3
|
||||
self.obj.Magnetization_im_1 = self.magnetization_im_1
|
||||
self.obj.Magnetization_im_2 = self.magnetization_im_2
|
||||
self.obj.Magnetization_im_3 = self.magnetization_im_3
|
||||
|
||||
self.obj.EnableMagnetization_1 = self.magnetization_1_enabled
|
||||
self.obj.EnableMagnetization_2 = self.magnetization_2_enabled
|
||||
self.obj.EnableMagnetization_3 = self.magnetization_3_enabled
|
||||
|
||||
def init_parameter_widget(self):
|
||||
self._get_params()
|
||||
|
||||
self.parameter_widget.qsb_magnetization_re_1.setProperty("value", self.magnetization_re_1)
|
||||
self.parameter_widget.qsb_magnetization_re_1.setEnabled(self.magnetization_1_enabled)
|
||||
FreeCADGui.ExpressionBinding(self.parameter_widget.qsb_magnetization_re_1).bind(
|
||||
self.obj, "Magnetization_re_1"
|
||||
)
|
||||
self._paramWidget.realYQSB.setProperty("value", self.obj.Magnetization_re_2)
|
||||
FreeCADGui.ExpressionBinding(self._paramWidget.realYQSB).bind(
|
||||
|
||||
self.parameter_widget.qsb_magnetization_re_2.setProperty("value", self.magnetization_re_2)
|
||||
self.parameter_widget.qsb_magnetization_re_2.setEnabled(self.magnetization_2_enabled)
|
||||
FreeCADGui.ExpressionBinding(self.parameter_widget.qsb_magnetization_re_2).bind(
|
||||
self.obj, "Magnetization_re_2"
|
||||
)
|
||||
self._paramWidget.realZQSB.setProperty("value", self.obj.Magnetization_re_3)
|
||||
FreeCADGui.ExpressionBinding(self._paramWidget.realZQSB).bind(
|
||||
|
||||
self.parameter_widget.qsb_magnetization_re_3.setProperty("value", self.magnetization_re_3)
|
||||
self.parameter_widget.qsb_magnetization_re_3.setEnabled(self.magnetization_3_enabled)
|
||||
FreeCADGui.ExpressionBinding(self.parameter_widget.qsb_magnetization_re_3).bind(
|
||||
self.obj, "Magnetization_re_3"
|
||||
)
|
||||
self._paramWidget.imagXQSB.setProperty("value", self.obj.Magnetization_im_1)
|
||||
FreeCADGui.ExpressionBinding(self._paramWidget.imagXQSB).bind(
|
||||
|
||||
self.parameter_widget.qsb_magnetization_im_1.setProperty("value", self.magnetization_im_1)
|
||||
self.parameter_widget.qsb_magnetization_im_1.setEnabled(self.magnetization_1_enabled)
|
||||
FreeCADGui.ExpressionBinding(self.parameter_widget.qsb_magnetization_im_1).bind(
|
||||
self.obj, "Magnetization_im_1"
|
||||
)
|
||||
self._paramWidget.imagYQSB.setProperty("value", self.obj.Magnetization_im_2)
|
||||
FreeCADGui.ExpressionBinding(self._paramWidget.imagYQSB).bind(
|
||||
|
||||
self.parameter_widget.qsb_magnetization_im_2.setProperty("value", self.magnetization_im_2)
|
||||
self.parameter_widget.qsb_magnetization_im_2.setEnabled(self.magnetization_2_enabled)
|
||||
FreeCADGui.ExpressionBinding(self.parameter_widget.qsb_magnetization_im_2).bind(
|
||||
self.obj, "Magnetization_im_2"
|
||||
)
|
||||
self._paramWidget.imagZQSB.setProperty("value", self.obj.Magnetization_im_3)
|
||||
FreeCADGui.ExpressionBinding(self._paramWidget.imagZQSB).bind(
|
||||
|
||||
self.parameter_widget.qsb_magnetization_im_3.setProperty("value", self.magnetization_im_3)
|
||||
self.parameter_widget.qsb_magnetization_im_3.setEnabled(self.magnetization_3_enabled)
|
||||
FreeCADGui.ExpressionBinding(self.parameter_widget.qsb_magnetization_im_3).bind(
|
||||
self.obj, "Magnetization_im_3"
|
||||
)
|
||||
|
||||
self._paramWidget.reXunspecBox.setChecked(self.obj.Magnetization_re_1_Disabled)
|
||||
self._paramWidget.reYunspecBox.setChecked(self.obj.Magnetization_re_2_Disabled)
|
||||
self._paramWidget.reZunspecBox.setChecked(self.obj.Magnetization_re_3_Disabled)
|
||||
self._paramWidget.imXunspecBox.setChecked(self.obj.Magnetization_im_1_Disabled)
|
||||
self._paramWidget.imYunspecBox.setChecked(self.obj.Magnetization_im_2_Disabled)
|
||||
self._paramWidget.imZunspecBox.setChecked(self.obj.Magnetization_im_3_Disabled)
|
||||
self.parameter_widget.ckb_magnetization_1.setChecked(self.magnetization_1_enabled)
|
||||
self.parameter_widget.ckb_magnetization_2.setChecked(self.magnetization_2_enabled)
|
||||
self.parameter_widget.ckb_magnetization_3.setChecked(self.magnetization_3_enabled)
|
||||
|
||||
def _applyMagnetizationChanges(self, enabledBox, magnetizationQSB):
|
||||
enabled = enabledBox.isChecked()
|
||||
magnetization = None
|
||||
try:
|
||||
magnetization = magnetizationQSB.property("value")
|
||||
except ValueError:
|
||||
FreeCAD.Console.PrintMessage(
|
||||
"Wrong input. Not recognised input: '{}' "
|
||||
"Magnetization has not been set.\n".format(magnetizationQSB.text())
|
||||
)
|
||||
magnetization = "0.0 A/m"
|
||||
return enabled, magnetization
|
||||
def magnetization_1_enabled_changed(self, value):
|
||||
self.magnetization_1_enabled = value
|
||||
self.parameter_widget.qsb_magnetization_re_1.setEnabled(value)
|
||||
self.parameter_widget.qsb_magnetization_im_1.setEnabled(value)
|
||||
|
||||
def _applyWidgetChanges(self):
|
||||
# apply the magnetizations and their enabled state
|
||||
self.obj.Magnetization_re_1_Disabled, self.obj.Magnetization_re_1 = (
|
||||
self._applyMagnetizationChanges(
|
||||
self._paramWidget.reXunspecBox, self._paramWidget.realXQSB
|
||||
)
|
||||
)
|
||||
self.obj.Magnetization_re_2_Disabled, self.obj.Magnetization_re_2 = (
|
||||
self._applyMagnetizationChanges(
|
||||
self._paramWidget.reYunspecBox, self._paramWidget.realYQSB
|
||||
)
|
||||
)
|
||||
self.obj.Magnetization_re_3_Disabled, self.obj.Magnetization_re_3 = (
|
||||
self._applyMagnetizationChanges(
|
||||
self._paramWidget.reZunspecBox, self._paramWidget.realZQSB
|
||||
)
|
||||
)
|
||||
self.obj.Magnetization_im_1_Disabled, self.obj.Magnetization_im_1 = (
|
||||
self._applyMagnetizationChanges(
|
||||
self._paramWidget.imXunspecBox, self._paramWidget.imagXQSB
|
||||
)
|
||||
)
|
||||
self.obj.Magnetization_im_2_Disabled, self.obj.Magnetization_im_2 = (
|
||||
self._applyMagnetizationChanges(
|
||||
self._paramWidget.imYunspecBox, self._paramWidget.imagYQSB
|
||||
)
|
||||
)
|
||||
self.obj.Magnetization_im_3_Disabled, self.obj.Magnetization_im_3 = (
|
||||
self._applyMagnetizationChanges(
|
||||
self._paramWidget.imZunspecBox, self._paramWidget.imagZQSB
|
||||
)
|
||||
)
|
||||
def magnetization_2_enabled_changed(self, value):
|
||||
self.magnetization_2_enabled = value
|
||||
self.parameter_widget.qsb_magnetization_re_2.setEnabled(value)
|
||||
self.parameter_widget.qsb_magnetization_im_2.setEnabled(value)
|
||||
|
||||
def magnetization_3_enabled_changed(self, value):
|
||||
self.magnetization_3_enabled = value
|
||||
self.parameter_widget.qsb_magnetization_re_3.setEnabled(value)
|
||||
self.parameter_widget.qsb_magnetization_im_3.setEnabled(value)
|
||||
|
||||
def magnetization_re_1_changed(self, value):
|
||||
self.magnetization_re_1 = value
|
||||
|
||||
def magnetization_re_2_changed(self, value):
|
||||
self.magnetization_re_2 = value
|
||||
|
||||
def magnetization_re_3_changed(self, value):
|
||||
self.magnetization_re_3 = value
|
||||
|
||||
def magnetization_im_1_changed(self, value):
|
||||
self.magnetization_im_1 = value
|
||||
|
||||
def magnetization_im_2_changed(self, value):
|
||||
self.magnetization_im_2 = value
|
||||
|
||||
def magnetization_im_3_changed(self, value):
|
||||
self.magnetization_im_3 = value
|
||||
|
||||
Reference in New Issue
Block a user