Menu

Pipe length - access from Python

2024-01-07
2024-01-07
  • Serhii Krushnevych

    Hi!
    I tried to make calculations using a Python Script for the Pipeline segment with different lengths (sets by table).
    How is I can change the pipe segment length from the Python script (see attached screenshot)?
    I found "<comprimento>1</comprimento>" in the output of the next code:

    pipeline = Flowsheet.GetFlowsheetSimulationObject('PIPE-1')
    PipProf = pipeline.Profile.SaveData()
    

    but how is I can modify the "Comprimento" ("length") field?
    I dig to PipeProfile Class
    but can't understand how is the next steep.
    Thanks.

     
  • Serhii Krushnevych

    My resolution of the question:

    clr.AddReference("DWSIM.UnitOperations")
    from DWSIM.UnitOperations import UnitOperations
    
    #get refference to the pipeline primitive on the current Flowsheet
    pipe = Flowsheet.GetFlowsheetSimulationObject('PIPE-1')
    pipe = pipe.GetAsObject()
    
    ps = UnitOperations.Auxiliary.Pipe.PipeSection()
    #fill the pipeline Hydraulic profile
    ps.Indice = 1 # Segment index
    ps.Incrementos = 10 #Sections number (for result table rows)
    ps.Quantidade = 1 #Amount
    ps.DE = 150 / 25.4 # External diameter in in
    ps.DI = 140 / 25.4 # Internal diameter in in
    ps.TipoSegmento = "Straight Tube Section"
    ps.Material = "PVC"
    ps.Comprimento = 50 #Length of the section
    ps.PipeWallRugosity = 1.5E-6 #Rugosity
    ps.Elevacao = 2 #Elevation difference in meters
    
    pipe.Profile.Sections.Clear()
    pipe.Profile.Sections.Add(1,ps)
    
     
    👍
    1

    Last edit: Serhii Krushnevych 2024-01-07
Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.