Fem: Enable expression for the heat flux constraint task panel

This commit is contained in:
marioalexis
2024-10-08 15:26:28 -03:00
committed by Chris Hennes
parent 736f03caf2
commit 40531158f2
7 changed files with 200 additions and 138 deletions

View File

@@ -35,15 +35,19 @@ static const char* ConstraintTypes[] = {"DFlux", "Convection", "Radiation", null
ConstraintHeatflux::ConstraintHeatflux()
{
ADD_PROPERTY(AmbientTemp, (0.0));
ADD_PROPERTY_TYPE(AmbientTemp,
(0.0),
"ConstraintHeatflux",
App::Prop_None,
"Ambient temperature");
/*ADD_PROPERTY(FaceTemp,(0.0));*/
ADD_PROPERTY(FilmCoef, (0.0));
ADD_PROPERTY(Emissivity, (0.0));
ADD_PROPERTY(DFlux, (0.0));
ADD_PROPERTY_TYPE(FilmCoef, (0.0), "ConstraintHeatflux", App::Prop_None, "Film coefficient");
ADD_PROPERTY_TYPE(Emissivity, (0.0), "ConstraintHeatflux", App::Prop_None, "Emissivity");
ADD_PROPERTY_TYPE(DFlux, (0.0), "ConstraintHeatflux", App::Prop_None, "Distributed heat flux");
ADD_PROPERTY_TYPE(ConstraintType,
(1),
"ConstraintHeatflux",
(App::PropertyType)(App::Prop_None),
App::Prop_None,
"Type of constraint, surface convection, radiation or surface heat flux");
ConstraintType.setEnums(ConstraintTypes);
}
@@ -58,6 +62,30 @@ const char* ConstraintHeatflux::getViewProviderName() const
return "FemGui::ViewProviderFemConstraintHeatflux";
}
void ConstraintHeatflux::handleChangedPropertyType(Base::XMLReader& reader,
const char* typeName,
App::Property* prop)
{
if (prop == &FilmCoef && strcmp(typeName, "App::PropertyFloat") == 0) {
App::PropertyFloat filmCoefProperty;
filmCoefProperty.Restore(reader);
FilmCoef.setValue(filmCoefProperty.getValue());
}
else if (prop == &DFlux && strcmp(typeName, "App::PropertyFloat") == 0) {
App::PropertyFloat dFluxProperty;
dFluxProperty.Restore(reader);
DFlux.setValue(dFluxProperty.getValue());
}
else if (prop == &AmbientTemp && strcmp(typeName, "App::PropertyFloat") == 0) {
App::PropertyFloat tempProperty;
tempProperty.Restore(reader);
AmbientTemp.setValue(tempProperty.getValue());
}
else {
Constraint::handleChangedPropertyType(reader, typeName, prop);
}
}
void ConstraintHeatflux::onChanged(const App::Property* prop)
{
Constraint::onChanged(prop);

View File

@@ -39,11 +39,11 @@ class FemExport ConstraintHeatflux: public Fem::Constraint
public:
ConstraintHeatflux();
App::PropertyFloat AmbientTemp;
App::PropertyTemperature AmbientTemp;
/*App::PropertyFloat FaceTemp;*/
App::PropertyFloat FilmCoef;
App::PropertyThermalTransferCoefficient FilmCoef;
App::PropertyFloat Emissivity;
App::PropertyFloat DFlux;
App::PropertyHeatFlux DFlux;
App::PropertyEnumeration ConstraintType;
/// recalculate the object
@@ -53,6 +53,9 @@ public:
const char* getViewProviderName() const override;
protected:
void handleChangedPropertyType(Base::XMLReader& reader,
const char* typeName,
App::Property* prop) override;
void onChanged(const App::Property* prop) override;
};

View File

