Command Line Mode

From DWSIM - Open Source Chemical Process Simulator
Jump to navigation Jump to search

Running DWSIM in Command Line Mode

If you want to optimize your simulation using external software, you can run DWSIM in command line mode. The process itself is very simple: DWSIM opens the simulation file without showing the interface, and any changes you want to do to any variable in the simulation are input in a XML file. Also, if you want to read variables after the calculation, you can specify them in the input file. DWSIM then writes another XML file with the values and units of the variables you defined.

To run DWSIM in command line mode, you’ll need:

  • A completely defined and error-free simulation file,
  • A XML file which will be used as input to define parameters and write values to properties before running the simulation.

Command line arguments

Argument

Description

-commandline

Runs DWSIM in command line mode.

-nosplash

Prevents the splash screen from showing.

-savechanges

Save changes to the simulation file after running.

-show <VALUE>

Define if a window is shown to display calculation details. <VALUE> is 0 to hide, 1 to show. If omitted DWSIM will run without showing the window.

-locale <VALUE>

Changes the locale settings of the current run. Also affects how DWSIM manages decimal and thousand separators. <VALUE> is the locale string and currently can be “en-US” (English - USA), “pt-BR” (Brazilian Portuguese) or “es” (Spanish). If omitted, DWSIM will use the current locale defined in previous normal (graphical interface) runs.

-simfile <VALUE>

Defines the simulation file to read. <VALUE> is the relative (to the current directory) or absolute path of the .dwsim file, between quotes.

-input <VALUE>

Defines the input XML file. <VALUE> is the relative (to the current directory) or absolute path of the file, between quotes.

-output <VALUE>

Defines the output XML file. <VALUE> is the relative (to the current directory) or absolute path of the file, between quotes.

The example below shows how to run DWSIM in command line mode from a command line window (or a batch file). It assumes that all the necessary files are in the same path, which is also the path of DWSIM executable file.

dwsim.exe -commandline -nosplash -show 1 -locale "en-US" -simfile "cavett15.dwsim" -input "input2.xml" -output "results.xml"

This command tells DWSIM to run in command line mode, not showing the splash screen, using English (USA) as the locale. The simulation file is “cavett15.dwsim” and the input and output XML files are “input2.xml” and “results.xml” respectively. When you execute this command, DWSIM will show the following window prior to writing to the output XML file:

File:Cl01.png

When this window closes, the simulation has been run and you can open the output XML file to view the results.

Input XML file structure

The basic structure of an input XML file is shown below:

<DWSIMXMLFile>
 <Configuration>
   <UnitsSystem Mode="Default" Name="" />
   <Simulation NumberOfRuns="1" FormattedOutput="Yes" />
   <PureCompoundProperties>
     <Compound Name="C7+">
       <Property Name="Molar_Weight" Value="210.00" />
       <Property Name="Critical_Temperature" Value="702.800" Unit="K" />
       <Property Name="Critical_Pressure" Value="21.70" Unit="atm" />
       <Property Name="Acentric_Factor" Value="0.6775" />
     </Compound>
   </PureCompoundProperties>
   <PropertyPackages>
     <PropertyPackage Name="PP_1">
    <Parameter Name="PP_FLASHALGORITHM" Value="3" />
       <InteractionParameters>
         <InteractionParameter Comp1="C7+" Comp2="Carbon Dioxide" kij="0.12" />
         <InteractionParameter Comp1="C7+" Comp2="Nitrogen" kij="0.12" />
         <InteractionParameter Comp1="C7+" Comp2="Hydrogen Sulfide" kij="0.05" />
       </InteractionParameters>
     </PropertyPackage>
   </PropertyPackages>      
</Configuration>
 <InputParameters>
   <SimulationObjects>
     <Object Name="MAT-000">
         <Property ID="PROP_MS_0" Value="100" />
         <Property ID="PROP_MS_1" Value="6000" />
     </Object>
   </SimulationObjects>
 </InputParameters>
 <OutputParameters>
   <SimulationObjects>
     <Object Name="VALV-000">
       <Property ID="PROP_VA_3" Name="" Value="" Unit=""/> 
     </Object>
     <Object Name="MAT-001">
       <Property ID="PROP_MS_0" Name="" Value="" Unit=""/> 
       <Property ID="PROP_MS_7" Name="" Value="" Unit=""/> 
     </Object>
     <Object Name="MAT-000">
       <Property ID="PROP_MS_7" Name="" Value="" Unit=""/> 
     </Object>
   </SimulationObjects>
 </OutputParameters>
