def accept(self): A = self.form.sa.value() R = self.form.aspect.value() beta = self.form.yard_angle.value() * pi / 180 alpha = self.form.boom_angle.value() * pi / 180 U = self.form.throat_spacing.value() / 1000 Ns = self.form.square_panels.value() Nf = self.form.fan_panels.value() w, q, LB, theta, actual = sail_params(A, R, alpha, beta, Nf, U) self.form.actual.setText('{:.1f}'.format(actual)) self.form.LB.setText('{:.1f}'.format(LB)) part = ActiveDocument.addObject('App::Part', 'Part') ActiveDocument.Tip = part part.Label = 'Sail' activeView().setActiveObject('part', part) outline = [] battens = [] P = q / Ns for ii in range(Ns): p = ii * P points = [Vector(0, 0, p), Vector(w, 0, p + LB * sin(alpha))] if ii == 0: outline.extend(points) else: battens.append(points) outline.append(Vector(w, 0, q + LB*sin(alpha))) phi = alpha h_ii = q for ii in range(Nf + 1): batten_points = [Vector(0, 0, h_ii), Vector(LB * cos(phi), 0, h_ii + LB * sin(phi))] if ii > 0: outline.append(batten_points[1]) if ii < Nf: battens.append(batten_points) h_ii += U phi += theta for ii in range(Nf + 1): outline.append(Vector(0, 0, h_ii)) h_ii -= U outline.append(Vector(0, 0, 0)) o_w = makeWire(outline) o_w.Label = 'Outline' part.addObject(o_w) for ii, batten in enumerate(battens): b_w = makeWire(batten) b_w.Label = "Batten {}".format(ii) part.addObject(b_w) c = o_w.Shape.CenterOfMass c = makePoint(c[0], c[1], c[2], (0, 1, 0)) c.Label = 'CentreOfEffort' part.addObject(c)
def makeW(): edges = frameCmd.edges() if len(edges) > 1: # patch for FC 0.17: first = edges[0] points = list() while len(edges) > 1: points.append(frameCmd.intersectionCLines(edges.pop(0), edges[0])) if edges[0].valueAt(0) == points[-1]: points.append(edges[0].valueAt(edges[0].LastParameter)) else: points.append(edges[0].valueAt(0)) if first.valueAt(0) == points[0]: points.insert(0, first.valueAt(first.LastParameter)) else: points.insert(0, first.valueAt(0)) # END from Draft import makeWire try: p = makeWire(points) except: FreeCAD.Console.PrintError('Missing intersection\n') return None p.Label = 'Path' drawAsCenterLine(p) return p elif FreeCADGui.Selection.getSelection(): obj = FreeCADGui.Selection.getSelection()[0] if hasattr(obj, 'Shape') and type(obj.Shape) == Part.Wire: drawAsCenterLine(obj) return obj else: return None
def makeW(): edges=fCmd.edges() if len(edges)>1: first=edges[0] last=edges[-1] points=list() while len(edges)>1: points.append(fCmd.intersectionCLines(edges.pop(0),edges[0])) delta1=(first.valueAt(0)-points[0]).Length delta2=(first.valueAt(first.LastParameter)-points[0]).Length if delta1>delta2: points.insert(0,first.valueAt(0)) else: points.insert(0,first.valueAt(first.LastParameter)) delta1=(last.valueAt(0)-points[0]).Length delta2=(last.valueAt(last.LastParameter)-points[0]).Length if delta1>delta2: points.append(last.valueAt(0)) else: points.append(last.valueAt(last.LastParameter)) from Draft import makeWire try: p=makeWire(points) except: FreeCAD.Console.PrintError('Missing intersection\n') return None p.Label='Path' drawAsCenterLine(p) return p elif FreeCADGui.Selection.getSelection(): obj=FreeCADGui.Selection.getSelection()[0] if hasattr(obj,'Shape') and type(obj.Shape)==Part.Wire: drawAsCenterLine(obj) return obj else: return None
def makeW(): edges = frameCmd.edges() if len(edges) > 1: # patch for FC 0.17: first = edges[0] points = list() while len(edges) > 1: points.append(frameCmd.intersectionCLines(edges.pop(0), edges[0])) if edges[0].valueAt(0) == points[-1]: points.append(edges[0].valueAt(edges[0].LastParameter)) else: points.append(edges[0].valueAt(0)) if first.valueAt(0) == points[0]: points.insert(0, first.valueAt(first.LastParameter)) else: points.insert(0, first.valueAt(0)) # END #P0=edges[0].valueAt(0) #P1=edges[0].valueAt(edges[0].LastParameter) #Pint=frameCmd.intersectionCLines(edges[0],edges[1]) #d0=Pint-P0 #d1=Pint-P1 #if d1.Length>d0.Length: #P0=P1 #eds=list() #for i in range(len(edges)-1): #P1=frameCmd.intersectionCLines(edges[i],edges[i+1]) #eds.append(Part.Edge(Part.Line(P0,P1))) #P0=P1 #P1=edges[-1].valueAt(edges[-1].LastParameter) #P2=edges[-1].valueAt(0) #d1=P1-P0 #d2=P2-P0 #if d1.Length<d2.Length: #P1=P2 #eds.append(Part.Edge(Part.Line(P0,P1))) #for e in eds: #print(type(e)) #w=Part.Wire(eds) #points=[e.valueAt(0) for e in w.Edges] #last=e.Edges[-1] #points.append(last.valueAt(last.LastParameter)) from Draft import makeWire try: p = makeWire(points) except: FreeCAD.Console.PrintError('Missing intersection\n') return None p.Label = 'Path' drawAsCenterLine(p) return p else: FreeCAD.Console.PrintError('Not enough edges/n') return None
def process(doc,filename): # The common airfoil dat format has many flavors # This code should work with almost every dialect # Regex to identify data rows and throw away unused metadata regex = re.compile(r'^\s*(?P<xval>(\-|\d*)\.\d+(E\-?\d+)?)\,?\s*(?P<yval>\-?\s*\d*\.\d+(E\-?\d+)?)\s*$') afile = pythonopen(filename,'r') # read the airfoil name which is always at the first line airfoilname = afile.readline().strip() coords=[] upside=True last_x=None # Collect the data for the upper and the lower side seperately if possible for lin in afile: curdat = regex.match(lin) if curdat != None: x = float(curdat.group("xval")) y = float(curdat.group("yval")) # the normal processing coords.append(Vector(x,y,0)) # End of if curdat != None # End of for lin in file afile.close() if len(coords) < 3: print 'Did not find enough coordinates\n' return # sometimes coords are divided in upper an lower side # so that x-coordinate begin new from leading or trailing edge # check for start coordinates in the middle of list if coords[0:-1].count(coords[0]) > 1: flippoint = coords.index(coords[0],1) upper = coords[0:flippoint] lower = coords[flippoint+1:] lower.reverse() for i in lower: upper.append(i) coords = upper # do we use the parametric Draft Wire? if useDraftWire: obj = makeWire ( coords, True ) #obj.label = airfoilname else: # alternate solution, uses common Part Faces lines = [] first_v = None last_v = None for v in coords: if first_v == None: first_v = v # End of if first_v == None # Line between v and last_v if they're not equal if (last_v != None) and (last_v != v): lines.append(Part.makeLine(last_v, v)) # End of if (last_v != None) and (last_v != v) # The new last_v last_v = v # End of for v in upper # close the wire if needed if last_v != first_v: lines.append(Part.makeLine(last_v, first_v)) # End of if last_v != first_v wire = Part.Wire(lines) face = Part.Face(wire) obj = FreeCAD.ActiveDocument.addObject('Part::Feature',airfoilname) obj.Shape = face doc.recompute()
def setup(doc=None, solvertype="ccxtools"): # setup model if doc is None: doc = init_doc() p1 = FreeCAD.Vector(0, 0, 50) p2 = FreeCAD.Vector(0, 0, -50) p3 = FreeCAD.Vector(0, 0, -4300) p4 = FreeCAD.Vector(4950, 0, -4300) p5 = FreeCAD.Vector(5000, 0, -4300) p6 = FreeCAD.Vector(8535.53, 0, -7835.53) p7 = FreeCAD.Vector(8569.88, 0, -7870.88) p8 = FreeCAD.Vector(12105.41, 0, -11406.41) p9 = FreeCAD.Vector(12140.76, 0, -11441.76) p10 = FreeCAD.Vector(13908.53, 0, -13209.53) p11 = FreeCAD.Vector(13943.88, 0, -13244.88) p12 = FreeCAD.Vector(15046.97, 0, -14347.97) p13 = FreeCAD.Vector(15046.97, 0, -7947.97) p14 = FreeCAD.Vector(15046.97, 0, -7847.97) p15 = FreeCAD.Vector(0, 0, 0) p16 = FreeCAD.Vector(0, 0, -2175) p17 = FreeCAD.Vector(2475, 0, -4300) p18 = FreeCAD.Vector(4975, 0, -4300) p19 = FreeCAD.Vector(6767.765, 0, -6067.765) p20 = FreeCAD.Vector(8552.705, 0, -7853.205) p21 = FreeCAD.Vector(10337.645, 0, -9638.645) p22 = FreeCAD.Vector(12123.085, 0, -11424.085) p23 = FreeCAD.Vector(13024.645, 0, -12325.645) p24 = FreeCAD.Vector(13926.205, 0, -13227.205) p25 = FreeCAD.Vector(14495.425, 0, -13796.425) p26 = FreeCAD.Vector(15046.97, 0, -11147.97) p27 = FreeCAD.Vector(15046.97, 0, -7897.97) points = [ p1, p2, p3, p4, p5, p6, p7, p8, p9, p10, p11, p12, p13, p14, p15, p16, p17, p18, p19, p20, p21, p22, p23, p24, p25, p26, p27 ] from Draft import makeWire line = makeWire(points, closed=False, face=False, support=None) doc.recompute() if FreeCAD.GuiUp: import FreeCADGui FreeCADGui.ActiveDocument.activeView().viewAxonometric() FreeCADGui.SendMsgToActiveView("ViewFit") # analysis analysis = ObjectsFem.makeAnalysis(doc, "Analysis") # solver if solvertype == "calculix": solver_object = analysis.addObject( ObjectsFem.makeSolverCalculix(doc, "SolverCalculiX"))[0] elif solvertype == "ccxtools": solver_object = analysis.addObject( ObjectsFem.makeSolverCalculixCcxTools( doc, "CalculiXccxTools") # CalculiX )[0] solver_object.WorkingDir = u"" if solvertype == "calculix" or solvertype == "ccxtools": solver_object.AnalysisType = "thermomech" solver_object.GeometricalNonlinearity = "linear" solver_object.ThermoMechSteadyState = True solver_object.MatrixSolverType = "default" solver_object.IterationsThermoMechMaximum = 2000 solver_object.IterationsControlParameterTimeUse = False # material material_object = analysis.addObject( ObjectsFem.makeMaterialFluid(doc, "FluidMaterial"))[0] mat = material_object.Material mat["Name"] = "Water" mat["Density"] = "998 kg/m^3" mat["SpecificHeat"] = "4.182 J/kg/K" mat["DynamicViscosity"] = "1.003e-3 kg/m/s" mat["VolumetricThermalExpansionCoefficient"] = "2.07e-4 m/m/K" mat["ThermalConductivity"] = "0.591 W/m/K" material_object.Material = mat inlet = analysis.addObject( ObjectsFem.makeElementFluid1D(doc, "ElementFluid1D"))[0] inlet.SectionType = "Liquid" inlet.LiquidSectionType = "PIPE INLET" inlet.InletPressure = 0.1 inlet.References = [(line, "Edge1")] entrance = analysis.addObject( ObjectsFem.makeElementFluid1D(doc, "ElementFluid1D"))[0] entrance.SectionType = "Liquid" entrance.LiquidSectionType = "PIPE ENTRANCE" entrance.EntrancePipeArea = 31416.00 entrance.EntranceArea = 25133.00 entrance.References = [(line, "Edge2")] manning1 = analysis.addObject( ObjectsFem.makeElementFluid1D(doc, "ElementFluid1D"))[0] manning1.SectionType = "Liquid" manning1.LiquidSectionType = "PIPE MANNING" manning1.ManningArea = 31416 manning1.ManningRadius = 50 manning1.ManningCoefficient = 0.002 manning1.References = [(line, "Edge3"), (line, "Edge5")] bend = analysis.addObject( ObjectsFem.makeElementFluid1D(doc, "ElementFluid1D"))[0] bend.SectionType = "Liquid" bend.LiquidSectionType = "PIPE BEND" bend.BendPipeArea = 31416 bend.BendRadiusDiameter = 1.5 bend.BendAngle = 45 bend.BendLossCoefficient = 0.4 bend.References = [(line, "Edge4")] enlargement1 = analysis.addObject( ObjectsFem.makeElementFluid1D(doc, "ElementFluid1D"))[0] enlargement1.SectionType = "Liquid" enlargement1.LiquidSectionType = "PIPE ENLARGEMENT" enlargement1.EnlargeArea1 = 31416.00 enlargement1.EnlargeArea2 = 70686.00 enlargement1.References = [(line, "Edge6")] manning2 = analysis.addObject( ObjectsFem.makeElementFluid1D(doc, "ElementFluid1D"))[0] manning2.SectionType = "Liquid" manning2.LiquidSectionType = "PIPE MANNING" manning2.ManningArea = 70686.00 manning2.ManningRadius = 75 manning2.ManningCoefficient = 0.002 manning2.References = [(line, "Edge7")] contraction = analysis.addObject( ObjectsFem.makeElementFluid1D(doc, "ElementFluid1D"))[0] contraction.SectionType = "Liquid" contraction.LiquidSectionType = "PIPE CONTRACTION" contraction.ContractArea1 = 70686 contraction.ContractArea2 = 17671 contraction.References = [(line, "Edge8")] manning3 = analysis.addObject( ObjectsFem.makeElementFluid1D(doc, "ElementFluid1D"))[0] manning3.SectionType = "Liquid" manning3.LiquidSectionType = "PIPE MANNING" manning3.ManningArea = 17671.00 manning3.ManningRadius = 37.5 manning3.ManningCoefficient = 0.002 manning3.References = [(line, "Edge11"), (line, "Edge9")] gate_valve = analysis.addObject( ObjectsFem.makeElementFluid1D(doc, "ElementFluid1D"))[0] gate_valve.SectionType = "Liquid" gate_valve.LiquidSectionType = "PIPE GATE VALVE" gate_valve.GateValvePipeArea = 17671 gate_valve.GateValveClosingCoeff = 0.5 gate_valve.References = [(line, "Edge10")] enlargement2 = analysis.addObject( ObjectsFem.makeElementFluid1D(doc, "ElementFluid1D"))[0] enlargement2.SectionType = "Liquid" enlargement2.LiquidSectionType = "PIPE ENLARGEMENT" enlargement2.EnlargeArea1 = 17671 enlargement2.EnlargeArea2 = 1e12 enlargement2.References = [(line, "Edge12")] outlet = analysis.addObject( ObjectsFem.makeElementFluid1D(doc, "ElementFluid1D"))[0] outlet.SectionType = "Liquid" outlet.LiquidSectionType = "PIPE OUTLET" outlet.OutletPressure = 0.1 outlet.References = [(line, "Edge13")] self_weight = analysis.addObject( ObjectsFem.makeConstraintSelfWeight(doc, "ConstraintSelfWeight"))[0] self_weight.Gravity_x = 0.0 self_weight.Gravity_y = 0.0 self_weight.Gravity_z = -1.0 # mesh from .meshes.mesh_thermomech_flow1d_seg3 import create_nodes, create_elements fem_mesh = Fem.FemMesh() control = create_nodes(fem_mesh) if not control: FreeCAD.Console.PrintError("Error on creating nodes.\n") control = create_elements(fem_mesh) if not control: FreeCAD.Console.PrintError("Error on creating elements.\n") femmesh_obj = analysis.addObject( doc.addObject("Fem::FemMeshObject", mesh_name))[0] femmesh_obj.FemMesh = fem_mesh doc.recompute() return doc
def process(doc, filename): # The common airfoil dat format has many flavors # This code should work with almost every dialect # Regex to identify data rows and throw away unused metadata regex = re.compile( r'^\s*(?P<xval>(\-|\d*)\.\d+(E\-?\d+)?)\,?\s*(?P<yval>\-?\s*\d*\.\d+(E\-?\d+)?)\s*$' ) afile = pythonopen(filename, 'r') # read the airfoil name which is always at the first line airfoilname = afile.readline().strip() coords = [] upside = True last_x = None # Collect the data for the upper and the lower side seperately if possible for lin in afile: curdat = regex.match(lin) if curdat != None: x = float(curdat.group("xval")) y = float(curdat.group("yval")) # the normal processing coords.append(Vector(x, y, 0)) # End of if curdat != None # End of for lin in file afile.close() if len(coords) < 3: print('Did not find enough coordinates\n') return # sometimes coords are divided in upper an lower side # so that x-coordinate begin new from leading or trailing edge # check for start coordinates in the middle of list if coords[0:-1].count(coords[0]) > 1: flippoint = coords.index(coords[0], 1) upper = coords[0:flippoint] lower = coords[flippoint + 1:] lower.reverse() for i in lower: upper.append(i) coords = upper # do we use the parametric Draft Wire? if useDraftWire: obj = makeWire(coords, True) #obj.label = airfoilname else: # alternate solution, uses common Part Faces lines = [] first_v = None last_v = None for v in coords: if first_v == None: first_v = v # End of if first_v == None # Line between v and last_v if they're not equal if (last_v != None) and (last_v != v): lines.append(Part.makeLine(last_v, v)) # End of if (last_v != None) and (last_v != v) # The new last_v last_v = v # End of for v in upper # close the wire if needed if last_v != first_v: lines.append(Part.makeLine(last_v, first_v)) # End of if last_v != first_v wire = Part.Wire(lines) face = Part.Face(wire) obj = FreeCAD.ActiveDocument.addObject('Part::Feature', airfoilname) obj.Shape = face doc.recompute()
def setup(doc=None, solvertype="ccxtools"): # init FreeCAD document if doc is None: doc = init_doc() # explanation object # just keep the following line and change text string in get_explanation method manager.add_explanation_obj(doc, get_explanation(manager.get_header(get_information()))) # geometric objects p1 = vec(0, 0, 50) p2 = vec(0, 0, -50) p3 = vec(0, 0, -4300) p4 = vec(4950, 0, -4300) p5 = vec(5000, 0, -4300) p6 = vec(8535.53, 0, -7835.53) p7 = vec(8569.88, 0, -7870.88) p8 = vec(12105.41, 0, -11406.41) p9 = vec(12140.76, 0, -11441.76) p10 = vec(13908.53, 0, -13209.53) p11 = vec(13943.88, 0, -13244.88) p12 = vec(15046.97, 0, -14347.97) p13 = vec(15046.97, 0, -7947.97) p14 = vec(15046.97, 0, -7847.97) p15 = vec(0, 0, 0) p16 = vec(0, 0, -2175) p17 = vec(2475, 0, -4300) p18 = vec(4975, 0, -4300) p19 = vec(6767.765, 0, -6067.765) p20 = vec(8552.705, 0, -7853.205) p21 = vec(10337.645, 0, -9638.645) p22 = vec(12123.085, 0, -11424.085) p23 = vec(13024.645, 0, -12325.645) p24 = vec(13926.205, 0, -13227.205) p25 = vec(14495.425, 0, -13796.425) p26 = vec(15046.97, 0, -11147.97) p27 = vec(15046.97, 0, -7897.97) points = [ p1, p2, p3, p4, p5, p6, p7, p8, p9, p10, p11, p12, p13, p14, p15, p16, p17, p18, p19, p20, p21, p22, p23, p24, p25, p26, p27 ] geom_obj = makeWire( points, closed=False, face=False, support=None ) doc.recompute() if FreeCAD.GuiUp: geom_obj.ViewObject.Document.activeView().viewAxonometric() geom_obj.ViewObject.Document.activeView().fitAll() # analysis analysis = ObjectsFem.makeAnalysis(doc, "Analysis") # solver if solvertype == "calculix": solver_obj = analysis.addObject( ObjectsFem.makeSolverCalculix(doc, "SolverCalculiX") )[0] elif solvertype == "ccxtools": solver_obj = ObjectsFem.makeSolverCalculixCcxTools(doc, "CalculiXccxTools") solver_obj.WorkingDir = u"" else: FreeCAD.Console.PrintWarning( "Not known or not supported solver type: {}. " "No solver object was created.\n".format(solvertype) ) if solvertype == "calculix" or solvertype == "ccxtools": solver_obj.SplitInputWriter = False solver_obj.AnalysisType = "thermomech" solver_obj.GeometricalNonlinearity = "linear" solver_obj.ThermoMechSteadyState = True solver_obj.MatrixSolverType = "default" solver_obj.IterationsThermoMechMaximum = 2000 solver_obj.IterationsControlParameterTimeUse = False analysis.addObject(solver_obj) # material material_obj = ObjectsFem.makeMaterialFluid(doc, "FluidMaterial") mat = material_obj.Material mat["Name"] = "Water" mat["Density"] = "998 kg/m^3" mat["SpecificHeat"] = "4.182 J/kg/K" mat["DynamicViscosity"] = "1.003e-3 kg/m/s" mat["VolumetricThermalExpansionCoefficient"] = "2.07e-4 m/m/K" mat["ThermalConductivity"] = "0.591 W/m/K" material_obj.Material = mat analysis.addObject(material_obj) inlet = ObjectsFem.makeElementFluid1D(doc, "ElementFluid1D") inlet.SectionType = "Liquid" inlet.LiquidSectionType = "PIPE INLET" inlet.InletPressure = 0.1 inlet.References = [(geom_obj, "Edge1")] analysis.addObject(inlet) entrance = ObjectsFem.makeElementFluid1D(doc, "ElementFluid1D") entrance.SectionType = "Liquid" entrance.LiquidSectionType = "PIPE ENTRANCE" entrance.EntrancePipeArea = 31416.00 entrance.EntranceArea = 25133.00 entrance.References = [(geom_obj, "Edge2")] analysis.addObject(entrance) manning1 = ObjectsFem.makeElementFluid1D(doc, "ElementFluid1D") manning1.SectionType = "Liquid" manning1.LiquidSectionType = "PIPE MANNING" manning1.ManningArea = 31416 manning1.ManningRadius = 50 manning1.ManningCoefficient = 0.002 manning1.References = [(geom_obj, "Edge3"), (geom_obj, "Edge5")] analysis.addObject(manning1) bend = ObjectsFem.makeElementFluid1D(doc, "ElementFluid1D") bend.SectionType = "Liquid" bend.LiquidSectionType = "PIPE BEND" bend.BendPipeArea = 31416 bend.BendRadiusDiameter = 1.5 bend.BendAngle = 45 bend.BendLossCoefficient = 0.4 bend.References = [(geom_obj, "Edge4")] analysis.addObject(bend) enlargement1 = ObjectsFem.makeElementFluid1D(doc, "ElementFluid1D") enlargement1.SectionType = "Liquid" enlargement1.LiquidSectionType = "PIPE ENLARGEMENT" enlargement1.EnlargeArea1 = 31416.00 enlargement1.EnlargeArea2 = 70686.00 enlargement1.References = [(geom_obj, "Edge6")] analysis.addObject(enlargement1) manning2 = ObjectsFem.makeElementFluid1D(doc, "ElementFluid1D") manning2.SectionType = "Liquid" manning2.LiquidSectionType = "PIPE MANNING" manning2.ManningArea = 70686.00 manning2.ManningRadius = 75 manning2.ManningCoefficient = 0.002 manning2.References = [(geom_obj, "Edge7")] analysis.addObject(manning2) contraction = ObjectsFem.makeElementFluid1D(doc, "ElementFluid1D") contraction.SectionType = "Liquid" contraction.LiquidSectionType = "PIPE CONTRACTION" contraction.ContractArea1 = 70686 contraction.ContractArea2 = 17671 contraction.References = [(geom_obj, "Edge8")] analysis.addObject(contraction) manning3 = ObjectsFem.makeElementFluid1D(doc, "ElementFluid1D") manning3.SectionType = "Liquid" manning3.LiquidSectionType = "PIPE MANNING" manning3.ManningArea = 17671.00 manning3.ManningRadius = 37.5 manning3.ManningCoefficient = 0.002 manning3.References = [(geom_obj, "Edge11"), (geom_obj, "Edge9")] analysis.addObject(manning3) gate_valve = ObjectsFem.makeElementFluid1D(doc, "ElementFluid1D") gate_valve.SectionType = "Liquid" gate_valve.LiquidSectionType = "PIPE GATE VALVE" gate_valve.GateValvePipeArea = 17671 gate_valve.GateValveClosingCoeff = 0.5 gate_valve.References = [(geom_obj, "Edge10")] analysis.addObject(gate_valve) enlargement2 = ObjectsFem.makeElementFluid1D(doc, "ElementFluid1D") enlargement2.SectionType = "Liquid" enlargement2.LiquidSectionType = "PIPE ENLARGEMENT" enlargement2.EnlargeArea1 = 17671 enlargement2.EnlargeArea2 = 1e12 enlargement2.References = [(geom_obj, "Edge12")] analysis.addObject(enlargement2) outlet = ObjectsFem.makeElementFluid1D(doc, "ElementFluid1D") outlet.SectionType = "Liquid" outlet.LiquidSectionType = "PIPE OUTLET" outlet.OutletPressure = 0.1 outlet.References = [(geom_obj, "Edge13")] analysis.addObject(outlet) # self_weight_constraint self_weight = ObjectsFem.makeConstraintSelfWeight(doc, "ConstraintSelfWeight") self_weight.Gravity_x = 0.0 self_weight.Gravity_y = 0.0 self_weight.Gravity_z = -1.0 analysis.addObject(self_weight) # mesh from .meshes.mesh_thermomech_flow1d_seg3 import create_nodes, create_elements fem_mesh = Fem.FemMesh() control = create_nodes(fem_mesh) if not control: FreeCAD.Console.PrintError("Error on creating nodes.\n") control = create_elements(fem_mesh) if not control: FreeCAD.Console.PrintError("Error on creating elements.\n") femmesh_obj = analysis.addObject(ObjectsFem.makeMeshGmsh(doc, get_meshname()))[0] femmesh_obj.FemMesh = fem_mesh femmesh_obj.Part = geom_obj femmesh_obj.SecondOrderLinear = False doc.recompute() return doc