Menu

Taking input from scripting variables in DWSIM

The One
2019-05-06
2019-05-06
  • The One

    The One - 2019-05-06

    Hi, I want to take a list as input through scripting variables in user model-python script. I am unable to do so. Can anyone help out?

     
  • Daniel Medeiros

    Daniel Medeiros - 2019-05-06

    Can you give more details? I didn't understand how you model would work.

     
  • The One

    The One - 2019-05-06

    Thank you Daniel for replying
    I want to create a batch reactor in DWSIM through User models-Python script. I will be taking input through scripting variables input section. I wanted to input a list of stoichometries of compounds involved in reaction. However, i am unable to input a list in the scripting varible section. The error that pops up is, "Conversion from type string to type double is not valid". I used the syntax [1,1] to input the stoichometries. Moreover, when i use syntax (2,2) for list in input column of scripting variables section, the software changes the variable value to -22. Can you explain how to input list in scripting variables section? I have attached the file. Here the variable i want to input as list is stoic.
    Thank you.

     
  • Daniel Medeiros

    Daniel Medeiros - 2019-05-06

    I see. The script unit only accepts single strings and numbers as input, but you could try [2, 2] and see if it works.

     
  • Daniel Medeiros

    Daniel Medeiros - 2019-05-06

    You also need to add the list as a STRING variable, not double.

     
  • The One

    The One - 2019-05-06

    I got error when used [2,2]: ,"Conversion from type string to type double is not valid"

     
  • The One

    The One - 2019-05-06

    I did not understand what you meant by adding list as string variable and not double. Can u tell the syntax to add list as string variable?

     
  • Daniel Medeiros

    Daniel Medeiros - 2019-05-06

    If you enter

    And use this script

    You should get

    The trick is to use eval to convert the string to a python list.

     
  • The One

    The One - 2019-05-06

    Thank you Daniel. This solved my problem.