Jump to: navigation, search

Akash Deep Singhal is a GSOC2015 student pursuing B.Tech + M.Tech from Department of Chemical Engineering, Indian Institute of Technology, Bombay (IN). He is working on the development of Chemical engineering specific models and integration of flash/thermodynamic libraries in ASCEND. To know more, visit his webpage

GSOC 2015

Weekly Progress Report

During this semester (Before May 6)

May 6 – May 12: Discussion

  • Finalized the Chemical processes to be worked on:-
    • Steam methane reforming
    • Ammonia synthesis (Haber-Bosch)
    • Methanol production from syngas or methane
  • Found component properties and working pressures/temperatures
  • Block diagram (simplified)designed for modelling

May 12 – May 19: Literature Survey & Conceptual Flow-Sheet Development

  • Identified the reactor type
  • Wrote equations for various unit operations (Reactor, mixer etc.)
  • Also wrote equations for connecting all the units to complete flowsheet

May 19 – May 26: Paper work

  • Remaining equations written
  • Went through some of the pre-existing flowsheet models

May 26 – June 5: Methane Reformation modelling

  • Methane reformation flowsheet coding done (WGSR not included)
  • Still not converging though

June 5 – June 14: Ammonia Production Equations

June 14 – June 24: Ammonia Formation Modelling

June 25 - June 28: Break

June 29 - July 12: Importing DWSIM DTL

  • Reading about DLL and COM-Callable interface
  • Register the DLL using .NET RegAsm (creating batch file)
   cd C:\Windows\Microsoft.NET\Framework\v4.0.30319
   regasm.exe /u D:\DTLSource\DTLSource\DTL-master\DWSIM\bin\Debug\DTL.dll \tlb:D:\DTLSource\DTLSource\DTL-master\DWSIM\bin\Debug\DTL.tlb
   regasm.exe  D:\DTLSource\DTLSource\DTL-master\DWSIM\bin\Debug\DTL.dll /codebase /tlb:D:\DTLSource\DTLSource\DTL-master\DWSIM\bin\Debug\DTL.tlb
  • Registered as DTL.Thermodynamic.Calculator module
  • Using win32com client
   >>>> import win32com.client
   >>>> dtlc.Initialize()
   >>>> dtlc = win32com.client.Dispatch('DTL.Thermodynamics.Calculator')
   >>>> dtlc.GetCompoundConstPropList()
   (u'molecularweight', u'criticaltemperature', u'criticalpressure', u'criticalvolume', u'criticalcompressibilityfactor', u'acentricfactor', u'normalboilingpoint', u'idealgasgibbsfreeenergyofformationat25c', u'idealgasenthalpyofformationat25c', u'casregistrynumber', u'chemicalformula')
   >>>> dtlc.GetCompoundConstProp("Water","criticalvolume")
   >>> dtlc.GetCompoundConstProp('Benzene','normalboilingpoint')

July 12 - July 19: Python functions for interfacing

  • Created python functions for interfacing with registered DWSIM DTL
  • Python file to be directly imported into a4c file
  • Sample:-
   def CompProperty(Comp,Prop): #comp is the component and prop is the required property
       """This function calls the DWSIM Thermodynamics DTL and gives the required component property"""
   	import win32com.client
   	dtlc = win32com.client.Dispatch("DTL.Thermodynamics.Calculator")
   	print Comp
   	print Prop
   	PROP_VALUE = dtlc.GetCompoundConstProp('Water','molecularweight')
   	# pv = float(PROP_VALUE)
   	print PROP_VALUE
   	return PROP_VALUE
  • When the above function in run:-
   >>> CompProperty('Benzene','normalboilingpoint')
  • All the values match with the values from DWSIM software (Verified!)
  • GetPropPackList, GetCompoundList, GetPropList, GetCompoundConstPropList, GetCompoundTDepPropList, GetCompoundPDepPropList and GetPhaseList are some of the functions which can be called from the library

July 20 - July 24

  • Semester starts; Busy in that

July 25 - August 1:

