Menu

Re-specifying multiple inputs

2021-11-22
2021-11-28
  • Daniel Gapes

    Daniel Gapes - 2021-11-22

    Hi
    I am testing a range of different compressor configurations, and would like to change the outlet conditions of multiple compressors, all to the same values. I have used the Input and Specification blocks to link outputs to inputs, but this seems to only work intermittantly. That is, when I modify a pressure input, the value doesnt always "spread" completely through to each of the compressors that I have linked. Eventually, after re-running the simulation or random changing of inputs and returning them to their original values, the correct values are arrived at. But this loses the point of what I am trying to achieve.
    I note a comment similar to this (maybe?) in https://sourceforge.net/p/dwsim/discussion/844529/thread/49c6d83e0d/#48dc
    Is there an alternative approach to deploy a single value across multiple unit operation inputs?
    Thanks

     
  • Luca Finardi

    Luca Finardi - 2021-11-23

    Hi,
    attached is my exercise.
    The common outlet pressure is specified in a spreadsheet's cell and a simple script is executed before the solver starts to set the outlet pressure to all compressors.
    It seems to work.

    Hope this helps.

    Luca

     
  • Daniel Gapes

    Daniel Gapes - 2021-11-24

    Brilliant, thanks so much.
    As I am new to scripting, I can make the pressure values work in my code as you have shown. Is there a location to find all of the input object names for the different units? For example, if I wanted to change a cooler temperature, what do I code? I tried
    Flowsheet.GetFlowsheetSimulationObject(oname).TOut = Tout_, but came up with error around TOut not being specified for the Cooler object.

    Similarly for material streams, is there a place I can look to see how temperature, pressure, flow etc are coded for inputs?

    Finally, there seems to be a sequence where I have to run the Python Script, prior to solving the flowsheet. Is there an alternative where this becomes automatic?
    Thanks

     
  • Luca Finardi

    Luca Finardi - 2021-11-24

    I suggest you to try the "Insert Snippet" feature in the DWSIM Script Manager tab. From there you can have the code lines to access all properties of both equipment and streams.

    Once created, a script can be automatically executed by linking it to specific event, such as before a component is calculated or the flowsheet's solver is started. For instance, in the example I uploaded, Script1 is linked to the solver start, i.e. every time you press the Solve Flowsheet button (or press F5) the Script1 is executed (so that the compressors' pout is automatically updated) and then the flowsheet is solved.
    Hope this could help.
    Luca

     
  • Daniel Gapes

    Daniel Gapes - 2021-11-28

    Once again, thanks so much for your response, exactly what I needed

     

Log in to post a comment.