@@ -66,24 +66,24 @@ TaskFemConstraintHeatflux::TaskFemConstraintHeatflux(
connect(ui->rb_radiation, &QRadioButton::clicked, this, &TaskFemConstraintHeatflux::Rad);
connect(ui->rb_dflux, &QRadioButton::clicked, this, &TaskFemConstraintHeatflux::Flux);
connect(ui->if_heatflux,
qOverload<double>(&InputField::valueChanged),
connect(ui->qsb_heat_flux,
qOverload<double>(&QuantitySpinBox::valueChanged),
this,
&TaskFemConstraintHeatflux::onHeatFluxChanged);
connect(ui->if_ambienttemp_conv,
qOverload<double>(&InputField::valueChanged),
connect(ui->qsb_ambienttemp_conv,
qOverload<double>(&QuantitySpinBox::valueChanged),
this,
&TaskFemConstraintHeatflux::onAmbientTempChanged);
connect(ui->if_filmcoef,
qOverload<double>(&InputField::valueChanged),
connect(ui->qsb_film_coef,
qOverload<double>(&QuantitySpinBox::valueChanged),
this,
&TaskFemConstraintHeatflux::onFilmCoefChanged);
connect(ui->if_emissivity,
qOverload<double>(&InputField::valueChanged),
connect(ui->dsb_emissivity,
qOverload<double>(&DoubleSpinBox::valueChanged),
this,
&TaskFemConstraintHeatflux::onEmissivityChanged);
connect(ui->if_ambienttemp_rad,
qOverload<double>(&InputField::valueChanged),
connect(ui->qsb_ambienttemp_rad,
qOverload<double>(&QuantitySpinBox::valueChanged),
this,
&TaskFemConstraintHeatflux::onAmbientTempChanged);
connect(ui->lw_references,
@@ -94,11 +94,12 @@ TaskFemConstraintHeatflux::TaskFemConstraintHeatflux(
this->groupLayout()->addWidget(proxy);
// Temporarily prevent unnecessary feature recomputes
ui->if_ambienttemp_conv->blockSignals(true);
ui->qsb_ambienttemp_conv->blockSignals(true);
// ui->if_facetemp->blockSignals(true);
ui->if_filmcoef->blockSignals(true);
ui->if_emissivity->blockSignals(true);
ui->if_ambienttemp_rad->blockSignals(true);
ui->qsb_film_coef->blockSignals(true);
ui->dsb_emissivity->blockSignals(true);
ui->qsb_ambienttemp_rad->blockSignals(true);
ui->qsb_heat_flux->blockSignals(true);
ui->lw_references->blockSignals(true);
ui->btnAdd->blockSignals(true);
ui->btnRemove->blockSignals(true);
@@ -110,43 +111,39 @@ TaskFemConstraintHeatflux::TaskFemConstraintHeatflux(
std::vector<std::string> SubElements = pcConstraint->References.getSubValues();
// Fill data into dialog elements
ui->if_ambienttemp_conv->setMinimum(0);
ui->if_ambienttemp_conv->setMaximum(FLOAT_MAX);
ui->qsb_ambienttemp_conv->setMinimum(0);
ui->qsb_ambienttemp_conv->setMaximum(FLOAT_MAX);
ui->if_filmcoef->setMinimum(0);
ui->if_filmcoef->setMaximum(FLOAT_MAX);
ui->qsb_film_coef->setMinimum(0);
ui->qsb_film_coef->setMaximum(FLOAT_MAX);
ui->if_emissivity->setMinimum(0);
ui->if_emissivity->setMaximum(FLOAT_MAX);
ui->dsb_emissivity->setMinimum(0);
ui->dsb_emissivity->setMaximum(FLOAT_MAX);
ui->if_ambienttemp_rad->setMinimum(0);
ui->if_ambienttemp_rad->setMaximum(FLOAT_MAX);
ui->qsb_ambienttemp_rad->setMinimum(0);
ui->qsb_ambienttemp_rad->setMaximum(FLOAT_MAX);
ui->qsb_ambienttemp_conv->setValue(pcConstraint->AmbientTemp.getQuantityValue());
ui->qsb_film_coef->setValue(pcConstraint->FilmCoef.getQuantityValue());
ui->qsb_ambienttemp_rad->setValue(pcConstraint->AmbientTemp.getQuantityValue());
ui->dsb_emissivity->setValue(pcConstraint->Emissivity.getValue());
ui->qsb_heat_flux->setValue(pcConstraint->DFlux.getQuantityValue());
std::string constraint_type = pcConstraint->ConstraintType.getValueAsString();
if (constraint_type == "Convection") {
ui->rb_convection->setChecked(true);
ui->sw_heatflux->setCurrentIndex(0);
Base::Quantity t =
Base::Quantity(pcConstraint->AmbientTemp.getValue(), Base::Unit::Temperature);
ui->if_ambienttemp_conv->setValue(t);
Base::Quantity f = Base::Quantity(pcConstraint->FilmCoef.getValue(),
Base::Unit::ThermalTransferCoefficient);
ui->if_filmcoef->setValue(f);
}
else if (constraint_type == "Radiation") {
ui->rb_radiation->setChecked(true);
ui->sw_heatflux->setCurrentIndex(1);
Base::Quantity t =
Base::Quantity(pcConstraint->AmbientTemp.getValue(), Base::Unit::Temperature);
ui->if_ambienttemp_rad->setValue(t);
Base::Quantity e = Base::Quantity(pcConstraint->Emissivity.getValue(), Base::Unit());
ui->if_emissivity->setValue(e);
}
else if (constraint_type == "DFlux") {
ui->rb_dflux->setChecked(true);
ui->sw_heatflux->setCurrentIndex(2);
Base::Quantity c = Base::Quantity(pcConstraint->DFlux.getValue(), Base::Unit::HeatFlux);
ui->if_heatflux->setValue(c);
}
ui->lw_references->clear();
@@ -158,18 +155,25 @@ TaskFemConstraintHeatflux::TaskFemConstraintHeatflux(
}
// Selection buttons
buttonGroup->addButton(ui->btnAdd, (int)SelectionChangeModes::refAdd);
buttonGroup->addButton(ui->btnRemove, (int)SelectionChangeModes::refRemove);
buttonGroup->addButton(ui->btnAdd, static_cast<int>(SelectionChangeModes::refAdd));
buttonGroup->addButton(ui->btnRemove, static_cast<int>(SelectionChangeModes::refRemove));
ui->if_ambienttemp_conv->blockSignals(false);
ui->qsb_ambienttemp_conv->blockSignals(false);
// ui->if_facetemp->blockSignals(false);
ui->if_filmcoef->blockSignals(false);
ui->if_emissivity->blockSignals(false);
ui->if_ambienttemp_rad->blockSignals(false);
ui->qsb_film_coef->blockSignals(false);
ui->dsb_emissivity->blockSignals(false);
ui->qsb_ambienttemp_rad->blockSignals(false);
ui->qsb_heat_flux->blockSignals(false);
ui->lw_references->blockSignals(false);
ui->btnAdd->blockSignals(false);
ui->btnRemove->blockSignals(false);
ui->qsb_film_coef->bind(pcConstraint->FilmCoef);
ui->qsb_ambienttemp_conv->bind(pcConstraint->AmbientTemp);
ui->qsb_ambienttemp_rad->bind(pcConstraint->AmbientTemp);
ui->dsb_emissivity->bind(pcConstraint->Emissivity);
ui->qsb_heat_flux->bind(pcConstraint->DFlux);
updateUI();
}
@@ -188,21 +192,21 @@ void TaskFemConstraintHeatflux::onAmbientTempChanged(double val)
{
Fem::ConstraintHeatflux* pcConstraint =
static_cast<Fem::ConstraintHeatflux*>(ConstraintView->getObject());
pcConstraint->AmbientTemp.setValue(val); //[K]
pcConstraint->AmbientTemp.setValue(val);
}
void TaskFemConstraintHeatflux::onFilmCoefChanged(double val)
{
Fem::ConstraintHeatflux* pcConstraint =
static_cast<Fem::ConstraintHeatflux*>(ConstraintView->getObject());
pcConstraint->FilmCoef.setValue(val); // [W]/[[m^2]/[K]]
pcConstraint->FilmCoef.setValue(val);
}
void TaskFemConstraintHeatflux::onEmissivityChanged(double val)
{
Fem::ConstraintHeatflux* pcConstraint =
static_cast<Fem::ConstraintHeatflux*>(ConstraintView->getObject());
pcConstraint->Emissivity.setValue(val); // [-]
pcConstraint->Emissivity.setValue(val);
}
void TaskFemConstraintHeatflux::onHeatFluxChanged(double val)
@@ -221,12 +225,8 @@ void TaskFemConstraintHeatflux::Conv()
"App.ActiveDocument.%s.ConstraintType = %s",
name.c_str(),
get_constraint_type().c_str());
Base::Quantity t = Base::Quantity(300, Base::Unit::Temperature);
ui->if_ambienttemp_conv->setValue(t);
pcConstraint->AmbientTemp.setValue(300);
Base::Quantity f = Base::Quantity(10, Base::Unit::ThermalTransferCoefficient);
ui->if_filmcoef->setValue(f);
pcConstraint->FilmCoef.setValue(10);
ui->qsb_ambienttemp_conv->setValue(pcConstraint->AmbientTemp.getQuantityValue());
ui->qsb_film_coef->setValue(pcConstraint->FilmCoef.getQuantityValue());
ui->sw_heatflux->setCurrentIndex(0);
}
@@ -239,12 +239,8 @@ void TaskFemConstraintHeatflux::Rad()
"App.ActiveDocument.%s.ConstraintType = %s",
name.c_str(),
get_constraint_type().c_str());
Base::Quantity t = Base::Quantity(300, Base::Unit::Temperature);
ui->if_ambienttemp_rad->setValue(t);
pcConstraint->AmbientTemp.setValue(300);
Base::Quantity e = Base::Quantity(1, Base::Unit());
ui->if_emissivity->setValue(e);
pcConstraint->Emissivity.setValue(1);
ui->qsb_ambienttemp_rad->setValue(pcConstraint->AmbientTemp.getQuantityValue());
ui->dsb_emissivity->setValue(pcConstraint->Emissivity.getValue());
ui->sw_heatflux->setCurrentIndex(1);
}
@@ -257,9 +253,7 @@ void TaskFemConstraintHeatflux::Flux()
"App.ActiveDocument.%s.ConstraintType = %s",
name.c_str(),
get_constraint_type().c_str());
Base::Quantity c = Base::Quantity(0, Base::Unit::HeatFlux);
ui->if_heatflux->setValue(c);
pcConstraint->DFlux.setValue(0);
ui->qsb_heat_flux->setValue(pcConstraint->DFlux.getQuantityValue());
ui->sw_heatflux->setCurrentIndex(2);
}
@@ -415,32 +409,36 @@ const std::string TaskFemConstraintHeatflux::getReferences() const
return TaskFemConstraint::getReferences(items);
}
double TaskFemConstraintHeatflux::getAmbientTemp() const
std::string TaskFemConstraintHeatflux::getAmbientTemp() const
{
Base::Quantity temperature;
std::string temp;
if (ui->rb_convection->isChecked()) {
temperature = ui->if_ambienttemp_conv->getQuantity();
temp = ui->qsb_ambienttemp_conv->value().getSafeUserString().toStdString();
}
else if (ui->rb_radiation->isChecked()) {
temperature = ui->if_ambienttemp_rad->getQuantity();
temp = ui->qsb_ambienttemp_rad->value().getSafeUserString().toStdString();
}
double temperature_in_kelvin = temperature.getValueAs(Base::Quantity::Kelvin);
return temperature_in_kelvin;
else {
auto obj = static_cast<Fem::ConstraintHeatflux*>(ConstraintView->getObject());
temp = obj->AmbientTemp.getQuantityValue().getSafeUserString().toStdString();
}
return temp;
}
double TaskFemConstraintHeatflux::getFilmCoef() const
std::string TaskFemConstraintHeatflux::getFilmCoef() const
{
Base::Quantity filmcoef = ui->if_filmcoef->getQuantity();
double filmcoef_in_units =
filmcoef.getValueAs(Base::Quantity(1.0, Base::Unit::ThermalTransferCoefficient));
return filmcoef_in_units;
return ui->qsb_film_coef->value().getSafeUserString().toStdString();
}
std::string TaskFemConstraintHeatflux::getDFlux() const
{
return ui->qsb_heat_flux->value().getSafeUserString().toStdString();
}
double TaskFemConstraintHeatflux::getEmissivity() const
{
Base::Quantity emissivity = ui->if_emissivity->getQuantity();
double emissivity_in_units = emissivity.getValueAs(Base::Quantity(1.0, Base::Unit()));
return emissivity_in_units;
return ui->dsb_emissivity->value();
}
std::string TaskFemConstraintHeatflux::get_constraint_type() const
@@ -462,15 +460,19 @@ void TaskFemConstraintHeatflux::changeEvent(QEvent* e)
{
TaskBox::changeEvent(e);
if (e->type() == QEvent::LanguageChange) {
ui->if_ambienttemp_conv->blockSignals(true);
ui->if_filmcoef->blockSignals(true);
ui->if_emissivity->blockSignals(true);
ui->if_ambienttemp_rad->blockSignals(true);
ui->qsb_ambienttemp_conv->blockSignals(true);
ui->qsb_film_coef->blockSignals(true);
ui->dsb_emissivity->blockSignals(true);
ui->qsb_ambienttemp_rad->blockSignals(true);
ui->qsb_heat_flux->blockSignals(true);
ui->retranslateUi(proxy);
ui->if_ambienttemp_conv->blockSignals(false);
ui->if_filmcoef->blockSignals(false);
ui->if_emissivity->blockSignals(true);
ui->if_ambienttemp_rad->blockSignals(false);
ui->qsb_ambienttemp_conv->blockSignals(false);
ui->qsb_film_coef->blockSignals(false);
ui->dsb_emissivity->blockSignals(false);
ui->qsb_ambienttemp_rad->blockSignals(false);
ui->qsb_heat_flux->blockSignals(false);
}
}
@@ -505,21 +507,24 @@ bool TaskDlgFemConstraintHeatflux::accept()
std::string name = ConstraintView->getObject()->getNameInDocument();
const TaskFemConstraintHeatflux* parameterHeatflux =
static_cast<const TaskFemConstraintHeatflux*>(parameter);
std::string scale = "1";
try {
Gui::Command::doCommand(Gui::Command::Doc,
"App.ActiveDocument.%s.AmbientTemp = %f",
"App.ActiveDocument.%s.AmbientTemp = \"%s\"",
name.c_str(),
parameterHeatflux->getAmbientTemp());
parameterHeatflux->getAmbientTemp().c_str());
Gui::Command::doCommand(Gui::Command::Doc,
"App.ActiveDocument.%s.FilmCoef = %f",
"App.ActiveDocument.%s.FilmCoef = \"%s\"",
name.c_str(),
parameterHeatflux->getFilmCoef());
parameterHeatflux->getFilmCoef().c_str());
Gui::Command::doCommand(Gui::Command::Doc,
"App.ActiveDocument.%s.Emissivity = %f",
name.c_str(),
parameterHeatflux->getEmissivity());
Gui::Command::doCommand(Gui::Command::Doc,
"App.ActiveDocument.%s.DFlux = \"%s\"",
name.c_str(),
parameterHeatflux->getDFlux().c_str());
}
catch (const Base::Exception& e) {
QMessageBox::warning(parameter, tr("Input error"), QString::fromLatin1(e.what()));

View File

@@ -45,9 +45,10 @@ public:
explicit TaskFemConstraintHeatflux(ViewProviderFemConstraintHeatflux* ConstraintView,
QWidget* parent = nullptr);
~TaskFemConstraintHeatflux() override;
double getAmbientTemp() const;
std::string getAmbientTemp() const;
/*double getFaceTemp(void) const;*/
double getFilmCoef() const;
std::string getFilmCoef() const;
std::string getDFlux() const;
double getEmissivity() const;
std::string get_constraint_type() const;
const std::string getReferences() const override;

View File

@@ -99,21 +99,24 @@
<item>
<widget class="QLabel" name="lbl_filmcoef">
<property name="text">
<string>Film coefficient</string>
<string>Film Coefficient</string>
</property>
</widget>
</item>
<item>
<widget class="Gui::InputField" name="if_filmcoef">
<property name="text">
<string>1 W/m^2/K</string>
</property>
<widget class="Gui::QuantitySpinBox" name="qsb_film_coef">
<property name="unit" stdset="0">
<string notr="true">W/m^2/K</string>
<string>W/m^2/K</string>
</property>
<property name="quantity" stdset="0">
<property name="alignment">
<set>Qt::AlignLeft|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
<property name="singleStep">
<double>1.000000000000000</double>
</property>
<property name="value" stdset="0">
<double>0.000000000000000</double>
</property>
</widget>
</item>
</layout>
@@ -128,15 +131,18 @@
</widget>
</item>
<item>
<widget class="Gui::InputField" name="if_ambienttemp_conv">
<property name="text">
<string>300 K</string>
</property>
<widget class="Gui::QuantitySpinBox" name="qsb_ambienttemp_conv">
<property name="unit" stdset="0">
<string notr="true">K</string>
<string>K</string>
</property>
<property name="quantity" stdset="0">
<double>300.000000000000000</double>
<property name="alignment">
<set>Qt::AlignLeft|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
<property name="singleStep">
<double>1.000000000000000</double>
</property>
<property name="value" stdset="0">
<double>300.0000000000000</double>
</property>
</widget>
</item>
@@ -163,11 +169,14 @@
</widget>
</item>
<item>
<widget class="Gui::InputField" name="if_emissivity">
<property name="text">
<string>1 </string>
<widget class="Gui::DoubleSpinBox" name="dsb_emissivity">
<property name="alignment">
<set>Qt::AlignLeft|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
<property name="quantity" stdset="0">
<property name="singleStep">
<double>0.100000000000000</double>
</property>
<property name="value" stdset="0">
<double>1.000000000000000</double>
</property>
</widget>
@@ -184,15 +193,18 @@
</widget>
</item>
<item>
<widget class="Gui::InputField" name="if_ambienttemp_rad">
<property name="text">
<string>300 K</string>
</property>
<widget class="Gui::QuantitySpinBox" name="qsb_ambienttemp_rad">
<property name="unit" stdset="0">
<string notr="true">K</string>
<string>K</string>
</property>
<property name="quantity" stdset="0">
<double>300.000000000000000</double>
<property name="alignment">
<set>Qt::AlignLeft|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
<property name="singleStep">
<double>1.000000000000000</double>
</property>
<property name="value" stdset="0">
<double>300.0000000000000</double>
</property>
</widget>
</item>
@@ -210,23 +222,26 @@
<item>
<layout class="QHBoxLayout" name="horizontalLayout_2">
<item>
<widget class="QLabel" name="label">
<widget class="QLabel" name="lbl_heat_flux">
<property name="text">
<string>Surface heat flux</string>
<string>Surface Heat Flux</string>
</property>
</widget>
</item>
<item>
<widget class="Gui::InputField" name="if_heatflux">
<property name="text">
<string>1 W/m^2</string>
</property>
<widget class="Gui::QuantitySpinBox" name="qsb_heat_flux">
<property name="unit" stdset="0">
<string notr="true">W/m^2/K</string>
</property>
<property name="quantity" stdset="0">
<double>1.000000000000000</double>
<string>W/m^2</string>
</property>
<property name="alignment">
<set>Qt::AlignLeft|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
<property name="singleStep">
<double>1.000000000000000</double>
</property>
<property name="value" stdset="0">
<double>0.000000000000000</double>
</property>
</widget>
</item>
</layout>
@@ -243,6 +258,16 @@
<extends>QLineEdit</extends>
<header>Gui/InputField.h</header>
</customwidget>
<customwidget>
<class>Gui::QuantitySpinBox</class>
<extends>QWidget</extends>
<header>Gui/QuantitySpinBox.h</header>
</customwidget>
<customwidget>
<class>Gui::DoubleSpinBox</class>
<extends>QWidget</extends>
<header>Gui/SpinBox.h</header>
</customwidget>
</customwidgets>
<resources/>
<connections/>

View File

@@ -49,22 +49,22 @@ def write_meshdata_constraint(f, femobj, heatflux_obj, ccxwriter):
if heatflux_obj.ConstraintType == "Convection":
heatflux_key_word = "FILM"
heatflux_facetype = "F"
# SvdW: add factor to force heatflux to units system of t/mm/s/K
heatflux_values = "{:.13G},{:.13G}".format(
heatflux_obj.AmbientTemp, heatflux_obj.FilmCoef * 0.001
heatflux_obj.AmbientTemp.getValueAs("K").Value,
heatflux_obj.FilmCoef.getValueAs("t/s^3/K").Value,
)
elif heatflux_obj.ConstraintType == "Radiation":
heatflux_key_word = "RADIATE"
heatflux_facetype = "R"
heatflux_values = "{:.13G},{:.13G}".format(
heatflux_obj.AmbientTemp, heatflux_obj.Emissivity
heatflux_obj.AmbientTemp.getValueAs("K").Value, heatflux_obj.Emissivity
)
elif heatflux_obj.ConstraintType == "DFlux":
heatflux_key_word = "DFLUX"
heatflux_facetype = "S"
heatflux_values = f"{heatflux_obj.DFlux * 0.001:.13G}"
heatflux_values = "{:.13G}".format(heatflux_obj.DFlux.getValueAs("t/s^3").Value)
f.write(f"*{heatflux_key_word}\n")
for ref_shape in femobj["HeatFluxFaceTable"]:

View File

@@ -117,12 +117,12 @@ class Heatwriter:
if obj.References:
for name in obj.References[0][1]:
if obj.ConstraintType == "Convection":
film = self.write.getFromUi(obj.FilmCoef, "W/(m^2*K)", "M/(T^3*O)")
temp = self.write.getFromUi(obj.AmbientTemp, "K", "O")
film = obj.FilmCoef.getValueAs("W/(m^2*K)").Value
temp = obj.AmbientTemp.getValueAs("K").Value
self.write.boundary(name, "Heat Transfer Coefficient", film)
self.write.boundary(name, "External Temperature", temp)
elif obj.ConstraintType == "DFlux":
flux = self.write.getFromUi(obj.DFlux, "W/m^2", "M*T^-3")
flux = obj.DFlux.getValueAs("W/m^2").Value
self.write.boundary(name, "Heat Flux BC", True)
self.write.boundary(name, "Heat Flux", flux)
self.write.handled(obj)