August 2 - August 9

  • Writing C wrapper for calling COM-Callable DWSIM Dynamic Thermodynamic Library, to make it accessible from a4c/a4l files
  • Working on connecting above using mono for completing the loop in Linux platform

August 10 - August 17

  • Continue C-wrapper for the connection
  • Wrapping up | Final Documentation
  • Written functions for Fetching informations from DTL in C (to be connected to the respective functions in python ):-
    • Property - Get specified property for specified component

double Property(char *Comp, char *Prop, char *PropType, double TorP)
    	PyObject *pName, *pModule, *pDict, *pFunc, *pValue, *pTorP, *ptype, *pArgs, *pcomp, *pprop;
    	double mw = 0.0;
    	// Initialize the Python Interpreter
    	/* Code goes here*/
    	return mw;
    	// Finish the Python Interpreter
    • TwoPhaseProperty - Getting component properties for two phase system

void TwoPhaseProperty(double mw[][4], char *propPack, double flashAlg, double pressure, double temp, char *comp1, char *comp2, double mf1, double mf2)
    	PyObject *pName, *pModule, *pDict, *pFunc, *pValue, *palg, *pArgs, *pcomp1, *pcomp2, *pmf1, *pmf2, *ptemp, *ppres, *ppack, *pi, *pj;
    	//double mw = 0.0;
    	// Initialize the Python Interpreter
    	/* Code goes here */
    	//return mw;
    	// Finish the Python Interpreter
    • Steam_Properties - Stem Properties at certain conditions

void Stream_Properties(char *proppack, char *compounds1, char *compounds2, double T, double P, double molefractions1, double molefractions2, double Results[])
	PyObject *pName, *pModule, *pDict, *pFunc, *pValue, *pArgs, *pcomp, *pprop, *pcompound1, *pcompound2, *pycompounds, *pT, *pP, *pmf1, *pmf2, *pycomp, *ii;
	int i;

	// Initialize the Python Interpreter

	/* Code goes here*/

	// Finish the Python Interpreter


And a few more

  • Method :-
    • Registration function
      • This function is the entry point for the shared library you are creating
      • Does the job of telling ASCEND what external relations you are going to be providing to it
    • Format of Registration
      • Forward Declaration
   ExtBBoxInitFunc dtltest_compprop_prepare;
   ExtBBoxFunc dtltest_compprop_calc;
      • Registration function for the DTLTEST shared library
  • Problem :-

After scons is run and dtltest.a4c is loaded, It shows error: IMPORT of 'johnpye/dtltest/dtltest' failed.

August 18 - August 21 Solution :- Asked John about this. He suggested, Rather write the code in C++. But the thing is C/C++ can call the functions from DLL/SO using LoadLibrary but DTL is written in visual basics (visual C++) so C++ can't interpret the functions directly. So if need be, intermediate functions will need to be written in visual C++.

int _tmain(int argc, _TCHAR* argv[])
    	  BSTR Comp = NULL;
    	  Comp = SysAllocString ( L"Methane" );
    	  BSTR Prop = NULL;
    	  Prop = SysAllocString ( L"vaporPressure" );
    	  int T = 0;
    	  double VapPres = 0;
    	 _CalculatorPtr ptrinterface(_uuidof(Calculator));
    	// Initialize COM.
    	 double x = 0;
    	 for (T = 300;T<1000;T++)
    	 //std::cout<< VapPres << std::endl;
    	 SysFreeString ( Comp );
    	 SysFreeString ( Prop );
        return 0;
    • This will become quite complicated so as to make compatible in UNIX systems. I think only writing in code in C/C++ and connecting DTL using mono might solve the problem.


Currently, ASCEND has a small number of processes specific models but pertaining to the vast area of Chemical Engineering, there are lots of processes which are required by users. And this makes ASCEND quite less useful as a modelling environment. There are various quite basic but very important processes which need to be modelled which can be used by the user.

