File size: 13,408 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
# ***************************************************************************
# *   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 document object"
__author__ = "Ofentse Kgoa"
__url__ = "https://www.freecad.org"

## @package element_fluid1D
#  \ingroup FEM
#  \brief element fluid 1D object

from . import base_femelement


class ElementFluid1D(base_femelement.BaseFemElement):
    """
    The element_fluid1D object
    """

    Type = "Fem::ElementFluid1D"

    known_fluid_types = ["Liquid"]
    # "Gas", "Open Channel" are not implemented in ccx writer
    # 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):
        super().__init__(obj)

        obj.addProperty(
            "App::PropertyEnumeration", "SectionType", "FluidSection", "select fluid section type"
        )
        obj.setPropertyStatus("SectionType", "LockDynamic")

        obj.addProperty(
            "App::PropertyEnumeration",
            "LiquidSectionType",
            "LiquidSection",
            "select liquid section type",
        )
        obj.setPropertyStatus("LiquidSectionType", "LockDynamic")

        obj.addProperty(
            "App::PropertyArea",
            "ManningArea",
            "LiquidManning",
            "set area of the manning fluid section",
        )
        obj.setPropertyStatus("ManningArea", "LockDynamic")

        obj.addProperty(
            "App::PropertyLength",
            "ManningRadius",
            "LiquidManning",
            "set hydraulic radius of manning fluid section",
        )
        obj.setPropertyStatus("ManningRadius", "LockDynamic")

        obj.addProperty(
            "App::PropertyFloat",
            "ManningCoefficient",
            "LiquidManning",
            "set coefficient of manning fluid section",
        )
        obj.setPropertyStatus("ManningCoefficient", "LockDynamic")

        obj.addProperty(
            "App::PropertyArea",
            "EnlargeArea1",
            "LiquidEnlargement",
            "set initial area of the enlargement fluid section",
        )
        obj.setPropertyStatus("EnlargeArea1", "LockDynamic")
        obj.addProperty(
            "App::PropertyArea",
            "EnlargeArea2",
            "LiquidEnlargement",
            "set enlarged area of enlargement fluid section",
        )
        obj.setPropertyStatus("EnlargeArea2", "LockDynamic")

        obj.addProperty(
            "App::PropertyArea",
            "ContractArea1",
            "LiquidContraction",
            "set initial area of the contraction fluid section",
        )
        obj.setPropertyStatus("ContractArea1", "LockDynamic")

        obj.addProperty(
            "App::PropertyArea",
            "ContractArea2",
            "LiquidContraction",
            "set contracted area of contraction fluid section",
        )
        obj.setPropertyStatus("ContractArea2", "LockDynamic")

        obj.addProperty(
            "App::PropertyFloat",
            "InletPressure",
            "LiquidInlet",
            "set inlet pressure for fluid section",
        )
        obj.setPropertyStatus("InletPressure", "LockDynamic")

        obj.addProperty(
            "App::PropertyFloat",
            "OutletPressure",
            "LiquidOutlet",
            "set outlet pressure for fluid section",
        )
        obj.setPropertyStatus("OutletPressure", "LockDynamic")

        obj.addProperty(
            "App::PropertyFloat",
            "InletFlowRate",
            "LiquidInlet",
            "set inlet mass flow rate for fluid section",
        )
        obj.setPropertyStatus("InletFlowRate", "LockDynamic")

        obj.addProperty(
            "App::PropertyFloat",
            "OutletFlowRate",
            "LiquidOutlet",
            "set outlet mass flow rate for fluid section",
        )
        obj.setPropertyStatus("OutletFlowRate", "LockDynamic")

        obj.addProperty(
            "App::PropertyBool",
            "InletPressureActive",
            "LiquidInlet",
            "activates or deactivates inlet pressure for fluid section",
        )
        obj.setPropertyStatus("InletPressureActive", "LockDynamic")

        obj.addProperty(
            "App::PropertyBool",
            "OutletPressureActive",
            "LiquidOutlet",
            "activates or deactivates outlet pressure for fluid section",
        )
        obj.setPropertyStatus("OutletPressureActive", "LockDynamic")

        obj.addProperty(
            "App::PropertyBool",
            "InletFlowRateActive",
            "LiquidInlet",
            "activates or deactivates inlet flow rate for fluid section",
        )
        obj.setPropertyStatus("InletFlowRateActive", "LockDynamic")

        obj.addProperty(
            "App::PropertyBool",
            "OutletFlowRateActive",
            "LiquidOutlet",
            "activates or deactivates outlet flow rate for fluid section",
        )
        obj.setPropertyStatus("OutletFlowRateActive", "LockDynamic")

        obj.addProperty(
            "App::PropertyArea",
            "EntrancePipeArea",
            "LiquidEntrance",
            "set the pipe area of the entrance fluid section",
        )
        obj.setPropertyStatus("EntrancePipeArea", "LockDynamic")

        obj.addProperty(
            "App::PropertyArea",
            "EntranceArea",
            "LiquidEntrance",
            "set the entrance area of the entrance fluid section",
        )
        obj.setPropertyStatus("EntranceArea", "LockDynamic")

        obj.addProperty(
            "App::PropertyArea",
            "DiaphragmPipeArea",
            "LiquidDiaphragm",
            "set the pipe area of the diaphragm fluid section",
        )
        obj.setPropertyStatus("DiaphragmPipeArea", "LockDynamic")

        obj.addProperty(
            "App::PropertyArea",
            "DiaphragmArea",
            "LiquidDiaphragm",
            "set the diaphragm area of the diaphragm fluid section",
        )
        obj.setPropertyStatus("DiaphragmArea", "LockDynamic")

        obj.addProperty(
            "App::PropertyArea",
            "BendPipeArea",
            "LiquidBend",
            "set pipe area of the bend fluid section",
        )
        obj.setPropertyStatus("BendPipeArea", "LockDynamic")

        obj.addProperty(
            "App::PropertyFloat",
            "BendRadiusDiameter",
            "LiquidBend",
            "set ratio of bend radius over pipe diameter of the bend fluid section",
        )
        obj.setPropertyStatus("BendRadiusDiameter", "LockDynamic")

        obj.addProperty(
            "App::PropertyFloat",
            "BendAngle",
            "LiquidBend",
            "set bend angle of the bend fluid section",
        )
        obj.setPropertyStatus("BendAngle", "LockDynamic")

        obj.addProperty(
            "App::PropertyFloat",
            "BendLossCoefficient",
            "LiquidBend",
            "set loss coefficient of the bend fluid section",
        )
        obj.setPropertyStatus("BendLossCoefficient", "LockDynamic")

        obj.addProperty(
            "App::PropertyArea",
            "GateValvePipeArea",
            "LiquidGateValve",
            "set pipe area of the gate valve fluid section",
        )
        obj.setPropertyStatus("GateValvePipeArea", "LockDynamic")

        obj.addProperty(
            "App::PropertyFloat",
            "GateValveClosingCoeff",
            "LiquidGateValve",
            "set closing coefficient of the gate valve fluid section",
        )
        obj.setPropertyStatus("GateValveClosingCoeff", "LockDynamic")

        obj.addProperty(
            "App::PropertyFloatList",
            "PumpFlowRate",
            "LiquidPump",
            "set the pump characteristic flow rate of the pump fluid section",
        )
        obj.setPropertyStatus("PumpFlowRate", "LockDynamic")

        obj.addProperty(
            "App::PropertyFloatList",
            "PumpHeadLoss",
            "LiquidPump",
            "set the pump characteristic head loss of the pump fluid section",
        )
        obj.setPropertyStatus("PumpHeadLoss", "LockDynamic")

        obj.addProperty(
            "App::PropertyArea",
            "ColebrookeArea",
            "LiquidColebrooke",
            "set pipe area of the colebrooke fluid section",
        )
        obj.setPropertyStatus("ColebrookeArea", "LockDynamic")

        obj.addProperty(
            "App::PropertyLength",
            "ColebrookeRadius",
            "LiquidColebrooke",
            "set hydraulic radius of the colebrooke fluid section",
        )
        obj.setPropertyStatus("ColebrookeRadius", "LockDynamic")

        obj.addProperty(
            "App::PropertyLength",
            "ColebrookeGrainDiameter",
            "LiquidColebrooke",
            "set grain diameter of the colebrooke fluid section",
        )
        obj.setPropertyStatus("ColebrookeGrainDiameter", "LockDynamic")

        obj.addProperty(
            "App::PropertyFloat",
            "ColebrookeFormFactor",
            "LiquidColebrooke",
            "set coefficient of the colebrooke fluid section",
        )
        obj.setPropertyStatus("ColebrookeFormFactor", "LockDynamic")

        obj.addProperty(
            "App::PropertyEnumeration", "GasSectionType", "GasSection", "select gas section type"
        )
        obj.setPropertyStatus("GasSectionType", "LockDynamic")

        obj.addProperty(
            "App::PropertyEnumeration",
            "ChannelSectionType",
            "ChannelSection",
            "select channel section type",
        )
        obj.setPropertyStatus("ChannelSectionType", "LockDynamic")

        # set property default values
        obj.SectionType = ElementFluid1D.known_fluid_types
        obj.SectionType = "Liquid"
        obj.LiquidSectionType = ElementFluid1D.known_liquid_types
        obj.LiquidSectionType = "PIPE INLET"
        obj.GasSectionType = ElementFluid1D.known_gas_types
        obj.GasSectionType = "NONE"
        obj.ChannelSectionType = ElementFluid1D.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