</DWSIMXMLFile>


Section/Node

Attribute

Description

Configuration

In the Configuration section you can define the system of units to be used, number of flowsheet runs and change pure compound and Property Package parameters.

UnitsSystem

Mode

“Default” uses the system of units defined in the simulation, otherwise you can enter “Custom” to use another.

UnitsSystem

Name

If you decided to use another system, this is where you enter its name. The system’s name you enter here must be present in the simulation, of course.

Simulation

NumberOfRuns

Defines how many runs DWSIM will execute before outputting any value to the XML file.

Simulation

FormattedOutput

Defines if the calculated values will be written to the output XML file using the simulation number format or not.

PureCompoundProperties/

Compound

Name

Name (String ID) of the compound whose properties will be changed/updated. The string ID of a compound can be found in the Pure Compound Properties Utility, between brackets in the compound selector combo box.

PureCompoundProperties/

Compound/

Property

Name

Name (String ID) of the property that will be changed/updated for the compound indicated in the parent node.

PureCompoundProperties/

Compound/

Property

Value

Value of the property to be changed/updated.

PureCompoundProperties

Compound

Property

Unit

Unit of the property to be changed/updated.

PropertyPackages/

PropertyPackage

Name

Name (User-defined string ID) of the Property Package whose properties will be changed/updated.

PropertyPackages/

PropertyPackage/

Parameter

Name

ID of the Property Package parameter to be changed/updated.

PropertyPackages/

PropertyPackage/

Parameter

Value

Value of the Property Package parameter to be changed/updated.

PropertyPackages/

PropertyPackage/

InteractionParameters/

InteractionParameter

Comp1

String ID of compound 1. The string ID of a compound can be found in the Pure Compound Properties Utility, between brackets in the compound selector combo box.

PropertyPackages/

PropertyPackage/

InteractionParameters/

InteractionParameter

Comp2

String ID of compound 2. The string ID of a compound can be found in the Pure Compound Properties Utility, between brackets in the compound selector combo box.

PropertyPackages/

PropertyPackage/

InteractionParameters/

InteractionParameter

kij, kji, A12, A21, alpha12

Value of the parameter to be updated, depends on the Property Package. See below for details.

