From 26dabdfca7c7881c20657964fcbcd7d436a50bab Mon Sep 17 00:00:00 2001 From: Bernd Hahnebach Date: Mon, 1 Aug 2016 21:57:28 +0100 Subject: [PATCH] FEM: task panel mechanical material: add thermomech related changes --- src/Mod/Fem/TaskPanelMechanicalMaterial.ui | 162 +++++++++++++++++++- src/Mod/Fem/_TaskPanelMechanicalMaterial.py | 55 +++++++ 2 files changed, 213 insertions(+), 4 deletions(-) diff --git a/src/Mod/Fem/TaskPanelMechanicalMaterial.ui b/src/Mod/Fem/TaskPanelMechanicalMaterial.ui index 9d443ef3d..aba82eed5 100644 --- a/src/Mod/Fem/TaskPanelMechanicalMaterial.ui +++ b/src/Mod/Fem/TaskPanelMechanicalMaterial.ui @@ -1,13 +1,13 @@ - MechanicalMaterial - + ThermalMechanicalMaterial + 0 0 - 253 - 541 + 370 + 713 @@ -232,6 +232,160 @@ + + + + + 16777215 + 1677215 + + + + Temperature-Dependant Material Properties + + + + + + QFormLayout::AllNonFixedFieldsGrow + + + + + Thermal Conductivity: + + + + + + + Expansion Coefficient: + + + + + + + + 0 + 0 + + + + + 80 + 20 + + + + 12 um/m/K + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + 2.000000000000000 + + + 2000000000.000000000000000 + + + m/m/K + + + 3 + + + 0.000000000000000 + + + + + + + Specific Heat: + + + + + + + + 0 + 0 + + + + + 80 + 20 + + + + 500 J/kg/K + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + 2.000000000000000 + + + 2050000000.000000000000000 + + + J/kg/K + + + 3 + + + 0.000000000000000 + + + + + + + + 0 + 0 + + + + + 80 + 20 + + + + 50 W/m/K + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + 2.000000000000000 + + + 2000000000.000000000000000 + + + W/m/K + + + 3 + + + 0.000000000000000 + + + + + + + + diff --git a/src/Mod/Fem/_TaskPanelMechanicalMaterial.py b/src/Mod/Fem/_TaskPanelMechanicalMaterial.py index 958eb1522..2c1725afb 100644 --- a/src/Mod/Fem/_TaskPanelMechanicalMaterial.py +++ b/src/Mod/Fem/_TaskPanelMechanicalMaterial.py @@ -51,6 +51,10 @@ class _TaskPanelMechanicalMaterial: QtCore.QObject.connect(self.form.spinBox_poisson_ratio, QtCore.SIGNAL("valueChanged(double)"), self.pr_changed) QtCore.QObject.connect(self.form.input_fd_density, QtCore.SIGNAL("valueChanged(double)"), self.density_changed) QtCore.QObject.connect(self.form.pushButton_Reference, QtCore.SIGNAL("clicked()"), self.add_references) + QtCore.QObject.connect(self.form.input_fd_thermal_conductivity, QtCore.SIGNAL("valueChanged(double)"), self.tc_changed) + QtCore.QObject.connect(self.form.input_fd_expansion_coefficient, QtCore.SIGNAL("valueChanged(double)"), self.tec_changed) + QtCore.QObject.connect(self.form.input_fd_specific_heat, QtCore.SIGNAL("valueChanged(double)"), self.sh_changed) + self.form.list_References.setContextMenuPolicy(QtCore.Qt.CustomContextMenu) self.form.list_References.connect(self.form.list_References, QtCore.SIGNAL("customContextMenuRequested(QPoint)"), self.references_list_right_clicked) @@ -155,6 +159,42 @@ class _TaskPanelMechanicalMaterial: material['PoissonRatio'] = unicode(value) self.material = material + def tc_changed(self, value): + import Units + old_tc = Units.Quantity(self.material['ThermalConductivity']).getValueAs("W/m/K") + variation = 0.001 + if value: + if not (1 - variation < float(old_tc) / value < 1 + variation): + # ThermalConductivity has changed + material = self.material + value_in_W_per_mK = value * 1e-3 # To compensate for use of SI units + material['ThermalConductivity'] = unicode(value_in_W_per_mK) + " W/m/K" + self.material = material + + def tec_changed(self, value): + import Units + old_tec = Units.Quantity(self.material['ThermalExpansionCoefficient']).getValueAs("um/m/K") + variation = 0.001 + if value: + if not (1 - variation < float(old_tec) / value < 1 + variation): + # ThermalExpansionCoefficient has changed + material = self.material + value_in_um_per_mK = value * 1e6 # To compensate for use of SI units + material['ThermalExpansionCoefficient'] = unicode(value_in_um_per_mK) + " um/m/K" + self.material = material + + def sh_changed(self, value): + import Units + old_sh = Units.Quantity(self.material['SpecificHeat']).getValueAs("J/kg/K") + variation = 0.001 + if value: + if not (1 - variation < float(old_sh) / value < 1 + variation): + # SpecificHeat has changed + material = self.material + value_in_J_per_kgK = value * 1e-6 # To compensate for use of SI units + material['SpecificHeat'] = unicode(value_in_J_per_kgK) + " J/kg/K" + self.material = material + def choose_material(self, index): if index < 0: return @@ -193,6 +233,21 @@ class _TaskPanelMechanicalMaterial: density = FreeCAD.Units.Quantity(matmap['Density']) density_with_new_unit = density.getValueAs(density_new_unit) self.form.input_fd_density.setText("{} {}".format(density_with_new_unit, density_new_unit)) + if 'ThermalConductivity' in matmap: + tc_new_unit = "W/m/K" + tc = FreeCAD.Units.Quantity(matmap['ThermalConductivity']) + tc_with_new_unit = tc.getValueAs(tc_new_unit) + self.form.input_fd_thermal_conductivity.setText("{} {}".format(tc_with_new_unit, tc_new_unit)) + if 'ThermalExpansionCoefficient' in matmap: + tec_new_unit = "um/m/K" + tec = FreeCAD.Units.Quantity(matmap['ThermalExpansionCoefficient']) + tec_with_new_unit = tec.getValueAs(tec_new_unit) + self.form.input_fd_expansion_coefficient.setText("{} {}".format(tec_with_new_unit, tec_new_unit)) + if 'SpecificHeat' in matmap: + sh_new_unit = "J/kg/K" + sh = FreeCAD.Units.Quantity(matmap['SpecificHeat']) + sh_with_new_unit = sh.getValueAs(sh_new_unit) + self.form.input_fd_specific_heat.setText("{} {}".format(sh_with_new_unit, sh_new_unit)) def add_transient_material(self, material): material_name = self.get_material_name(material)