File size: 22,157 Bytes
985c397 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 | # ***************************************************************************
# * Copyright (c) 2016 Ofentse Kgoa <kgoaot@eskom.co.za> *
# * Copyright (c) 2018 Bernd Hahnebach <bernd@bimstatik.org> *
# * Based on the FemElementGeometry1D by Bernd Hahnebach *
# * *
# * This file is part of the FreeCAD CAx development system. *
# * *
# * This program is free software; you can redistribute it and/or modify *
# * it under the terms of the GNU Lesser General Public License (LGPL) *
# * as published by the Free Software Foundation; either version 2 of *
# * the License, or (at your option) any later version. *
# * for detail see the LICENCE text file. *
# * *
# * This program is distributed in the hope that it will be useful, *
# * but WITHOUT ANY WARRANTY; without even the implied warranty of *
# * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
# * GNU Library General Public License for more details. *
# * *
# * You should have received a copy of the GNU Library General Public *
# * License along with this program; if not, write to the Free Software *
# * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 *
# * USA *
# * *
# ***************************************************************************
__title__ = "FreeCAD FEM element fluid 1D task panel for the document object"
__author__ = "Ofentse Kgoa, Bernd Hahnebach"
__url__ = "https://www.freecad.org"
## @package task_element_fluid1D
# \ingroup FEM
# \brief task panel for element fluid 1D object
from PySide import QtCore
from PySide import QtGui
import FreeCAD
import FreeCADGui
from FreeCAD import Units
from femguiutils import selection_widgets
from femobjects import element_fluid1D
from . import base_femtaskpanel
class _TaskPanel(base_femtaskpanel._BaseTaskPanel):
"""
The TaskPanel for editing References property of ElementFluid1D objects
"""
def __init__(self, obj):
super().__init__(obj)
# parameter widget
self.parameterWidget = FreeCADGui.PySideUic.loadUi(
FreeCAD.getHomePath() + "Mod/Fem/Resources/ui/ElementFluid1D.ui"
)
QtCore.QObject.connect(
self.parameterWidget.cb_section_type,
QtCore.SIGNAL("activated(int)"),
self.sectiontype_changed,
)
QtCore.QObject.connect(
self.parameterWidget.cb_liquid_section_type,
QtCore.SIGNAL("activated(int)"),
self.liquidsectiontype_changed,
)
QtCore.QObject.connect(
self.parameterWidget.if_manning_area,
QtCore.SIGNAL("valueChanged(Base::Quantity)"),
self.manning_area_changed,
)
QtCore.QObject.connect(
self.parameterWidget.if_manning_radius,
QtCore.SIGNAL("valueChanged(Base::Quantity)"),
self.manning_radius_changed,
)
QtCore.QObject.connect(
self.parameterWidget.sb_manning_coefficient,
QtCore.SIGNAL("valueChanged(double)"),
self.manning_coefficient_changed,
)
QtCore.QObject.connect(
self.parameterWidget.if_enlarge_area1,
QtCore.SIGNAL("valueChanged(Base::Quantity)"),
self.enlarge_area1_changed,
)
QtCore.QObject.connect(
self.parameterWidget.if_enlarge_area2,
QtCore.SIGNAL("valueChanged(Base::Quantity)"),
self.enlarge_area2_changed,
)
QtCore.QObject.connect(
self.parameterWidget.if_contract_area1,
QtCore.SIGNAL("valueChanged(Base::Quantity)"),
self.contract_area1_changed,
)
QtCore.QObject.connect(
self.parameterWidget.if_contract_area2,
QtCore.SIGNAL("valueChanged(Base::Quantity)"),
self.contract_area2_changed,
)
QtCore.QObject.connect(
self.parameterWidget.if_inletpressure,
QtCore.SIGNAL("valueChanged(Base::Quantity)"),
self.inlet_pressure_changed,
)
QtCore.QObject.connect(
self.parameterWidget.if_outletpressure,
QtCore.SIGNAL("valueChanged(Base::Quantity)"),
self.outlet_pressure_changed,
)
QtCore.QObject.connect(
self.parameterWidget.if_inletflowrate,
QtCore.SIGNAL("valueChanged(Base::Quantity)"),
self.inlet_flowrate_changed,
)
QtCore.QObject.connect(
self.parameterWidget.if_outletflowrate,
QtCore.SIGNAL("valueChanged(Base::Quantity)"),
self.outlet_flowrate_changed,
)
QtCore.QObject.connect(
self.parameterWidget.gb_inletpressure,
QtCore.SIGNAL("clicked(bool)"),
self.inlet_pressure_active,
)
QtCore.QObject.connect(
self.parameterWidget.gb_outletpressure,
QtCore.SIGNAL("clicked(bool)"),
self.outlet_pressure_active,
)
QtCore.QObject.connect(
self.parameterWidget.gb_inletflowrate,
QtCore.SIGNAL("clicked(bool)"),
self.inlet_flowrate_active,
)
QtCore.QObject.connect(
self.parameterWidget.gb_outletflowrate,
QtCore.SIGNAL("clicked(bool)"),
self.outlet_flowrate_active,
)
QtCore.QObject.connect(
self.parameterWidget.if_entrance_pipe_area,
QtCore.SIGNAL("valueChanged(Base::Quantity)"),
self.entrance_pipe_area_changed,
)
QtCore.QObject.connect(
self.parameterWidget.if_entrance_area,
QtCore.SIGNAL("valueChanged(Base::Quantity)"),
self.entrance_area_changed,
)
QtCore.QObject.connect(
self.parameterWidget.if_diaphragm_pipe_area,
QtCore.SIGNAL("valueChanged(Base::Quantity)"),
self.diaphragm_pipe_area_changed,
)
QtCore.QObject.connect(
self.parameterWidget.if_diaphragm_area,
QtCore.SIGNAL("valueChanged(Base::Quantity)"),
self.diaphragm_area_changed,
)
QtCore.QObject.connect(
self.parameterWidget.if_bend_pipe_area,
QtCore.SIGNAL("valueChanged(Base::Quantity)"),
self.bend_pipe_area_changed,
)
QtCore.QObject.connect(
self.parameterWidget.sb_bradius_pdiameter,
QtCore.SIGNAL("valueChanged(double)"),
self.bradius_pdiameter_changed,
)
QtCore.QObject.connect(
self.parameterWidget.sb_bend_angle,
QtCore.SIGNAL("valueChanged(double)"),
self.bend_angle_changed,
)
QtCore.QObject.connect(
self.parameterWidget.sb_bend_loss_coefficient,
QtCore.SIGNAL("valueChanged(double)"),
self.bend_loss_coefficient_changed,
)
QtCore.QObject.connect(
self.parameterWidget.if_gatevalve_pipe_area,
QtCore.SIGNAL("valueChanged(Base::Quantity)"),
self.gatevalve_pipe_area_changed,
)
QtCore.QObject.connect(
self.parameterWidget.sb_gatevalve_closing_coeff,
QtCore.SIGNAL("valueChanged(double)"),
self.gatevalve_closing_coeff_changed,
)
QtCore.QObject.connect(
self.parameterWidget.if_colebrooke_pipe_area,
QtCore.SIGNAL("valueChanged(Base::Quantity)"),
self.colebrooke_pipe_area_changed,
)
QtCore.QObject.connect(
self.parameterWidget.if_colebrooke_radius,
QtCore.SIGNAL("valueChanged(Base::Quantity)"),
self.colebrooke_radius_changed,
)
QtCore.QObject.connect(
self.parameterWidget.if_colebrooke_grain_diameter,
QtCore.SIGNAL("valueChanged(Base::Quantity)"),
self.colebrooke_grain_diameter_changed,
)
QtCore.QObject.connect(
self.parameterWidget.sb_colebrooke_form_factor,
QtCore.SIGNAL("valueChanged(double)"),
self.colebrooke_form_factor_changed,
)
QtCore.QObject.connect(
self.parameterWidget.tw_pump_characteristics,
QtCore.SIGNAL("cellChanged(int, int)"),
self.pump_characteristics_changed,
)
# some fluid types deactivated since they are not implemented in ccx writer
self.parameterWidget.cb_section_type.addItems(
element_fluid1D.ElementFluid1D.known_fluid_types
)
self.parameterWidget.cb_liquid_section_type.addItems(
element_fluid1D.ElementFluid1D.known_liquid_types
)
self.parameterWidget.cb_gas_section_type.addItems(
element_fluid1D.ElementFluid1D.known_gas_types
)
self.parameterWidget.cb_channel_section_type.addItems(
element_fluid1D.ElementFluid1D.known_channel_types
)
self.get_fluidsection_props()
self.updateParameterWidget()
# geometry selection widget
self.selectionWidget = selection_widgets.GeometryElementsSelection(
obj.References, ["Edge"], False, True
)
# form made from param and selection widget
self.form = [self.parameterWidget, self.selectionWidget]
def accept(self):
self.set_fluidsection_props()
self.obj.References = self.selectionWidget.references
self.selectionWidget.finish_selection()
return super().accept()
def reject(self):
self.selectionWidget.finish_selection()
return super().reject()
def get_fluidsection_props(self):
self.SectionType = self.obj.SectionType
self.LiquidSectionType = self.obj.LiquidSectionType
self.ManningArea = self.obj.ManningArea
self.ManningRadius = self.obj.ManningRadius
self.ManningCoefficient = self.obj.ManningCoefficient
self.EnlargeArea1 = self.obj.EnlargeArea1
self.EnlargeArea2 = self.obj.EnlargeArea2
self.ContractArea1 = self.obj.ContractArea1
self.ContractArea2 = self.obj.ContractArea2
self.OutletPressure = self.obj.OutletPressure
self.InletPressure = self.obj.InletPressure
self.OutletFlowRate = self.obj.OutletFlowRate
self.InletFlowRate = self.obj.InletFlowRate
self.OutletPressureActive = self.obj.OutletPressureActive
self.InletPressureActive = self.obj.InletPressureActive
self.OutletFlowRateActive = self.obj.OutletFlowRateActive
self.InletFlowRateActive = self.obj.InletFlowRateActive
self.EntrancePipeArea = self.obj.EntrancePipeArea
self.EntranceArea = self.obj.EntranceArea
self.DiaphragmPipeArea = self.obj.DiaphragmPipeArea
self.DiaphragmArea = self.obj.DiaphragmArea
self.BendPipeArea = self.obj.BendPipeArea
self.BendRadiusDiameter = self.obj.BendRadiusDiameter
self.BendAngle = self.obj.BendAngle
self.BendLossCoefficient = self.obj.BendLossCoefficient
self.GateValvePipeArea = self.obj.GateValvePipeArea
self.GateValveClosingCoeff = self.obj.GateValveClosingCoeff
self.ColebrookeArea = self.obj.ColebrookeArea
self.ColebrookeRadius = self.obj.ColebrookeRadius
self.ColebrookeGrainDiameter = self.obj.ColebrookeGrainDiameter
self.ColebrookeFormFactor = self.obj.ColebrookeFormFactor
self.PumpFlowRate = self.obj.PumpFlowRate
self.PumpHeadLoss = self.obj.PumpHeadLoss
def set_fluidsection_props(self):
self.obj.LiquidSectionType = self.LiquidSectionType
self.obj.SectionType = self.SectionType
self.obj.ManningArea = self.ManningArea
self.obj.ManningRadius = self.ManningRadius
self.obj.ManningCoefficient = self.ManningCoefficient
self.obj.EnlargeArea1 = self.EnlargeArea1
self.obj.EnlargeArea2 = self.EnlargeArea2
self.obj.ContractArea1 = self.ContractArea1
self.obj.ContractArea2 = self.ContractArea2
self.obj.OutletPressure = self.OutletPressure
self.obj.InletPressure = self.InletPressure
self.obj.OutletFlowRate = self.OutletFlowRate
self.obj.InletFlowRate = self.InletFlowRate
self.obj.OutletPressureActive = self.OutletPressureActive
self.obj.InletPressureActive = self.InletPressureActive
self.obj.OutletFlowRateActive = self.OutletFlowRateActive
self.obj.InletFlowRateActive = self.InletFlowRateActive
self.obj.EntrancePipeArea = self.EntrancePipeArea
self.obj.EntranceArea = self.EntranceArea
self.obj.DiaphragmPipeArea = self.DiaphragmPipeArea
self.obj.DiaphragmArea = self.DiaphragmArea
self.obj.BendPipeArea = self.BendPipeArea
self.obj.BendRadiusDiameter = self.BendRadiusDiameter
self.obj.BendAngle = self.BendAngle
self.obj.BendLossCoefficient = self.BendLossCoefficient
self.obj.GateValvePipeArea = self.GateValvePipeArea
self.obj.GateValveClosingCoeff = self.GateValveClosingCoeff
self.obj.ColebrookeArea = self.ColebrookeArea
self.obj.ColebrookeRadius = self.ColebrookeRadius
self.obj.ColebrookeGrainDiameter = self.ColebrookeGrainDiameter
self.obj.ColebrookeFormFactor = self.ColebrookeFormFactor
self.obj.PumpFlowRate = self.PumpFlowRate
self.obj.PumpHeadLoss = self.PumpHeadLoss
def updateParameterWidget(self):
"fills the widgets"
index_sectiontype = self.parameterWidget.cb_section_type.findText(self.SectionType)
self.parameterWidget.cb_section_type.setCurrentIndex(index_sectiontype)
self.parameterWidget.sw_section_type.setCurrentIndex(index_sectiontype)
index_liquidsectiontype = self.parameterWidget.cb_liquid_section_type.findText(
self.LiquidSectionType
)
self.parameterWidget.cb_liquid_section_type.setCurrentIndex(index_liquidsectiontype)
self.parameterWidget.sw_liquid_section_type.setCurrentIndex(index_liquidsectiontype)
self.parameterWidget.if_manning_area.setText(self.ManningArea.UserString)
self.parameterWidget.if_manning_radius.setText(self.ManningRadius.UserString)
self.parameterWidget.sb_manning_coefficient.setValue(self.ManningCoefficient)
self.parameterWidget.if_enlarge_area1.setText(self.EnlargeArea1.UserString)
self.parameterWidget.if_enlarge_area2.setText(self.EnlargeArea2.UserString)
self.parameterWidget.if_contract_area1.setText(self.ContractArea1.UserString)
self.parameterWidget.if_contract_area2.setText(self.ContractArea2.UserString)
self.parameterWidget.if_inletpressure.setText(
FreeCAD.Units.Quantity(1000 * self.InletPressure, FreeCAD.Units.Pressure).UserString
)
self.parameterWidget.if_outletpressure.setText(
FreeCAD.Units.Quantity(1000 * self.OutletPressure, FreeCAD.Units.Pressure).UserString
)
self.parameterWidget.if_inletflowrate.setText(str(self.InletFlowRate))
self.parameterWidget.if_outletflowrate.setText(str(self.OutletFlowRate))
self.parameterWidget.gb_inletpressure.setChecked(self.InletPressureActive)
self.parameterWidget.gb_outletpressure.setChecked(self.OutletPressureActive)
self.parameterWidget.gb_inletflowrate.setChecked(self.InletFlowRateActive)
self.parameterWidget.gb_outletflowrate.setChecked(self.OutletFlowRateActive)
self.parameterWidget.if_entrance_pipe_area.setText(self.EntrancePipeArea.UserString)
self.parameterWidget.if_entrance_area.setText(self.EntranceArea.UserString)
self.parameterWidget.if_diaphragm_pipe_area.setText(self.DiaphragmPipeArea.UserString)
self.parameterWidget.if_diaphragm_area.setText(self.DiaphragmArea.UserString)
self.parameterWidget.if_bend_pipe_area.setText(self.BendPipeArea.UserString)
self.parameterWidget.sb_bradius_pdiameter.setValue(self.BendRadiusDiameter)
self.parameterWidget.sb_bend_angle.setValue(self.BendAngle)
self.parameterWidget.sb_bend_loss_coefficient.setValue(self.BendLossCoefficient)
self.parameterWidget.if_gatevalve_pipe_area.setText(self.GateValvePipeArea.UserString)
self.parameterWidget.sb_gatevalve_closing_coeff.setValue(self.GateValveClosingCoeff)
self.parameterWidget.if_colebrooke_pipe_area.setText(self.ColebrookeArea.UserString)
self.parameterWidget.if_colebrooke_radius.setText(self.ColebrookeRadius.UserString)
self.parameterWidget.if_colebrooke_grain_diameter.setText(
self.ColebrookeGrainDiameter.UserString
)
self.parameterWidget.sb_colebrooke_form_factor.setValue(self.ColebrookeFormFactor)
for i in range(len(self.PumpFlowRate)):
self.parameterWidget.tw_pump_characteristics.setItem(
i, 0, QtGui.QTableWidgetItem(str(self.PumpFlowRate[i]))
)
self.parameterWidget.tw_pump_characteristics.setItem(
i, 1, QtGui.QTableWidgetItem(str(self.PumpHeadLoss[i]))
)
def sectiontype_changed(self, index):
if index < 0:
return
self.parameterWidget.cb_section_type.setCurrentIndex(index)
self.parameterWidget.sw_section_type.setCurrentIndex(index)
# parameterWidget returns unicode
self.SectionType = str(self.parameterWidget.cb_section_type.itemText(index))
def liquidsectiontype_changed(self, index):
if index < 0:
return
self.parameterWidget.cb_liquid_section_type.setCurrentIndex(index)
self.parameterWidget.sw_liquid_section_type.setCurrentIndex(index)
# parameterWidget returns unicode
self.LiquidSectionType = str(self.parameterWidget.cb_liquid_section_type.itemText(index))
def manning_area_changed(self, base_quantity_value):
self.ManningArea = base_quantity_value
def manning_radius_changed(self, base_quantity_value):
self.ManningRadius = base_quantity_value
def manning_coefficient_changed(self, base_quantity_value):
self.ManningCoefficient = base_quantity_value
def enlarge_area1_changed(self, base_quantity_value):
self.EnlargeArea1 = base_quantity_value
def enlarge_area2_changed(self, base_quantity_value):
self.EnlargeArea2 = base_quantity_value
def contract_area1_changed(self, base_quantity_value):
self.ContractArea1 = base_quantity_value
def contract_area2_changed(self, base_quantity_value):
self.ContractArea2 = base_quantity_value
def inlet_pressure_changed(self, base_quantity_value):
self.InletPressure = Units.Quantity(base_quantity_value).getValueAs("MPa").Value
def outlet_pressure_changed(self, base_quantity_value):
self.OutletPressure = Units.Quantity(base_quantity_value).getValueAs("MPa").Value
def inlet_flowrate_changed(self, base_quantity_value):
self.InletFlowRate = Units.Quantity(base_quantity_value).getValueAs("kg/s").Value
def outlet_flowrate_changed(self, base_quantity_value):
self.OutletFlowRate = Units.Quantity(base_quantity_value).getValueAs("kg/s").Value
def inlet_pressure_active(self, active):
self.InletPressureActive = active
def outlet_pressure_active(self, active):
self.OutletPressureActive = active
def inlet_flowrate_active(self, active):
self.InletFlowRateActive = active
def outlet_flowrate_active(self, active):
self.OutletFlowRateActive = active
def entrance_pipe_area_changed(self, base_quantity_value):
self.EntrancePipeArea = base_quantity_value
def entrance_area_changed(self, base_quantity_value):
self.EntranceArea = base_quantity_value
def diaphragm_pipe_area_changed(self, base_quantity_value):
self.DiaphragmPipeArea = base_quantity_value
def diaphragm_area_changed(self, base_quantity_value):
self.DiaphragmArea = base_quantity_value
def bend_pipe_area_changed(self, base_quantity_value):
self.BendPipeArea = base_quantity_value
def bradius_pdiameter_changed(self, base_quantity_value):
self.BendRadiusDiameter = base_quantity_value
def bend_angle_changed(self, base_quantity_value):
self.BendAngle = base_quantity_value
def bend_loss_coefficient_changed(self, base_quantity_value):
self.BendLossCoefficient = base_quantity_value
def gatevalve_pipe_area_changed(self, base_quantity_value):
self.GateValvePipeArea = base_quantity_value
def gatevalve_closing_coeff_changed(self, base_quantity_value):
self.GateValveClosingCoeff = base_quantity_value
def colebrooke_pipe_area_changed(self, base_quantity_value):
self.ColebrookeArea = base_quantity_value
def colebrooke_radius_changed(self, base_quantity_value):
self.ColebrookeRadius = base_quantity_value
def colebrooke_grain_diameter_changed(self, base_quantity_value):
self.ColebrookeGrainDiameter = base_quantity_value
def colebrooke_form_factor_changed(self, base_quantity_value):
self.ColebrookeFormFactor = base_quantity_value
def pump_characteristics_changed(self, row, column):
if column == 0:
self.PumpFlowRate[row] = float(
self.parameterWidget.tw_pump_characteristics.item(row, column).text()
)
else:
self.PumpHeadLoss[row] = float(
self.parameterWidget.tw_pump_characteristics.item(row, column).text()
)
|