''''InputParameters

In this section we define the objects which will be modified before the simulation is run.

Object

Name

Define the name of the object whose properties you will modify before running the simulation.

Property

ID

Self-explanatory. The ID of the property which will have its value modified.

Property

Value

The value of the property you defined with the ID attribute. Please note that this value works in conjunction with the units system you defined above (which can be either the one selected in the simulation or the one you indicated in this input XML file).

OutputParameters

In this section we define the objects whose properties will be read after the simulation is run.

Object

Name

Define the name of the object whose properties you will read after running the simulation.

Property

ID

Self-explanatory. The ID of the property which will have its value read.

Property

Name

The name of the property (localized according to the locale setting) will be written by DWSIM to the output file.

Property

Value

The value of the property will be written by DWSIM to the output file.

Property

Unit

The unit of the property will be written by DWSIM to the output file.

Property Package Configuration Parameters

Property ID

Default value

Allowed values

Description

PP_PHFILT

0.001

Any real number

PH Flash - Internal Loop Tolerance


PP_PSFILT

0.001

Any real number

PS Flash - Internal Loop Tolerance

PP_PHFELT

0.001

Any real number

PH Flash - External Loop Tolerance

PP_PSFELT

0.001

Any real number

PS Flash - External Loop Tolerance

PP_PHFMEI

50

Any integer number

PH Flash - Maximum External Iterations

PP_PSFMEI

50

Any integer number

PS Flash - Maximum External Iterations

PP_PHFMII

100

Any integer number

PH Flash - Maximum Internal Iterations

PP_PSFMII

100

Any integer number

PS Flash - Maximum Internal Iterations

PP_PTFMEI

100

Any integer number

PT/PV Flash - Maximum External Iterations

PP_PTFMII

100

Any integer number

PT/PV Flash - Maximum Internal Iterations

PP_PTFILT

0.001

Any real number

PT/PV Flash - Internal Loop Tolerance

PP_PTFELT

0.001

Any real number

PT/PV Flash - External Loop Tolerance

PP_RIG_BUB_DEW_FLASH_INIT

0

0, 1

Use Rigorous Bubble and Dew Points for TP Flash Vapor Fraction Initialization

PP_IDEAL_MIXRULE_LIQDENS

0

0, 1

Use Ideal Mixing Rule for Liquid Phase Density

PP_FLASHALGORITHM

2

0, 1, 2, 3, 4, 5, 6

Flash Algorithm (0 = Default, 1 = Inside-Out, 2 = Global Setting, 3 = Three-Phase Inside-Out, 4 = Two-Phase Gibbs Min., 5 = Three-Phase Gibbs Min., 6 = Three-Phase Hybrid NL/IO)

PP_USEEXPLIQDENS

0

0, 1

Use Experimental Liquid Density Data

PP_USEEXPLIQTHERMALCOND

1

0, 1

Use Experimental Liquid Thermal Conductivity Data

PP_USE_EOS_LIQDENS

0

0, 1

Use EOS for Liquid Density

PP_USE_EOS_VOLUME_SHIFT

0

0, 1

Use Peneloux Volume Translation correction

Pure Compound Parameter IDs

Parameter ID

Description

Molar_Weight

Molecular Weight

Critical_Temperature

Critical Temperature

Critical_Pressure

Critical Pressure

Critical_Volume

Critical Volume

Critical_Compressibility

Critical Compressibility

Acentric_Factor

Acentric Factor

Z_Rackett

Rackett Parameter

PR_Volume_Translation_Coefficient

Peng-Robinson Volume Translation Coefficient (si = ci/bi)

SRK_Volume_Translation_Coefficient

SRK Volume Translation Coefficient (si = ci/bi)

CS_Acentric_Factor

Chao-Seader Acentric Factor

CS_Solubility_Parameter

Chao-Seader Solubility Parameter

CS_Liquid_Molar_Volume

Chao-Seader Liquid Molar Volume

IG_Entropy_of_Formation_25C

Ideal Gas Entropy of Formation at 25 C

IG_Enthalpy_of_Formation_25C

Ideal Gas Enthalpy of Formation at 25 C

IG_Gibbs_Energy_of_Formation_25C

Ideal Gas Gibbs Energy of Formation at 25 C

Dipole_Moment

Dipole Moment

Vapor_Pressure_Constant_EqNo

Vapor Pressure Equation Number (ChemSep-like)

Vapor_Pressure_Constant_A

Vapor Pressure Equation A Constant

Vapor_Pressure_Constant_B

Vapor Pressure Equation B Constant

Vapor_Pressure_Constant_C

Vapor Pressure Equation C Constant

Vapor_Pressure_Constant_D

Vapor Pressure Equation D Constant

Vapor_Pressure_Constant_E

Vapor Pressure Equation E Constant

Ideal_Gas_Heat_Capacity_EqNo

Ideal Gas Heat Capacity Equation Number (ChemSep-like)

Ideal_Gas_Heat_Capacity_Const_A

Ideal Gas Heat Capacity Equation A Constant

Ideal_Gas_Heat_Capacity_Const_B

Ideal Gas Heat Capacity Equation B Constant

Ideal_Gas_Heat_Capacity_Const_C

Ideal Gas Heat Capacity Equation C Constant

Ideal_Gas_Heat_Capacity_Const_D

Ideal Gas Heat Capacity Equation D Constant

Ideal_Gas_Heat_Capacity_Const_E

Ideal Gas Heat Capacity Equation E Constant

''''Liquid_Viscosity_Const_EqNo

Liquid Viscosity Equation Number (ChemSep-like)

Liquid_Viscosity_Const_A

Liquid Viscosity Equation A Constant

Liquid_Viscosity_Const_B

Liquid Viscosity Equation B Constant

Liquid_Viscosity_Const_C

Liquid Viscosity Equation C Constant

Liquid_Viscosity_Const_D

Liquid Viscosity Equation D Constant

Liquid_Viscosity_Const_E

Liquid Viscosity Equation E Constant

Liquid_Density_Const_EqNo

Liquid Density Equation Number (ChemSep-like)

Liquid_Density_Const_A

Liquid Density Equation A Constant

Liquid_Density_Const_B

Liquid Density Equation B Constant

Liquid_Density_Const_C

Liquid Density Equation C Constant

Liquid_Density_Const_D

Liquid Density Equation D Constant

Liquid_Density_Const_E

Liquid Density Equation E Constant

Normal_Boiling_Point

Normal Boiling Point

HVapA

Heat of Vaporization Equation A Constant

HVapB

Heat of Vaporization Equation B Constant

HVapC

Heat of Vaporization Equation C Constant

HVapD

Heat of Vaporization Equation D Constant

