FEM: Thermal expansion reference temperature for CalculiX analyses (#19285)

* FEM: Update task_material_common.py

* FEM: Update write_femelement_material.py

* FEM: Update Material.ui

* Fem: Enable material expansion reference temperature

* FEM: Update thermomech_bimetal.py

* FEM: Update thermomech_bimetal.inp

---------

Co-authored-by: marioalexis <mario.passaglia@gmail.com>
This commit is contained in:
FEA-eng
2025-01-29 13:37:02 +01:00
committed by GitHub
parent 07b2c87f0a
commit 456106910e
5 changed files with 88 additions and 171 deletions

View File

@@ -338,13 +338,53 @@
</widget>
</item>
<item row="2" column="0">
<widget class="QLabel" name="label_expansion_reference_temperature">
<property name="text">
<string>Expansion Reference Temperature:</string>
</property>
</widget>
</item>
<item row="2" column="1">
<widget class="Gui::QuantitySpinBox" name="qsb_expansion_reference_temperature">
<property name="enabled">
<bool>false</bool>
</property>
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>80</width>
</size>
</property>
<property name="alignment">
<set>Qt::AlignLeft|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
<property name="singleStep">
<double>1.000000000000000</double>
</property>
<property name="maximum">
<double>100000000000.00000000000000</double>
</property>
<property name="unit" stdset="0">
<string notr="true">K</string>
</property>
<property name="value" stdset="0">
<double>0.000000000000000</double>
</property>
</widget>
</item>
<item row="3" column="0">
<widget class="QLabel" name="label_14">
<property name="text">
<string>Specific Heat Capacity:</string>
</property>
</widget>
</item>
<item row="2" column="1">
<item row="3" column="1">
<widget class="Gui::QuantitySpinBox" name="qsb_specific_heat">
<property name="enabled">
<bool>false</bool>
@@ -413,150 +453,4 @@
</customwidget>
</customwidgets>
<resources/>
<connections>
<connection>
<sender>chbu_allow_edit</sender>
<signal>toggled(bool)</signal>
<receiver>qsb_density</receiver>
<slot>setEnabled(bool)</slot>
<hints>
<hint type="sourcelabel">
<x>272</x>
<y>162</y>
</hint>
<hint type="destinationlabel">
<x>250</x>
<y>364</y>
</hint>
</hints>
</connection>
<connection>
<sender>chbu_allow_edit</sender>
<signal>toggled(bool)</signal>
<receiver>qsb_young_modulus</receiver>
<slot>setEnabled(bool)</slot>
<hints>
<hint type="sourcelabel">
<x>272</x>
<y>162</y>
</hint>
<hint type="destinationlabel">
<x>242</x>
<y>425</y>
</hint>
</hints>
</connection>
<connection>
<sender>chbu_allow_edit</sender>
<signal>toggled(bool)</signal>
<receiver>qsb_poisson_ratio</receiver>
<slot>setEnabled(bool)</slot>
<hints>
<hint type="sourcelabel">
<x>272</x>
<y>162</y>
</hint>
<hint type="destinationlabel">
<x>242</x>
<y>451</y>
</hint>
</hints>
</connection>
<connection>
<sender>chbu_allow_edit</sender>
<signal>toggled(bool)</signal>
<receiver>qsb_kinematic_viscosity</receiver>
<slot>setEnabled(bool)</slot>
<hints>
<hint type="sourcelabel">
<x>272</x>
<y>162</y>
</hint>
<hint type="destinationlabel">
<x>247</x>
<y>512</y>
</hint>
</hints>
</connection>
<connection>
<sender>chbu_allow_edit</sender>
<signal>toggled(bool)</signal>
<receiver>qsb_thermal_conductivity</receiver>
<slot>setEnabled(bool)</slot>
<hints>
<hint type="sourcelabel">
<x>272</x>
<y>162</y>
</hint>
<hint type="destinationlabel">
<x>254</x>
<y>573</y>
</hint>
</hints>
</connection>
<connection>
<sender>chbu_allow_edit</sender>
<signal>toggled(bool)</signal>
<receiver>qsb_expansion_coefficient</receiver>
<slot>setEnabled(bool)</slot>
<hints>
<hint type="sourcelabel">
<x>272</x>
<y>162</y>
</hint>
<hint type="destinationlabel">
<x>254</x>
<y>599</y>
</hint>
</hints>
</connection>
<connection>
<sender>chbu_allow_edit</sender>
<signal>toggled(bool)</signal>
<receiver>qsb_specific_heat</receiver>
<slot>setEnabled(bool)</slot>
<hints>
<hint type="sourcelabel">
<x>272</x>
<y>162</y>
</hint>
<hint type="destinationlabel">
<x>254</x>
<y>625</y>
</hint>
</hints>
</connection>
<connection>
<sender>chbu_allow_edit</sender>
<signal>toggled(bool)</signal>
<receiver>label_vol_expansion_coefficient</receiver>
<slot>setEnabled(bool)</slot>
<hints>
<hint type="sourcelabel">
<x>272</x>
<y>162</y>
</hint>
<hint type="destinationlabel">
<x>67</x>
<y>651</y>
</hint>
</hints>
</connection>
<connection>
<sender>chbu_allow_edit</sender>
<signal>toggled(bool)</signal>
<receiver>pushButton_editMat</receiver>
<slot>setDisabled(bool)</slot>
<hints>
<hint type="sourcelabel">
<x>272</x>
<y>162</y>
</hint>
<hint type="destinationlabel">
<x>91</x>
<y>162</y>
</hint>
</hints>
</connection>
</connections>
</ui>

View File

@@ -159,6 +159,7 @@ def setup(doc=None, solvertype="ccxtools"):
mat["SpecificHeat"] = "385 J/kg/K"
mat["ThermalConductivity"] = "398 W/m/K"
mat["ThermalExpansionCoefficient"] = "0.0000165 m/m/K"
mat["ThermalExpansionReferenceTemperature"] = "273 K"
mat["Density"] = "8960.0 kg/m^3"
material_obj_bottom.Material = mat
material_obj_bottom.References = [(geom_obj, "Solid1")]
@@ -173,6 +174,7 @@ def setup(doc=None, solvertype="ccxtools"):
mat["SpecificHeat"] = "515 J/kg/K"
mat["ThermalConductivity"] = "13.5 W/m/K"
mat["ThermalExpansionCoefficient"] = "0.00000125 m/m/K"
mat["ThermalExpansionReferenceTemperature"] = "273 K"
material_obj_top.Material = mat
material_obj_top.References = [(geom_obj, "Solid2")]
analysis.addObject(material_obj_top)

View File

@@ -81,6 +81,10 @@ def write_femelement_material(f, ccxwriter):
if mat_obj.Category == "Solid":
TEC = FreeCAD.Units.Quantity(mat_obj.Material["ThermalExpansionCoefficient"])
TEC_in_mmK = TEC.getValueAs("mm/mm/K").Value
RT = FreeCAD.Units.Quantity(
mat_obj.Material["ThermalExpansionReferenceTemperature"]
)
RT_in_K = RT.getValueAs("K").Value
elif mat_obj.Category == "Fluid":
KV = FreeCAD.Units.Quantity(mat_obj.Material["KinematicViscosity"])
KV_in_mm2s = KV.getValueAs("mm^2/s").Value
@@ -100,7 +104,7 @@ def write_femelement_material(f, ccxwriter):
if mat_obj.Category == "Solid":
f.write("*CONDUCTIVITY\n")
f.write(f"{TC_in_WmK:.13G}\n")
f.write("*EXPANSION\n")
f.write(f"*EXPANSION, ZERO={RT_in_K:.13G}\n")
f.write(f"{TEC_in_mmK:.13G}\n")
f.write("*SPECIFIC HEAT\n")
f.write(f"{SH_in_JkgK:.13G}\n")

View File

@@ -98,6 +98,11 @@ class _TaskPanel(base_femtaskpanel._BaseTaskPanel):
QtCore.SIGNAL("editingFinished()"),
self.tec_changed,
)
QtCore.QObject.connect(
self.parameterWidget.qsb_expansion_reference_temperature,
QtCore.SIGNAL("editingFinished()"),
self.tec_changed,
)
QtCore.QObject.connect(
self.parameterWidget.qsb_specific_heat,
QtCore.SIGNAL("editingFinished()"),
@@ -154,13 +159,6 @@ class _TaskPanel(base_femtaskpanel._BaseTaskPanel):
self.selectionWidget.finish_selection()
return super().reject()
def isfloat(self, num):
try:
float(num)
return True
except ValueError:
return False
# choose material ****************************************************************************
def filter_models(self, category):
material_filter = Materials.MaterialFilter()
@@ -172,24 +170,26 @@ class _TaskPanel(base_femtaskpanel._BaseTaskPanel):
def toggleInputFieldsReadOnly(self):
if self.parameterWidget.chbu_allow_edit.isChecked():
self.parameterWidget.qsb_density.setReadOnly(False)
self.parameterWidget.qsb_young_modulus.setReadOnly(False)
self.parameterWidget.qsb_poisson_ratio.setReadOnly(False)
self.parameterWidget.qsb_thermal_conductivity.setReadOnly(False)
self.parameterWidget.qsb_expansion_coefficient.setReadOnly(False)
self.parameterWidget.qsb_specific_heat.setReadOnly(False)
self.parameterWidget.qsb_kinematic_viscosity.setReadOnly(False)
self.parameterWidget.qsb_density.setDisabled(False)
self.parameterWidget.qsb_young_modulus.setDisabled(False)
self.parameterWidget.qsb_poisson_ratio.setDisabled(False)
self.parameterWidget.qsb_thermal_conductivity.setDisabled(False)
self.parameterWidget.qsb_expansion_coefficient.setDisabled(False)
self.parameterWidget.qsb_expansion_reference_temperature.setDisabled(False)
self.parameterWidget.qsb_specific_heat.setDisabled(False)
self.parameterWidget.qsb_kinematic_viscosity.setDisabled(False)
self.parameterWidget.wgt_material_tree.setEnabled(False)
self.uuid = ""
self.mat_from_input_fields()
else:
self.parameterWidget.qsb_density.setReadOnly(True)
self.parameterWidget.qsb_young_modulus.setReadOnly(True)
self.parameterWidget.qsb_poisson_ratio.setReadOnly(True)
self.parameterWidget.qsb_thermal_conductivity.setReadOnly(True)
self.parameterWidget.qsb_expansion_coefficient.setReadOnly(True)
self.parameterWidget.qsb_specific_heat.setReadOnly(True)
self.parameterWidget.qsb_kinematic_viscosity.setReadOnly(True)
self.parameterWidget.qsb_density.setDisabled(True)
self.parameterWidget.qsb_young_modulus.setDisabled(True)
self.parameterWidget.qsb_poisson_ratio.setDisabled(True)
self.parameterWidget.qsb_thermal_conductivity.setDisabled(True)
self.parameterWidget.qsb_expansion_coefficient.setDisabled(True)
self.parameterWidget.qsb_expansion_reference_temperature.setDisabled(True)
self.parameterWidget.qsb_specific_heat.setDisabled(True)
self.parameterWidget.qsb_kinematic_viscosity.setDisabled(True)
self.parameterWidget.wgt_material_tree.setEnabled(True)
self.set_from_editor(self.material_tree.UUID)
@@ -224,6 +224,14 @@ class _TaskPanel(base_femtaskpanel._BaseTaskPanel):
self.parameterWidget.qsb_expansion_coefficient.property("value").UserString
)
def tec_changed(self):
if self.parameterWidget.chbu_allow_edit.isChecked():
self.material["ThermalExpansionReferenceTemperature"] = (
self.parameterWidget.qsb_expansion_reference_temperature.property(
"value"
).UserString
)
def sh_changed(self):
if self.parameterWidget.chbu_allow_edit.isChecked():
self.material["SpecificHeat"] = self.parameterWidget.qsb_specific_heat.property(
@@ -277,6 +285,12 @@ class _TaskPanel(base_femtaskpanel._BaseTaskPanel):
self.parameterWidget.qsb_expansion_coefficient.setProperty("value", v)
else:
self.parameterWidget.qsb_expansion_coefficient.setProperty("rawValue", 0.0)
if "ThermalExpansionReferenceTemperature" in matmap:
self.parameterWidget.qsb_expansion_reference_temperature.setProperty(
"value", Units.Quantity(matmap["ThermalExpansionReferenceTemperature"])
)
else:
self.parameterWidget.qsb_expansion_reference_temperature.setProperty("rawValue", 0.0)
if "SpecificHeat" in matmap:
self.parameterWidget.qsb_specific_heat.setProperty(
"value", Units.Quantity(matmap["SpecificHeat"])
@@ -299,6 +313,9 @@ class _TaskPanel(base_femtaskpanel._BaseTaskPanel):
d["Density"] = p.qsb_density.property("value").UserString
d["ThermalConductivity"] = p.qsb_thermal_conductivity.property("value").UserString
d["ThermalExpansionCoefficient"] = p.qsb_expansion_coefficient.property("value").UserString
d["ThermalExpansionReferenceTemperature"] = p.qsb_expansion_reference_temperature.property(
"value"
).UserString
d["SpecificHeat"] = p.qsb_specific_heat.property("value").UserString
if self.obj.Category == "Solid":
d["YoungsModulus"] = p.qsb_young_modulus.property("value").UserString

View File

@@ -7053,7 +7053,7 @@ Evolumes
119000,0.343
*CONDUCTIVITY
398
*EXPANSION
*EXPANSION, ZERO=273
1.65E-05
*SPECIFIC HEAT
385000000
@@ -7064,7 +7064,7 @@ Evolumes
140000,0.29
*CONDUCTIVITY
13.5
*EXPANSION
*EXPANSION, ZERO=273
1.25E-06
*SPECIFIC HEAT
515000000