Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding documentation for ACM/VBA workaround #1118

Merged
merged 4 commits into from
Mar 21, 2023
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions docs/source/chapt_sinter/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,4 @@ Contents

reference
tutorial/index
vba_acm
34 changes: 34 additions & 0 deletions docs/source/chapt_sinter/vba_acm.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
Additional ACM Functionality with Excel/VBA
===========================================

When additional functionality is needed when working with Aspen Custom Modeler (ACM), such as custom initialization routines or executing complicated cyclic models, using excel/VBA execution of the ACM simulation is a viable option. The excel file can then be connected to FOQUS through the documented SimSinter connection.

Below is an example of a VBA macro titled ‘runAspen’ for executing a temperature swing adsorption (TSA) cycle simulated in ACM.

.. figure:: figs/acm_vba/01_VBAcode.png
:alt: VBA Example Code
:name: fig.sinter.vba_acm.vba_code

VBA Example Code

Code block 1 creates the ACM object using objects installed with Aspen simulation workbook. The full path of the ACM file is needed in the ‘ACMApp.OpenDocument’ function. The ‘ACMSimulation’ object is used to read/write variables in the simulation and even run the simulation. Additionally, you can view the aspen simulation by setting ‘ACMApp.Visible’ to True.

Code block 2 changes the value of a fixed variable in the simulation through the ‘ACMSimulation’ object. This can be a hardcoded value in the macro script, or it can read from a worksheet cell which is shown here.

Code block 3 runs the custom initialization and simulation routine for this TSA example. The model is first run in initialization mode and then to ensure that the cycle task will correctly run, it is deactivated and then reactivated. The model is again initialized and then run in dynamic mode.

Code block 4 reads results from the model and then closes the simulation.

This is a simple example, but additional examples and more information for scripting and automation can be found in the documentation for ACM.
To run the model using FOQUS, connect the excel file which contains the execution macro using SimSinter, and create a flowsheet node for the resulting turbine model. Tutorials for Excel/SimSinter and creating a flowsheet are linked below.

| https://foqus.readthedocs.io/en/stable/chapt_sinter/tutorial/excel.html
| https://foqus.readthedocs.io/en/stable/chapt_flowsheet/tutorial/sim_flowsheet.html

Specifying that the macro should be run can be done during the SimSinter setup step or in the settings tab after the flowsheet node has been created. The node settings for our example setup are shown below in which the ‘runAspen’ macro is specified.

.. figure:: figs/acm_vba/02_nodesettings.png
:alt: Node Settings for Running Excel Macro
:name: fig.sinter.vba_acm.node

Node Settings for Running Excel Macro