FEM: 1DFlow, object modules

This commit is contained in:
kgoao
2017-02-28 11:50:13 +01:00
committed by wmayer
parent 299d20c025
commit 52b869bf39
8 changed files with 1505 additions and 1 deletions

View File

@@ -89,6 +89,7 @@ SET(FemObjectsScripts_SRCS
PyObjects/__init__.py
PyObjects/_FemBeamSection.py
PyObjects/_FemConstraintSelfWeight.py
PyObjects/_FemFluidSection.py
PyObjects/_FemMaterialMechanicalNonlinear.py
PyObjects/_FemMeshGmsh.py
PyObjects/_FemMeshGroup.py
@@ -124,6 +125,7 @@ SET(FemGuiScripts_SRCS
PyGui/_CommandSolverCalculix.py
PyGui/_CommandSolverZ88.py
PyGui/_TaskPanelFemBeamSection.py
PyGui/_TaskPanelFemFluidSection.py
PyGui/_TaskPanelFemMeshGmsh.py
PyGui/_TaskPanelFemMeshGroup.py
PyGui/_TaskPanelFemMeshRegion.py
@@ -133,6 +135,7 @@ SET(FemGuiScripts_SRCS
PyGui/_TaskPanelShowResult.py
PyGui/_ViewProviderFemBeamSection.py
PyGui/_ViewProviderFemConstraintSelfWeight.py
PyGui/_ViewProviderFemFluidSection.py
PyGui/_ViewProviderFemMaterialMechanicalNonlinear.py
PyGui/_ViewProviderFemMeshGmsh.py
PyGui/_ViewProviderFemMeshGroup.py
@@ -143,6 +146,7 @@ SET(FemGuiScripts_SRCS
PyGui/_ViewProviderFemSolverZ88.py
PyGui/_ViewProviderFemMaterial.py
PyGui/TaskPanelFemBeamSection.ui
PyGui/TaskPanelFemFluidSection.ui
PyGui/TaskPanelFemMeshGmsh.ui
PyGui/TaskPanelFemMeshGroup.ui
PyGui/TaskPanelFemMeshRegion.ui

View File

@@ -47,6 +47,7 @@ INSTALL(
PyObjects/__init__.py
PyObjects/_FemBeamSection.py
PyObjects/_FemConstraintSelfWeight.py
PyObjects/_FemFluidSection.py
PyObjects/_FemMaterialMechanicalNonlinear.py
PyObjects/_FemMeshGmsh.py
PyObjects/_FemMeshGroup.py
@@ -85,6 +86,7 @@ INSTALL(
PyGui/_CommandSolverCalculix.py
PyGui/_CommandSolverZ88.py
PyGui/_TaskPanelFemBeamSection.py
PyGui/_TaskPanelFemFluidSection.py
PyGui/_TaskPanelFemMeshGmsh.py
PyGui/_TaskPanelFemMeshGroup.py
PyGui/_TaskPanelFemMeshRegion.py
@@ -94,6 +96,7 @@ INSTALL(
PyGui/_TaskPanelShowResult.py
PyGui/_ViewProviderFemBeamSection.py
PyGui/_ViewProviderFemConstraintSelfWeight.py
PyGui/_ViewProviderFemFluidSection.py
PyGui/_ViewProviderFemMaterialMechanicalNonlinear.py
PyGui/_ViewProviderFemMeshGmsh.py
PyGui/_ViewProviderFemMeshGroup.py
@@ -104,12 +107,13 @@ INSTALL(
PyGui/_ViewProviderFemSolverZ88.py
PyGui/_ViewProviderFemMaterial.py
PyGui/TaskPanelFemBeamSection.ui
PyGui/TaskPanelFemFluidSection.ui
PyGui/TaskPanelFemMaterial.ui
PyGui/TaskPanelFemMeshGmsh.ui
PyGui/TaskPanelFemMeshGroup.ui
PyGui/TaskPanelFemMeshRegion.ui
PyGui/TaskPanelFemShellThickness.ui
PyGui/TaskPanelFemSolverCalculix.ui
PyGui/TaskPanelFemMaterial.ui
PyGui/TaskPanelShowResult.ui
DESTINATION
Mod/Fem/PyGui

View File

@@ -83,6 +83,17 @@ def makeBeamSection(sectiontype='Rectangular', width=10.0, height=25.0, name="Be
return obj
def makeFemFluidSection(name="FluidSection"):
'''makeFemFluidSection([name]): creates an Fluid section object to define 1D flow'''
obj = FreeCAD.ActiveDocument.addObject("Fem::FeaturePython", name)
import PyObjects._FemFluidSection
PyObjects._FemFluidSection._FemFluidSection(obj)
if FreeCAD.GuiUp:
import PyGui._ViewProviderFemFluidSection
PyGui._ViewProviderFemFluidSection._ViewProviderFemFluidSection(obj.ViewObject)
return obj
def makeShellThickness(thickness=20.0, name="ShellThickness"):
'''makeShellThickness([thickness], [name]): creates an shellthickness object to define a plate thickness'''
obj = FreeCAD.ActiveDocument.addObject("Fem::FeaturePython", name)

View File

@@ -0,0 +1,890 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>Form</class>
<widget class="QWidget" name="Form">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>590</width>
<height>653</height>
</rect>
</property>
<property name="windowTitle">
<string>Form</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout_11">
<item>
<widget class="QGroupBox" name="groupBox_3">
<property name="maximumSize">
<size>
<width>16777215</width>
<height>1677215</height>
</size>
</property>
<property name="title">
<string>Fluid Section Parameter</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout_5">
<item>
<widget class="QComboBox" name="cb_section_type"/>
</item>
</layout>
</widget>
</item>
<item>
<widget class="QStackedWidget" name="sw_section_type">
<property name="currentIndex">
<number>0</number>
</property>
<widget class="QWidget" name="page">
<layout class="QVBoxLayout" name="verticalLayout_8">
<item>
<widget class="QLabel" name="label">
<property name="text">
<string>Liquid Section Parameter</string>
</property>
</widget>
</item>
<item>
<widget class="QComboBox" name="cb_liquid_section_type"/>
</item>
<item>
<widget class="QStackedWidget" name="sw_liquid_section_type">
<property name="currentIndex">
<number>9</number>
</property>
<widget class="QWidget" name="page_4">
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
<widget class="QLabel" name="label_4">
<property name="text">
<string>Pipe Area </string>
</property>
</widget>
</item>
<item>
<widget class="Gui::InputField" name="if_manning_area">
<property name="text">
<string>0 mm^2</string>
</property>
<property name="unit" stdset="0">
<string notr="true">mm^2</string>
</property>
</widget>
</item>
</layout>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_2">
<item>
<widget class="QLabel" name="label_5">
<property name="text">
<string>Hydraulic Radius</string>
</property>
</widget>
</item>
<item>
<widget class="Gui::InputField" name="if_manning_radius">
<property name="text">
<string>0 mm</string>
</property>
<property name="unit" stdset="0">
<string notr="true">mm</string>
</property>
</widget>
</item>
</layout>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_3">
<item>
<widget class="QLabel" name="label_6">
<property name="text">
<string>Manning Coefficient</string>
</property>
</widget>
</item>
<item>
<widget class="QDoubleSpinBox" name="sb_manning_coefficient">
<property name="decimals">
<number>3</number>
</property>
<property name="maximum">
<double>1.000000000000000</double>
</property>
<property name="singleStep">
<double>0.001000000000000</double>
</property>
</widget>
</item>
</layout>
</item>
</layout>
</widget>
<widget class="QWidget" name="page_5">
<layout class="QVBoxLayout" name="verticalLayout_6">
<item>
<layout class="QHBoxLayout" name="horizontalLayout_4">
<item>
<widget class="QLabel" name="label_7">
<property name="text">
<string>Initial Area</string>
</property>
</widget>
</item>
<item>
<widget class="Gui::InputField" name="if_enlarge_area1">
<property name="text">
<string>0 mm^2</string>
</property>
<property name="unit" stdset="0">
<string notr="true">mm^2</string>
</property>
</widget>
</item>
</layout>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_5">
<item>
<widget class="QLabel" name="label_8">
<property name="text">
<string>Enlarged Area</string>
</property>
</widget>
</item>
<item>
<widget class="Gui::InputField" name="if_enlarge_area2">
<property name="text">
<string>0 mm^2</string>
</property>
<property name="unit" stdset="0">
<string notr="true">mm^2</string>
</property>
</widget>
</item>
</layout>
</item>
</layout>
</widget>
<widget class="QWidget" name="page_6">
<layout class="QVBoxLayout" name="verticalLayout_7">
<item>
<layout class="QHBoxLayout" name="horizontalLayout_7">
<item>
<widget class="QLabel" name="label_10">
<property name="text">
<string>Initial Area</string>
</property>
</widget>
</item>
<item>
<widget class="Gui::InputField" name="if_contract_area1">
<property name="text">
<string>0 mm^2</string>
</property>
<property name="unit" stdset="0">
<string notr="true">mm^2</string>
</property>
</widget>
</item>
</layout>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_6">
<item>
<widget class="QLabel" name="label_9">
<property name="text">
<string>Contracted Area</string>
</property>
</widget>
</item>
<item>
<widget class="Gui::InputField" name="if_contract_area2">
<property name="text">
<string>0 mm^2</string>
</property>
<property name="unit" stdset="0">
<string notr="true">mm^2</string>
</property>
</widget>
</item>
</layout>
</item>
</layout>
</widget>
<widget class="QWidget" name="page_7">
<layout class="QVBoxLayout" name="verticalLayout_13">
<item>
<widget class="QGroupBox" name="gb_inletpressure">
<property name="title">
<string>Inlet Pressure</string>
</property>
<property name="checkable">
<bool>true</bool>
</property>
<layout class="QVBoxLayout" name="verticalLayout_9">
<item>
<layout class="QHBoxLayout" name="horizontalLayout_8">
<item>
<widget class="QLabel" name="label_11">
<property name="text">
<string>Pressure</string>
</property>
</widget>
</item>
<item>
<widget class="Gui::InputField" name="if_inletpressure">
<property name="enabled">
<bool>true</bool>
</property>
<property name="text">
<string/>
</property>
<property name="unit" stdset="0">
<string notr="true">MPa</string>
</property>
</widget>
</item>
</layout>
</item>
</layout>
</widget>
</item>
<item>
<widget class="QGroupBox" name="gb_inletflowrate">
<property name="title">
<string>Inlet Mass Flow Rate</string>
</property>
<property name="checkable">
<bool>true</bool>
</property>
<layout class="QVBoxLayout" name="verticalLayout_12">
<item>
<layout class="QHBoxLayout" name="horizontalLayout_10">
<item>
<widget class="QLabel" name="label_13">
<property name="text">
<string>Mass flow rate</string>
</property>
</widget>
</item>
<item>
<widget class="Gui::InputField" name="if_inletflowrate">
<property name="text">
<string>1 kg/s</string>
</property>
<property name="unit" stdset="0">
<string notr="true">kg/s</string>
</property>
</widget>
</item>
</layout>
</item>
</layout>
</widget>
</item>
</layout>
</widget>
<widget class="QWidget" name="page_8">
<layout class="QVBoxLayout" name="verticalLayout_15">
<item>
<widget class="QGroupBox" name="gb_outletpressure">
<property name="title">
<string>Outlet Pressure</string>
</property>
<property name="checkable">
<bool>true</bool>
</property>
<layout class="QVBoxLayout" name="verticalLayout_10">
<item>
<layout class="QHBoxLayout" name="horizontalLayout_9">
<item>
<widget class="QLabel" name="label_12">
<property name="text">
<string>Pressure</string>
</property>
</widget>
</item>
<item>
<widget class="Gui::InputField" name="if_outletpressure">
<property name="text">
<string/>
</property>
<property name="unit" stdset="0">
<string notr="true">MPa</string>
</property>
</widget>
</item>
</layout>
</item>
</layout>
<zorder></zorder>
</widget>
</item>
<item>
<widget class="QGroupBox" name="gb_outletflowrate">
<property name="title">
<string>Outlet Mass Flow Rate</string>
</property>
<property name="checkable">
<bool>true</bool>
</property>
<layout class="QVBoxLayout" name="verticalLayout_14">
<item>
<layout class="QHBoxLayout" name="horizontalLayout_11">
<item>
<widget class="QLabel" name="label_14">
<property name="text">
<string>Mass flow rate</string>
</property>
</widget>
</item>
<item>
<widget class="Gui::InputField" name="if_outletflowrate">
<property name="text">
<string>1 kg/s</string>
</property>
<property name="unit" stdset="0">
<string notr="true">kg/s</string>
</property>
</widget>
</item>
</layout>
</item>
</layout>
</widget>
</item>
</layout>
</widget>
<widget class="QWidget" name="page_9">
<layout class="QVBoxLayout" name="verticalLayout_16">
<item>
<layout class="QHBoxLayout" name="horizontalLayout_13">
<item>
<widget class="QLabel" name="label_15">
<property name="text">
<string>Pipe Area</string>
</property>
</widget>
</item>
<item>
<widget class="Gui::InputField" name="if_entrance_pipe_area">
<property name="text">
<string>0 mm^2</string>
</property>
<property name="unit" stdset="0">
<string notr="true">mm^2</string>
</property>
</widget>
</item>
</layout>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_14">
<item>
<widget class="QLabel" name="label_16">
<property name="text">
<string>Entrance Area</string>
</property>
</widget>
</item>
<item>
<widget class="Gui::InputField" name="if_entrance_area">
<property name="text">
<string>0 mm^2</string>
</property>
<property name="unit" stdset="0">
<string notr="true">mm^2</string>
</property>
</widget>
</item>
</layout>
</item>
</layout>
</widget>
<widget class="QWidget" name="page_10">
<layout class="QVBoxLayout" name="verticalLayout_17">
<item>
<layout class="QHBoxLayout" name="horizontalLayout_15">
<item>
<widget class="QLabel" name="label_17">
<property name="text">
<string>Pipe Area</string>
</property>
</widget>
</item>
<item>
<widget class="Gui::InputField" name="if_diaphragm_pipe_area">
<property name="text">
<string>0 mm^2</string>
</property>
<property name="unit" stdset="0">
<string notr="true">mm^2</string>
</property>
</widget>
</item>
</layout>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_16">
<item>
<widget class="QLabel" name="label_18">
<property name="text">
<string>Diaphragm Area</string>
</property>
</widget>
</item>
<item>
<widget class="Gui::InputField" name="if_diaphragm_area">
<property name="text">
<string>0 mm^2</string>
</property>
<property name="unit" stdset="0">
<string notr="true">mm^2</string>
</property>
</widget>
</item>
</layout>
</item>
</layout>
</widget>
<widget class="QWidget" name="page_11">
<layout class="QVBoxLayout" name="verticalLayout_18">
<item>
<layout class="QHBoxLayout" name="horizontalLayout_17">
<item>
<widget class="QLabel" name="label_19">
<property name="text">
<string>Pipe Area</string>
</property>
</widget>
</item>
<item>
<widget class="Gui::InputField" name="if_bend_pipe_area">
<property name="text">
<string>0 mm^2</string>
</property>
<property name="unit" stdset="0">
<string notr="true">mm^2</string>
</property>
</widget>
</item>
</layout>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_18">
<item>
<widget class="QLabel" name="label_20">
<property name="text">
<string>Bend Radius/Pipe Diameter</string>
</property>
</widget>
</item>
<item>
<widget class="QDoubleSpinBox" name="sb_bradius_pdiameter">
<property name="decimals">
<number>3</number>
</property>
<property name="minimum">
<double>1.000000000000000</double>
</property>
<property name="maximum">
<double>9999999.000000000000000</double>
</property>
<property name="singleStep">
<double>0.100000000000000</double>
</property>
</widget>
</item>
</layout>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_19">
<item>
<widget class="QLabel" name="label_21">
<property name="text">
<string>Bend Angle</string>
</property>
</widget>
</item>
<item>
<widget class="QDoubleSpinBox" name="sb_bend_angle">
<property name="decimals">
<number>3</number>
</property>
<property name="maximum">
<double>360.000000000000000</double>
</property>
<property name="singleStep">
<double>1.000000000000000</double>
</property>
</widget>
</item>
</layout>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_20">
<item>
<widget class="QLabel" name="label_22">
<property name="text">
<string>Head loss coefficient</string>
</property>
</widget>
</item>
<item>
<widget class="QDoubleSpinBox" name="sb_bend_loss_coefficient">
<property name="decimals">
<number>3</number>
</property>
<property name="maximum">
<double>1.000000000000000</double>
</property>
<property name="singleStep">
<double>0.001000000000000</double>
</property>
</widget>
</item>
</layout>
</item>
</layout>
</widget>
<widget class="QWidget" name="page_12">
<layout class="QVBoxLayout" name="verticalLayout_19">
<item>
<layout class="QHBoxLayout" name="horizontalLayout_21">
<item>
<widget class="QLabel" name="label_23">
<property name="text">
<string>Pipe Area</string>
</property>
</widget>
</item>
<item>
<widget class="Gui::InputField" name="if_gatevalve_pipe_area">
<property name="text">
<string>0 mm^2</string>
</property>
<property name="unit" stdset="0">
<string notr="true">mm^2</string>
</property>
</widget>
</item>
</layout>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_22">
<item>
<widget class="QLabel" name="label_24">
<property name="text">
<string>Gate valve closing coefficient</string>
</property>
</widget>
</item>
<item>
<widget class="QDoubleSpinBox" name="sb_gatevalve_closing_coeff">
<property name="decimals">
<number>3</number>
</property>
<property name="minimum">
<double>0.125000000000000</double>
</property>
<property name="maximum">
<double>1.000000000000000</double>
</property>
<property name="singleStep">
<double>0.100000000000000</double>
</property>
</widget>
</item>
</layout>
</item>
</layout>
</widget>
<widget class="QWidget" name="page_13">
<layout class="QVBoxLayout" name="verticalLayout_21">
<item>
<layout class="QVBoxLayout" name="verticalLayout_20">
<item>
<widget class="QLabel" name="label_25">
<property name="text">
<string>Pump Characteristic</string>
</property>
</widget>
</item>
<item>
<widget class="QTableWidget" name="tw_pump_characteristics">
<row>
<property name="text">
<string>1</string>
</property>
</row>
<row>
<property name="text">
<string>2</string>
</property>
</row>
<row>
<property name="text">
<string>3</string>
</property>
</row>
<row>
<property name="text">
<string>4</string>
</property>
</row>
<row>
<property name="text">
<string>5</string>
</property>
</row>
<column>
<property name="text">
<string>Flow rate [mm^3/s]</string>
</property>
</column>
<column>
<property name="text">
<string>Head Loss[mm]</string>
</property>
</column>
<item row="0" column="0">
<property name="text">
<string/>
</property>
</item>
<item row="0" column="1">
<property name="text">
<string/>
</property>
</item>
<item row="1" column="0">
<property name="text">
<string/>
</property>
</item>
<item row="1" column="1">
<property name="text">
<string/>
</property>
</item>
<item row="2" column="0">
<property name="text">
<string/>
</property>
</item>
<item row="2" column="1">
<property name="text">
<string/>
</property>
</item>
<item row="3" column="0">
<property name="text">
<string/>
</property>
</item>
<item row="3" column="1">
<property name="text">
<string/>
</property>
</item>
<item row="4" column="0">
<property name="text">
<string/>
</property>
</item>
<item row="4" column="1">
<property name="text">
<string/>
</property>
</item>
</widget>
</item>
</layout>
</item>
</layout>
</widget>
<widget class="QWidget" name="page_14">
<layout class="QVBoxLayout" name="verticalLayout_22">
<item>
<layout class="QHBoxLayout" name="horizontalLayout_23">
<item>
<widget class="QLabel" name="label_26">
<property name="text">
<string>Pipe Area</string>
</property>
</widget>
</item>
<item>
<widget class="Gui::InputField" name="if_colebrooke_pipe_area">
<property name="text">
<string>0 mm^2</string>
</property>
<property name="unit" stdset="0">
<string notr="true">mm^2</string>
</property>
</widget>
</item>
</layout>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_24">
<item>
<widget class="QLabel" name="label_27">
<property name="text">
<string>Hydraulic Radius</string>
</property>
</widget>
</item>
<item>
<widget class="Gui::InputField" name="if_colebrooke_radius">
<property name="text">
<string>0 mm</string>
</property>
<property name="unit" stdset="0">
<string notr="true">mm</string>
</property>
</widget>
</item>
</layout>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_25">
<item>
<widget class="QLabel" name="label_28">
<property name="text">
<string>Grain diameter</string>
</property>
</widget>
</item>
<item>
<widget class="Gui::InputField" name="if_colebrooke_grain_diameter">
<property name="text">
<string>0 mm</string>
</property>
<property name="unit" stdset="0">
<string notr="true">mm</string>
</property>
</widget>
</item>
</layout>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_26">
<item>
<widget class="QLabel" name="label_29">
<property name="text">
<string>Cross section form factor</string>
</property>
</widget>
</item>
<item>
<widget class="QDoubleSpinBox" name="sb_colebrooke_form_factor">
<property name="decimals">
<number>3</number>
</property>
<property name="minimum">
<double>0.000000000000000</double>
</property>
<property name="maximum">
<double>1.000000000000000</double>
</property>
<property name="singleStep">
<double>0.100000000000000</double>
</property>
<property name="value">
<double>1.000000000000000</double>
</property>
</widget>
</item>
</layout>
</item>
</layout>
</widget>
</widget>
</item>
</layout>
</widget>
<widget class="QWidget" name="page_2">
<layout class="QVBoxLayout" name="verticalLayout_3">
<item>
<widget class="QLabel" name="label_2">
<property name="text">
<string>Gas Section Parameter</string>
</property>
</widget>
</item>
<item>
<widget class="QComboBox" name="cb_gas_section_type"/>
</item>
</layout>
</widget>
<widget class="QWidget" name="page_3">
<layout class="QVBoxLayout" name="verticalLayout_4">
<item>
<widget class="QLabel" name="label_3">
<property name="text">
<string>Open Channel Section Parameter</string>
</property>
</widget>
</item>
<item>
<widget class="QComboBox" name="cb_channel_section_type"/>
</item>
</layout>
</widget>
</widget>
</item>
<item>
<widget class="QGroupBox" name="groupBox_1">
<property name="title">
<string>References</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout_2">
<item>
<widget class="QLabel" name="l_label_text_1">
<property name="text">
<string>Select an edge, click Add or Remove</string>
</property>
</widget>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_12">
<item>
<widget class="QPushButton" name="btn_add">
<property name="text">
<string>Add</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="btn_remove">
<property name="text">
<string>Remove</string>
</property>
</widget>
</item>
</layout>
</item>
<item>
<widget class="QListWidget" name="list_References"/>
</item>
</layout>
</widget>
</item>
</layout>
</widget>
<customwidgets>
<customwidget>
<class>Gui::InputField</class>
<extends>QLineEdit</extends>
<header>Gui/InputField.h</header>
</customwidget>
</customwidgets>
<resources/>
<connections/>
</ui>

View File

@@ -0,0 +1,382 @@
# ***************************************************************************
# * *
# * Copyright (c) 2016 - Ofentse Kgoa <kgoaot@eskom.co.za> *
# * Based on the FemBeamSection by Bernd Hahnebach *
# * *
# * 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__ = "_TaskPanelFemFluidSection"
__author__ = "Ofentse Kgoa"
__url__ = "http://www.freecadweb.org"
## @package TaskPanelFemFluidSection
# \ingroup FEM
import FreeCAD
import FreeCADGui
from PySide import QtGui
from PySide import QtCore
import PyObjects._FemFluidSection
class _TaskPanelFemFluidSection:
'''The TaskPanel for editing References property of FemFluidSection objects'''
def __init__(self, obj):
FreeCADGui.Selection.clearSelection()
self.sel_server = None
self.obj = obj
self.form = FreeCADGui.PySideUic.loadUi(FreeCAD.getHomePath() + "Mod/Fem/PyGui/TaskPanelFemFluidSection.ui")
QtCore.QObject.connect(self.form.btn_add, QtCore.SIGNAL("clicked()"), self.add_references)
QtCore.QObject.connect(self.form.btn_remove, QtCore.SIGNAL("clicked()"), self.remove_reference)
QtCore.QObject.connect(self.form.cb_section_type, QtCore.SIGNAL("activated(int)"), self.sectiontype_changed)
QtCore.QObject.connect(self.form.cb_liquid_section_type, QtCore.SIGNAL("activated(int)"), self.liquidsectiontype_changed)
QtCore.QObject.connect(self.form.if_manning_area, QtCore.SIGNAL("valueChanged(Base::Quantity)"), self.manning_area_changed)
QtCore.QObject.connect(self.form.if_manning_radius, QtCore.SIGNAL("valueChanged(Base::Quantity)"), self.manning_radius_changed)
QtCore.QObject.connect(self.form.sb_manning_coefficient, QtCore.SIGNAL("valueChanged(double)"), self.manning_coefficient_changed)
QtCore.QObject.connect(self.form.if_enlarge_area1, QtCore.SIGNAL("valueChanged(Base::Quantity)"), self.enlarge_area1_changed)
QtCore.QObject.connect(self.form.if_enlarge_area2, QtCore.SIGNAL("valueChanged(Base::Quantity)"), self.enlarge_area2_changed)
QtCore.QObject.connect(self.form.if_contract_area1, QtCore.SIGNAL("valueChanged(Base::Quantity)"), self.contract_area1_changed)
QtCore.QObject.connect(self.form.if_contract_area2, QtCore.SIGNAL("valueChanged(Base::Quantity)"), self.contract_area2_changed)
QtCore.QObject.connect(self.form.if_inletpressure, QtCore.SIGNAL("valueChanged(Base::Quantity)"), self.inlet_pressure_changed)
QtCore.QObject.connect(self.form.if_outletpressure, QtCore.SIGNAL("valueChanged(Base::Quantity)"), self.outlet_pressure_changed)
QtCore.QObject.connect(self.form.if_inletflowrate, QtCore.SIGNAL("valueChanged(Base::Quantity)"), self.inlet_flowrate_changed)
QtCore.QObject.connect(self.form.if_outletflowrate, QtCore.SIGNAL("valueChanged(Base::Quantity)"), self.outlet_flowrate_changed)
QtCore.QObject.connect(self.form.gb_inletpressure, QtCore.SIGNAL("clicked(bool)"), self.inlet_pressure_active)
QtCore.QObject.connect(self.form.gb_outletpressure, QtCore.SIGNAL("clicked(bool)"), self.outlet_pressure_active)
QtCore.QObject.connect(self.form.gb_inletflowrate, QtCore.SIGNAL("clicked(bool)"), self.inlet_flowrate_active)
QtCore.QObject.connect(self.form.gb_outletflowrate, QtCore.SIGNAL("clicked(bool)"), self.outlet_flowrate_active)
QtCore.QObject.connect(self.form.if_entrance_pipe_area, QtCore.SIGNAL("valueChanged(Base::Quantity)"), self.entrance_pipe_area_changed)
QtCore.QObject.connect(self.form.if_entrance_area, QtCore.SIGNAL("valueChanged(Base::Quantity)"), self.entrance_area_changed)
QtCore.QObject.connect(self.form.if_diaphragm_pipe_area, QtCore.SIGNAL("valueChanged(Base::Quantity)"), self.diaphragm_pipe_area_changed)
QtCore.QObject.connect(self.form.if_diaphragm_area, QtCore.SIGNAL("valueChanged(Base::Quantity)"), self.diaphragm_area_changed)
QtCore.QObject.connect(self.form.if_bend_pipe_area, QtCore.SIGNAL("valueChanged(Base::Quantity)"), self.bend_pipe_area_changed)
QtCore.QObject.connect(self.form.sb_bradius_pdiameter, QtCore.SIGNAL("valueChanged(double)"), self.bradius_pdiameter_changed)
QtCore.QObject.connect(self.form.sb_bend_angle, QtCore.SIGNAL("valueChanged(double)"), self.bend_angle_changed)
QtCore.QObject.connect(self.form.sb_bend_loss_coefficient, QtCore.SIGNAL("valueChanged(double)"), self.bend_loss_coefficient_changed)
QtCore.QObject.connect(self.form.if_gatevalve_pipe_area, QtCore.SIGNAL("valueChanged(Base::Quantity)"), self.gatevalve_pipe_area_changed)
QtCore.QObject.connect(self.form.sb_gatevalve_closing_coeff, QtCore.SIGNAL("valueChanged(double)"), self.gatevalve_closing_coeff_changed)
QtCore.QObject.connect(self.form.if_colebrooke_pipe_area, QtCore.SIGNAL("valueChanged(Base::Quantity)"), self.colebrooke_pipe_area_changed)
QtCore.QObject.connect(self.form.if_colebrooke_radius, QtCore.SIGNAL("valueChanged(Base::Quantity)"), self.colebrooke_radius_changed)
QtCore.QObject.connect(self.form.if_colebrooke_grain_diameter, QtCore.SIGNAL("valueChanged(Base::Quantity)"), self.colebrooke_grain_diameter_changed)
QtCore.QObject.connect(self.form.sb_colebrooke_form_factor, QtCore.SIGNAL("valueChanged(double)"), self.colebrooke_form_factor_changed)
QtCore.QObject.connect(self.form.tw_pump_characteristics, QtCore.SIGNAL("cellChanged(int, int)"), self.pump_characteristics_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)
self.form.cb_section_type.addItems(PyObjects._FemFluidSection._FemFluidSection.known_fluid_types)
self.form.cb_liquid_section_type.addItems(PyObjects._FemFluidSection._FemFluidSection.known_liquid_types)
self.form.cb_gas_section_type.addItems(PyObjects._FemFluidSection._FemFluidSection.known_gas_types)
self.form.cb_channel_section_type.addItems(PyObjects._FemFluidSection._FemFluidSection.known_channel_types)
self.get_fluidsection_props()
self.update()
def accept(self):
self.set_fluidsection_props()
if self.sel_server:
FreeCADGui.Selection.removeObserver(self.sel_server)
FreeCADGui.ActiveDocument.resetEdit()
FreeCAD.ActiveDocument.recompute()
return True
def reject(self):
if self.sel_server:
FreeCADGui.Selection.removeObserver(self.sel_server)
FreeCADGui.ActiveDocument.resetEdit()
return True
def get_fluidsection_props(self):
self.references = []
if self.obj.References:
self.tuplereferences = self.obj.References
self.get_references()
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.References = self.references
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 update(self):
'fills the widgets'
index_sectiontype = self.form.cb_section_type.findText(self.SectionType)
self.form.cb_section_type.setCurrentIndex(index_sectiontype)
self.form.sw_section_type.setCurrentIndex(index_sectiontype)
index_liquidsectiontype = self.form.cb_liquid_section_type.findText(self.LiquidSectionType)
self.form.cb_liquid_section_type.setCurrentIndex(index_liquidsectiontype)
self.form.sw_liquid_section_type.setCurrentIndex(index_liquidsectiontype)
self.form.if_manning_area.setText(self.ManningArea.UserString)
self.form.if_manning_radius.setText(self.ManningRadius.UserString)
self.form.sb_manning_coefficient.setValue(self.ManningCoefficient)
self.form.if_enlarge_area1.setText(self.EnlargeArea1.UserString)
self.form.if_enlarge_area2.setText(self.EnlargeArea2.UserString)
self.form.if_contract_area1.setText(self.ContractArea1.UserString)
self.form.if_contract_area2.setText(self.ContractArea2.UserString)
self.form.if_inletpressure.setText(FreeCAD.Units.Quantity(1000 * self.InletPressure, FreeCAD.Units.Pressure).UserString)
self.form.if_outletpressure.setText(FreeCAD.Units.Quantity(1000 * self.OutletPressure, FreeCAD.Units.Pressure).UserString)
self.form.if_inletflowrate.setText(str(self.InletFlowRate))
self.form.if_outletflowrate.setText(str(self.OutletFlowRate))
self.form.gb_inletpressure.setChecked(self.InletPressureActive)
self.form.gb_outletpressure.setChecked(self.OutletPressureActive)
self.form.gb_inletflowrate.setChecked(self.InletFlowRateActive)
self.form.gb_outletflowrate.setChecked(self.OutletFlowRateActive)
self.form.if_entrance_pipe_area.setText(self.EntrancePipeArea.UserString)
self.form.if_entrance_area.setText(self.EntranceArea.UserString)
self.form.if_diaphragm_pipe_area.setText(self.DiaphragmPipeArea.UserString)
self.form.if_diaphragm_area.setText(self.DiaphragmArea.UserString)
self.form.if_bend_pipe_area.setText(self.BendPipeArea.UserString)
self.form.sb_bradius_pdiameter.setValue(self.BendRadiusDiameter)
self.form.sb_bend_angle.setValue(self.BendAngle)
self.form.sb_bend_loss_coefficient.setValue(self.BendLossCoefficient)
self.form.if_gatevalve_pipe_area.setText(self.GateValvePipeArea.UserString)
self.form.sb_gatevalve_closing_coeff.setValue(self.GateValveClosingCoeff)
self.form.if_colebrooke_pipe_area.setText(self.ColebrookeArea.UserString)
self.form.if_colebrooke_radius.setText(self.ColebrookeRadius.UserString)
self.form.if_colebrooke_grain_diameter.setText(self.ColebrookeGrainDiameter.UserString)
self.form.sb_colebrooke_form_factor.setValue(self.ColebrookeFormFactor)
for i in range(len(self.PumpFlowRate)):
self.form.tw_pump_characteristics.setItem(i,0,QtGui.QTableWidgetItem(str(self.PumpFlowRate[i])))
self.form.tw_pump_characteristics.setItem(i,1,QtGui.QTableWidgetItem(str(self.PumpHeadLoss[i])))
self.rebuild_list_References()
def sectiontype_changed(self, index):
if index < 0:
return
self.form.cb_section_type.setCurrentIndex(index)
self.form.sw_section_type.setCurrentIndex(index)
self.SectionType = str(self.form.cb_section_type.itemText(index)) # form returns unicode
def liquidsectiontype_changed(self, index):
if index < 0:
return
self.form.cb_liquid_section_type.setCurrentIndex(index)
self.form.sw_liquid_section_type.setCurrentIndex(index)
self.LiquidSectionType = str(self.form.cb_liquid_section_type.itemText(index)) # form returns unicode
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 = float(FreeCAD.Units.Quantity(base_quantity_value).getValueAs("MPa"))
def outlet_pressure_changed(self, base_quantity_value):
self.OutletPressure = float(FreeCAD.Units.Quantity(base_quantity_value).getValueAs("MPa"))
def inlet_flowrate_changed(self, base_quantity_value):
self.InletFlowRate = float(FreeCAD.Units.Quantity(base_quantity_value).getValueAs("kg/s"))
def outlet_flowrate_changed(self, base_quantity_value):
self.OutletFlowRate = float(FreeCAD.Units.Quantity(base_quantity_value).getValueAs("kg/s"))
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.form.tw_pump_characteristics.item(row, column).text())
else:
self.PumpHeadLoss[row] = float(self.form.tw_pump_characteristics.item(row, column).text())
def get_references(self):
for ref in self.tuplereferences:
for elem in ref[1]:
self.references.append((ref[0], elem))
def references_list_right_clicked(self, QPos):
self.form.contextMenu = QtGui.QMenu()
menu_item = self.form.contextMenu.addAction("Remove Reference")
if not self.references:
menu_item.setDisabled(True)
self.form.connect(menu_item, QtCore.SIGNAL("triggered()"), self.remove_reference)
parentPosition = self.form.list_References.mapToGlobal(QtCore.QPoint(0, 0))
self.form.contextMenu.move(parentPosition + QPos)
self.form.contextMenu.show()
def remove_reference(self):
if not self.references:
return
currentItemName = str(self.form.list_References.currentItem().text())
for ref in self.references:
refname_to_compare_listentry = ref[0].Name + ':' + ref[1]
if refname_to_compare_listentry == currentItemName:
self.references.remove(ref)
self.rebuild_list_References()
def add_references(self):
'''Called if Button add_reference is triggered'''
# in constraints EditTaskPanel the selection is active as soon as the taskpanel is open
# here the addReference button EditTaskPanel has to be triggered to start selection mode
FreeCADGui.Selection.clearSelection()
# start SelectionObserver and parse the function to add the References to the widget
print_message = "Select Edges by single click on them to add them to the list"
import FemSelectionObserver
self.sel_server = FemSelectionObserver.FemSelectionObserver(self.selectionParser, print_message)
def selectionParser(self, selection):
# print('selection: ', selection[0].Shape.ShapeType, ' ', selection[0].Name, ' ', selection[1])
if hasattr(selection[0], "Shape"):
if selection[1]:
elt = selection[0].Shape.getElement(selection[1])
if elt.ShapeType == 'Edge':
if selection not in self.references:
self.references.append(selection)
self.rebuild_list_References()
else:
FreeCAD.Console.PrintMessage(selection[0].Name + ' --> ' + selection[1] + ' is in reference list already!\n')
def rebuild_list_References(self):
self.form.list_References.clear()
items = []
for ref in self.references:
item_name = ref[0].Name + ':' + ref[1]
items.append(item_name)
for listItemName in sorted(items):
self.form.list_References.addItem(listItemName)

View File

@@ -0,0 +1,85 @@
# ***************************************************************************
# * *
# * Copyright (c) 2016 - Ofentse Kgoa <kgoaot@eskom.co.za> *
# * Based on the FemBeamSection by Bernd Hahnebach *
# * *
# * 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__ = "_ViewProviderFemFluidSection"
__author__ = "Ofentse Kgoa"
__url__ = "http://www.freecadweb.org"
## @package ViewProviderFemFluidSection
# \ingroup FEM
import FreeCAD
import FreeCADGui
from pivy import coin
class _ViewProviderFemFluidSection:
"A View Provider for the FemFluidSection object"
def __init__(self, vobj):
vobj.Proxy = self
def getIcon(self):
return ":/icons/fem-fluid-section.svg"
def attach(self, vobj):
self.ViewObject = vobj
self.Object = vobj.Object
self.standard = coin.SoGroup()
vobj.addDisplayMode(self.standard, "Standard")
def getDisplayModes(self, obj):
return ["Standard"]
def getDefaultDisplayMode(self):
return "Standard"
def updateData(self, obj, prop):
return
def onChanged(self, vobj, prop):
return
def setEdit(self, vobj, mode=0):
import PyGui._TaskPanelFemFluidSection
taskd = PyGui._TaskPanelFemFluidSection._TaskPanelFemFluidSection(self.Object)
taskd.obj = vobj.Object
FreeCADGui.Control.showDialog(taskd)
return True
def unsetEdit(self, vobj, mode=0):
FreeCADGui.Control.closeDialog()
return
def doubleClicked(self, vobj):
doc = FreeCADGui.getDocument(vobj.Object.Document)
if not doc.getInEdit():
doc.setEdit(vobj.Object.Name)
else:
FreeCAD.Console.PrintError('Active Task Dialog found! Please close this one first!\n')
return True
def __getstate__(self):
return None
def __setstate__(self, state):
return None

View File

@@ -31,6 +31,12 @@ __url__ = "http://www.freecadweb.org"
class _FemConstraintSelfWeight:
"The FemConstraintSelfWeight object"
def __init__(self, obj):
obj.addProperty("App::PropertyFloat", "Gravity_x", "Gravity", "set the gravity component in the x direction")
obj.addProperty("App::PropertyFloat", "Gravity_y", "Gravity", "set the gravity component in the y direction")
obj.addProperty("App::PropertyFloat", "Gravity_z", "Gravity", "set the gravity component in the z direction")
obj.Gravity_x = 0.0
obj.Gravity_y = 0.0
obj.Gravity_z = -1.0
obj.Proxy = self
self.Type = "FemConstraintSelfWeight"

View File

@@ -0,0 +1,122 @@
# ***************************************************************************
# * *
# * Copyright (c) 2016 - Ofentse Kgoa <kgoaot@eskom.co.za> *
# * Based on the FemBeamSection by Bernd Hahnebach *
# * *
# * 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__ = "_FemFluidSection"
__author__ = "Ofentse Kgoa"
__url__ = "http://www.freecadweb.org"
## @package FemFluidSection
# \ingroup FEM
class _FemFluidSection:
"The FemFluidSection object"
known_fluid_types = ['Liquid', 'Gas', 'Open Channel']
known_liquid_types = ['PIPE MANNING', 'PIPE ENLARGEMENT', 'PIPE CONTRACTION', 'PIPE INLET', 'PIPE OUTLET', 'PIPE ENTRANCE', 'PIPE DIAPHRAGM', 'PIPE BEND', 'PIPE GATE VALVE', 'LIQUID PUMP', 'PIPE WHITE-COLEBROOK']
known_gas_types = ['NONE']
known_channel_types = ['NONE']
def __init__(self, obj):
obj.addProperty("App::PropertyLinkSubList", "References", "FluidSection", "List of fluid section shapes")
obj.addProperty("App::PropertyEnumeration", "SectionType", "FluidSection", "select fluid section type")
obj.addProperty("App::PropertyEnumeration", "LiquidSectionType", "LiquidSection", "select liquid section type")
obj.addProperty("App::PropertyArea", "ManningArea", "LiquidManning", "set area of the manning fluid section")
obj.addProperty("App::PropertyLength", "ManningRadius", "LiquidManning", "set hydraulic radius of manning fluid section")
obj.addProperty("App::PropertyFloat", "ManningCoefficient", "LiquidManning", "set coefficient of manning fluid section")
obj.addProperty("App::PropertyArea", "EnlargeArea1", "LiquidEnlargement", "set intial area of the enlargement fluid section")
obj.addProperty("App::PropertyArea", "EnlargeArea2", "LiquidEnlargement", "set enlarged area of enlargement fluid section")
obj.addProperty("App::PropertyArea", "ContractArea1", "LiquidContraction", "set intial area of the contraction fluid section")
obj.addProperty("App::PropertyArea", "ContractArea2", "LiquidContraction", "set contracted area of contraction fluid section")
obj.addProperty("App::PropertyFloat", "InletPressure", "LiquidInlet", "set inlet pressure for fluid section")
obj.addProperty("App::PropertyFloat", "OutletPressure", "LiquidOutlet", "set outlet pressure for fluid section")
obj.addProperty("App::PropertyFloat", "InletFlowRate", "LiquidInlet", "set inlet mass flow rate for fluid section")
obj.addProperty("App::PropertyFloat", "OutletFlowRate", "LiquidOutlet", "set outlet mass flow rate for fluid section")
obj.addProperty("App::PropertyBool", "InletPressureActive", "LiquidInlet", "activates or deactivates inlet pressure for fluid section")
obj.addProperty("App::PropertyBool", "OutletPressureActive", "LiquidOutlet", "activates or deactivates outlet pressure for fluid section")
obj.addProperty("App::PropertyBool", "InletFlowRateActive", "LiquidInlet", "activates or deactivates inlet flow rate for fluid section")
obj.addProperty("App::PropertyBool", "OutletFlowRateActive", "LiquidOutlet", "activates or deactivates outlet flow rate for fluid section")
obj.addProperty("App::PropertyArea", "EntrancePipeArea", "LiquidEntrance", "set the pipe area of the entrance fluid section")
obj.addProperty("App::PropertyArea", "EntranceArea", "LiquidEntrance", "set the entrance area of the entrance fluid section")
obj.addProperty("App::PropertyArea", "DiaphragmPipeArea", "LiquidDiaphragm", "set the pipe area of the diaphragm fluid section")
obj.addProperty("App::PropertyArea", "DiaphragmArea", "LiquidDiaphragm", "set the diaphragm area of the diaphragm fluid section")
obj.addProperty("App::PropertyArea", "BendPipeArea", "LiquidBend", "set pipe area of the bend fluid section")
obj.addProperty("App::PropertyFloat", "BendRadiusDiameter", "LiquidBend", "set ratio of bend radius over pipe diameter of the bend fluid section")
obj.addProperty("App::PropertyFloat", "BendAngle", "LiquidBend", "set bend angle of the bend fluid section")
obj.addProperty("App::PropertyFloat", "BendLossCoefficient", "LiquidBend", "set loss coefficient of the bend fluid section")
obj.addProperty("App::PropertyArea", "GateValvePipeArea", "LiquidGateValve", "set pipe area of the gate valve fluid section")
obj.addProperty("App::PropertyFloat", "GateValveClosingCoeff", "LiquidGateValve", "set closing coefficient of the gate valve fluid section")
obj.addProperty("App::PropertyFloatList", "PumpFlowRate", "LiquidPump", "set the pump characteristic flow rate of the pump fluid section")
obj.addProperty("App::PropertyFloatList", "PumpHeadLoss", "LiquidPump", "set the pump characteristic head loss of the pump fluid section")
obj.addProperty("App::PropertyArea", "ColebrookeArea", "LiquidColebrooke", "set pipe area of the colebrooke fluid section")
obj.addProperty("App::PropertyLength", "ColebrookeRadius", "LiquidColebrooke", "set hydraulic radius of the colebrooke fluid section")
obj.addProperty("App::PropertyLength", "ColebrookeGrainDiameter", "LiquidColebrooke", "set grain diameter of the colebrooke fluid section")
obj.addProperty("App::PropertyFloat", "ColebrookeFormFactor", "LiquidColebrooke", "set coefficient of the colebrooke fluid section")
obj.addProperty("App::PropertyEnumeration", "GasSectionType", "GasSection", "select gas section type")
obj.addProperty("App::PropertyEnumeration", "ChannelSectionType", "ChannelSection", "select channel section type")
# set property default values
obj.SectionType = _FemFluidSection.known_fluid_types
obj.SectionType = 'Liquid'
obj.LiquidSectionType = _FemFluidSection.known_liquid_types
obj.LiquidSectionType = 'PIPE INLET'
obj.GasSectionType = _FemFluidSection.known_gas_types
obj.GasSectionType = 'NONE'
obj.ChannelSectionType = _FemFluidSection.known_channel_types
obj.ChannelSectionType = 'NONE'
obj.ManningArea = 10.0
obj.ManningRadius = 1.0
obj.ManningCoefficient = 0.0015 # has units of s/mm^(1/3)
obj.EnlargeArea1 = 10.0
obj.EnlargeArea2 = 20.0
obj.ContractArea1 = 20.0
obj.ContractArea2 = 10.0
obj.EntrancePipeArea = 20.0
obj.EntranceArea = 20.0
obj.DiaphragmPipeArea = 20.0
obj.DiaphragmArea = 20.0
obj.BendPipeArea = 20.0
obj.BendRadiusDiameter = 1.0
obj.BendAngle = 0.0
obj.BendLossCoefficient = 0.0
obj.GateValvePipeArea = 20.0
obj.GateValveClosingCoeff = 0.125
obj.PumpFlowRate = [0, 1.04e-04, 2.08e-4, 3.13e-4, 4.17e-4]
obj.PumpHeadLoss = [30, 29.17, 26.67, 23.33, 18.33]
obj.ColebrookeArea = 20.0
obj.ColebrookeRadius = 1.0
obj.ColebrookeGrainDiameter = 0.0025
obj.ColebrookeFormFactor = 1.0
obj.InletPressure = 1.0
obj.OutletPressure = 1.0
obj.InletFlowRate = 1.0
obj.OutletFlowRate = 1.0
obj.InletPressureActive = True
obj.OutletPressureActive = True
obj.InletFlowRateActive = False
obj.OutletFlowRateActive = False
obj.Proxy = self
self.Type = "FemFluidSection"
def execute(self, obj):
return