Proposed Plan

  • During this semester (Before May 3)
    • Understand some basic concepts e.g. learning extensively about Mathematical modelling of a Chemical Process, design some basic process flowsheets to get familiar with the ascend modelling environment, recollect various relevant Chemical Engineering concept learnt in last four years
    • Try to get some experience in the relevant portions of the codebase, get familiarize with coding styles and version management in ASCEND
    • Develop a sample flow sheet for Steam reforming and provide complete documentation.
    • Collect (as many as possible) complete project material from various groups working separately on various processes, e.g. Group X is working on complete industrial level manufacture of some process P. This will give us around 25 complete working-process-flowsheets simulated on AspenPlus.
  • May 3 – May 5: Discussion
    • Detailed discussion of project methodology and implementation with mentors, community members
    • Finalize the processes and flash algorithms to be worked on
  • May 5 – May 12: Literature Survey
    • Identify different reaction paths
    • Find component and mixture properties, working temperatures and pressures
    • Design basic block diagrams
  • May 12 – May 19: Conceptual Flow-Sheet Development
    • Writing and solving process equations
    • Check for kinetics, thermodynamics
    • Identify separation and reaction techniques required in different reaction paths
    • Select feasible route from the flow sheets developed. Selection of appropriate reactor, Heat exchanger, separator etc.
  • May 19 – May 26: Paper Work
    • Perform manual Mass balance for each equipment
    • Steady state simulation on ASPEN. Get a converged file with recycle
    • Check for the heat duty
    • Equipment sizing for various equipments (manually or Aspen{preferable})
    • Heat Integration : Combine Heat Exchanger Network to minimize the energy consumption
    • Detailed discussion would be needed with mentors and Prof. Kannan, (I intend to do that while the above part goes on)
    • Reporting with extensive documentation
  • May 26 – June 2: Begin Coding
    • Choose one process out of the selected ones | Finalize on the basis of ease
    • Code the model
  • June 2 – June 9: First process ready
    • By this time, a basic ascend model should be ready and running. In this week, I intend to test it for various parameters and check whether the model is converging or not.
    • Grasp the crunch of this model and start working on the further models
  • June 9 – June 20: Keep on writing processes (12 days)
    • Repeat the work done above for single process.
    • Validate models for reusability
  • June 21 – June 24: Break
    • I wish to take some break. Go out trekking or for some adventure. Relax a bit.
    • Enjoy first showers of rain after hot and humid summers in Mumbai (One of my favorite time of the year)
    • Would help me for efficient working
  • June 24 – July 1: Get back to work
    • Learn extensively about Flash Algorithms
    • DWSIM includes various equilibrium flash algorithms for VLE and even for more complicated SLE etc.
    • Getting info on how to import libraries from DWSIM since the major issue in the integration is that DWSIM core libraries are written in .NET while ASCEND libraries are written in C/C++
    • For the integration Inter-language unification need to be done. Check for its feasibility
    • Nested Loops(default), Gibbs Minimization, Inside-out (for 2-3 phases) are some of flash algorithms used in DWSIM
  • July 1 – July 8: Writing Flash Algorithms
    • In case, direct integration of DWSIM package is not feasible or if new flash algorithms are needed to be developed, work on it
    • By the time, mentors guidance period starts on July 4 according to GSOC timeline
    • Get help in the issues I have been facing (though this will already be happening so does not make much sense)
  • July 8 – July 15:
    • Come back to models which needed these flash algorithms
    • Make changes accordingly and validate the models
    • Fix any issue that occurs
  • July 15 – July 22: Wrap up
    • Final Documentation to be made
    • Complete testing - Check for any bug and troubleshooting in that case
    • Merging my project branch with trunk
  • July 22 – Aug 17:
    • Semester will start so will take this time as buffer for any leftovers due to glitches or some bugs
    • Extension for ARM devices: According to current scenario, tech-world is shifting from Laptops to Tablets and Phablets, in short ARM based devices. If time permits, I intend to get this whole package working on netbook, an ARM based laptop for on-the-go-development (an initiative by FOSSEE, IIT Bombay).
  • Aug 21: Final Submission of the code to google