ADVANCED EXAMPLE 8001 Adjust Feed Composition From Excel Components NO. NAME FORMULA PHC 1 2 3 4 H2O N2 O2 H2O H2O N2 O2 H2O Stream Data Stream 1 - N2 Gaseous Assays LI3 GC8 GC8 GC8 10 Mt/Hr N2 ..............1.0 Temp ...............50oC Stream 2 - O2 Gaseous Assays 10 Mt/Hr O2 ...............1.0 Temp ...............50oC Stream 3 - H20 Gaseous Assays 10 Mt/Hr H2O ................1.0 Temp ...............50oC Stream 6 - WATER 2 Mt/Hr Aqueous Assays H2O ............1.0 Temp 20oC Flash Vessel Set the Pressure to achieve 65oC in the Slurry, stream 8. The Flash Vessel Unit Operation Data variable PR is the pressure in the Flash. A Feedback Control will be used to adjust the PR variable to achieve the desired temperature in stream 8. In The CONTROL TAB of the Unit Operation Screen enter the following in the CtB and CtA fields. Note: 3 FRND nv (Returns the rounded off vector nv to 3 decimal places. CtB PRFRND VCTL 5 CtA 1 ADVANCED EXAMPLE 8001 FlashPressurePR The pressure of the Flashing Vessel needs to be reported to the Excel Spreadsheet. The variable "FlashPressure" is assigned the value of the Flash variable PR which is the Flash pressure. The value of "FlashPressure" is then output too Excel via a DDE link in METSIM. Flowrate Controls CN ID 1 Control N2 in Feed Stream 5 2 Control O2 in Feed Stream 5 3 Control H20 in Feed Stream 5 4 Flowrate Feed Stream 5 OP 2 2 2 2 SN 1 2 3 5 SP USFeedFlow×USN2WF USFeedFlow×USO2WF USFeedFlow×USH2OWF USFeedFlow Feedback Control ID = Control Flash Pressure to achieve Outlet Temperature CN OP NO SN LV HV VF SP 5 3 3 0 75 1000 VTEC s8 USslurryTemp VF VMTH SN VMTH SN VMTH SN VMTH SN SL 1 With the Edit Object Data Tool click on the "User Created Objects Button" and enter the following; User Created Objects Type Name Description Value Scalar USN2WF N2 wf Feed Stream 5 0.67 Scalar USO2WF O2 wf Feed Stream 5 0.23 Scalar USH2OWF H2O wf Feed Stream 5 0.1 Scalar USFeedFlow Flowrate Feed Stream 5 205 Scalar USslurryTemp Flash Slurry Temp oC 65 BATCH BATCH Run METSIM From Excel XCAL From the Tools Menu select "IDDE Input DDE Data Exchange" and enter the following; DDEs ID Flowrate Feed Stream 5 N2 wf O2 wf H2O wf Flash Slurry Temp oC Flowrate Stream 1-N2 Mt/Hr Flowrate Stream 2-O2 Mt/Hr Flowrate Stream 3-H2O Mt/Hr Flowrate Stream 4-Error Mt/Hr Flowrate Stream 5-Feed Mt/Hr Flowrate Stream 6-Feed Mt/Hr Flowrate Stream 7-Feed Mt/Hr Flowrate Stream 8-Feed Mt/Hr N2 wf in Feed O2 wf in Feed H2O wf in Feed Feed Stream Temp oC Flash Water Temp OC Flash Offgas Temp oC Flash Slurry Temp oC Flash Pressure kPa MV USFeedFlow USN2WF USO2WF USH2OWF USslurryTemp VMTH s1 VMTH s2 VMTH s3 VMTH s4 VMTH s5 VMTH s6 VMTH s7 VMTH s8 c2 VCWF s5 c3 VCWF s5 c4 VCWF s5 VTEC s5 VTEC s6 VTEC s7 VTEC s8 FlashPressure IO INPUT INPUT INPUT INPUT INPUT OUTPUT OUTPUT OUTPUT OUTPUT OUTPUT OUTPUT OUTPUT OUTPUT OUTPUT OUTPUT OUTPUT OUTPUT OUTPUT OUTPUT OUTPUT OUTPUT PN EXCEL EXCEL EXCEL EXCEL EXCEL EXCEL EXCEL EXCEL EXCEL EXCEL EXCEL EXCEL EXCEL EXCEL EXCEL EXCEL EXCEL EXCEL EXCEL EXCEL EXCEL SN FEED FEED FEED FEED FEED FEED FEED FEED FEED FEED FEED FEED FEED FEED FEED FEED FEED FEED FEED FEED FEED CN USFeedFlow USN2WF USO2WF USH2OWF USslurryTemp Flow1out Flow2out Flow3out Flow4out Flow5out Flow6out Flow7out Flow8out N2out O2out H2Oout FeedTemp FlashWaterTemp OffGasTemp SlurryTempout FlashPressure EXCEL SPREADSHEET Using the supplied graphic (cbkFeedCompExcelPic.jpg) setup the following Excel Spreadsheet. 2 ADVANCED EXAMPLE 8001 In Excel rename SHEET1 to FEED. Add an Excel Button with the following Visual Basic Code; Private Sub CommandButton1_Click() MyAppID = Shell("c:\metsim\metsim.exe SIL=1 MOD=C:\METSIM\MEX\8001CalFromExcel.sfw") End Sub After the Excel spreadsheet is setup SAVE it as "8001CalFromExcel.XLS". In METSIM Turn on the Activate Dynamic Data Exchange Switch (DDS) by clicking on the Model Parameters Button, then the Calc Options tab and finally click the DDS box. With the "Edit Object Data" Tool click on the SECTION at the bottom left-hand side of the palette. Enter Feed Stream into the field UN - Unit Operation Name. Click OK to exit this unit operation. The flowsheet is now ready to CALCULATE but before running the Calculation routine the file should be SAVED as "8001CalFromExcel.sfw". It is important that the flowsheet be saved as the filename used in the Command Button. The METSIM flowsheet MUST BE SAVED in the directory used in the CommandButton. After Saving the METSIM flowsheet and Excel file close both programs. Load the Excel file. From Excel click on the METSIM Button. Results may be viewed in Excel after the calculation stops. 3 ADVANCED EXAMPLE 8001 Next change the input values in Excel and Calculate the flowsheet again. Then view the results in Excel again. Instructions for Running METSIM from EXCEL in Silent Mode 1. Build METSIM model and get it working. 2. Once model is working add DDE inputs and outputs to Excel. 3. Build Excel Spreadsheet with input and output fields. 4. Test model, DDE and Excel to make sure they function as desired. 5. In METSIM User Created Objects, create a 'BATCH' function with 'XCAL' command. 'XCAL' calls the METSIM calculation routine. The BATCH function is executed when a model is loaded in silent mode. 6. Add METSIM button to Excel. Add following Vusual Basic commands to button. Private Sub CommandButton1_Click() MyAppID = Shell("c:\metsim\metsim.exe SIL=1 MOD=FILE") End Sub Where FILE is exact and complete drive:path/file/extension Example: C:\METSIM\MEX\cbkFeedComposition.SFW 7. Save METSIM and Excel files in same directory as specified in path noted. 8. Close METSIM and Excel. Reopen Excel, load file, change data, click 'METSIM' button. METSIM should startup, load model, read DDE input, calculate results, write DDE output and shutdown without displaying any messages. 9. The Security Option in Excel must be set to allow the running of Macros for the function to work. 10. Whenever a new version of METSIM is received the flowsheet and spreadsheet need to be loaded and Saved before the function will work correctly. 4