UNIQUAC_R

UNIQUAC Model R Parameter

UNIQUAC_Q

UNIQUAC Model Q Parameter

Binary Interaction Parameter Table

Property Package

IP Set #1
IP Set #2
IP Set #3
IP Set #4
IP Set #5
IP Set #6
IP Set #7
IP Set #8

PC-SAFT

PC-SAFT kij
Not used
Not used
Not used
Not used
Not used
Not used
Not used

Peng-Robinson (PR)

PR kij
Not used
Not used
Not used
Not used
Not used
Not used
Not used

Soave-Redlich-Kwong (SRK)

SRK kij
Not used
Not used
Not used
Not used
Not used
Not used
Not used

Peng-Robinson-Stryjek-Vera 2 (PRSV2)

PRSV2-M kij
PRSV2-M kji
Not used
Not used
Not used
Not used
Not used
Not used

Peng-Robinson / Lee-Kesler (PR/LK)

PR kij
Not used
Not used
Not used
Not used
Not used
Not used
Not used

UNIFAC

PR kij
Not used
Not used
Not used
Not used
Not used
Not used
Not used

UNIFAC-LL

PR kij
Not used
Not used
Not used
Not used
Not used
Not used
Not used

Modified UNIFAC (Dortmund)

PR kij
Not used
Not used
Not used
Not used
Not used
Not used
Not used

NRTL

PR kij
NRTL A12 (cal/mol)
NRTL A21 (cal/mol)
NRTL Alpha
NRTL B12 (cal/mol.K)
NRTL B21 (cal/mol.K)
NRTL C12 (cal/mol.K²)
NRTL C21 (cal/mol.K²)

UNIQUAC

PR kij
UNIQUAC A12 (cal/mol)
UNIQUAC A21 (cal/mol)
UNIQUAC B12 (cal/mol.K)
UNIQUAC B21 (cal/mol.K)
UNIQUAC C12 (cal/mol.K²)
UNIQUAC C21 (cal/mol.K²)
Not used

Chao-Seader

Not used
Not used
Not used
Not used
Not used
Not used
Not used
Not used

Grayson-Streed

Not used
Not used
Not used
Not used
Not used
Not used
Not used
Not used

Lee-Kesler-Plöcker

LKP kij
Not used
Not used
Not used
Not used
Not used
Not used
Not used

Raoult's Law

Not used
Not used
Not used
Not used
Not used
Not used
Not used
Not used

COSMO-SAC (JCOSMO)

PR kij
Not used
Not used
Not used
Not used
Not used
Not used
Not used

IAPWS-IF97 Steam Tables

Not used
Not used
Not used
Not used
Not used
Not used
Not used
Not used

Output XML file structure

The output XML file is the same as the input one, with the exception that the names, values and units of the variables which were defined to be read now appear in the OutputParameters section.

<DWSIMXMLFile>
 <Configuration>
   <UnitsSystem Mode="Default" Name="" />
   <Simulation NumberOfRuns="2" FormattedOutput="Yes" />
 </Configuration>
 <InputParameters>
   <SimulationObjects>
     <Object Name="MAT-000">
       <Property ID="PROP_MS_0" Value="100" />
       <Property ID="PROP_MS_1" Value="6000" />
     </Object>
   </SimulationObjects>
 </InputParameters>
 <OutputParameters>
   <SimulationObjects>
     <Object Name="VALV-000">
       <Property ID="PROP_VA_3" Name="Temperature Drop" Value="-10.99552" Unit="°C." />
     </Object>
     <Object Name="MAT-001">
       <Property ID="PROP_MS_0" Name="Temperature" Value="89.00448" Unit="°C" />
       <Property ID="PROP_MS_7" Name="Mixture Specific Enthalpy" Value="71.76271" Unit="kJ/kg" />
     </Object>
     <Object Name="MAT-000">
       <Property ID="PROP_MS_7" Name="Mixture Specific Enthalpy" Value="71.76284" Unit="kJ/kg" />
     </Object>
   </SimulationObjects>
 </OutputParameters>
</DWSIMXMLFile>

Property IDs

In order to read and write object property values, you need to know their IDs. A Property ID is a code which uniquely defines a property of an object of any type. For example, “PROP_MS_0” is the ID for the Temperature property of the Material Stream object. If you have the object name and the property ID, then you can read and/or write to that property. This is the very principle of operation of the command line run mode.

Check the Object Property Codes page to view Property IDs for all object types available in DWSIM.