Error trying to link Matlab and Aspen Plus

22 ビュー (過去 30 日間)
Andres
Andres 2024 年 8 月 28 日
回答済み: Andres 2024 年 9 月 14 日
I have error message while trying to link Matlab with my Aspen Plus simulation:
>> CHLC
Error using COM.Apwn_Document_37_0/invoke
Invoke Error, Dispatch Exception:
Source: Aspen Plus 37.0 OLE Services
Description: Unable to open file.
Error in CHLC (line 8)
Aspen.invoke('InitFromFile',[mess.Name '\' Simulation_Name '.apwz']);
This is the code im using:
%% Linking
Aspen = actxserver('Apwn.Document.37.0');
[stat,mess]=fileattrib; % get attributes of folder (Necessary to establish the location of the simulation)
Simulation_Name = 'CL_SCO2';% Aspeen Plus Simulation Name
Aspen.invoke('InitFromArchive2',[mess.Name '\' Simulation_Name '.bkp']);
Aspen.Visible = 1; % 1 ---> Aspen is Visible; 0 ---> Aspen is open but not visible
Aspen.SuppressDialogs = 1; % Suppress windows dialogs.
Aspen.Engine.Run2(1); % Run the simulation
while Aspen.Engine.IsRunning == 1 % 1 --> If Aspen is running; 0 ---> If Aspen stop.
pause(0.5);
end
Matlab version is R2022a (9.12.0.1884302) 64-bit and Aspen plus V11 (37.0.0395)
Already try saving Aspen simulation as .bkp and .apwz.
Yes, two files ( .m matlab code and .awpz / .bkp simulation) are in the same folder.

回答 (3 件)

UDAYA PEDDIRAJU
UDAYA PEDDIRAJU 2024 年 8 月 29 日
Hi Andres,
Ensure the file paths and extensions are correct. Check file permissions. Verify compatibility between MATLAB and Aspen Plus versions. The error is due to the file, otherwise no problem with code, check all file related posibilities, if nothing works you can change the paths and try, restart your system.
I hope you'll be able to figure out the issue.

Saurabh
Saurabh 2024 年 8 月 29 日
Hi Andres,
It seems to when to try to link MATLAB and Aspen plus, you are encountering an invoke error. I went through the MathWorks official documentations and found there are certain MATLAB COM Support Limitations. It says that Microsoft (assuming you have windows OS-32bit) does not support loading 32-bit DLLs or in-process COM servers into a 64-bit application, or conversely. So, you cannot use 32-bit DLL COM objects in 64-bit MATLAB and COM functions are available on Microsoft Windows systems only, if you have different OS, it will not work.
The same information can be found here:

Andres
Andres 2024 年 9 月 14 日
Thank you all for your suggestions! These lines are responsible for the problem, I still don't understand why.
[stat,mess]=fileattrib; % get attributes of folder (Necessary to establish the location of the simulation)
Aspen.invoke('InitFromArchive2',[mess.Name '\' Simulation_Name '.bkp']);
This is what worked for me. It even runs fine if the .bkp or .apwz file is in a different folder.
AspenVersion = 'Apwn.Document.37.0'; % AspenPlus Version: V11.0 -> 37.0; V10.0 -> 36.0, ...
%savefile localization.
AspenPath = 'C:\Users... file.apwz';
% Creates a local or remote COM Automation server
Aspen = actxserver(AspenVersion); % Get pointer and load Aspen Plus comserver:
% % Open Aspen
invoke(Aspen,'InitFromFile2',AspenPath);
Aspen.visible = 0; % Interfaz grafica: 0 -> no visible; 1 ->Visible
Aspen.SuppressDialogs = 1; % Simprimir ventanas de dialog/warnings
Aspen.Reinit(); % Reset datos
Aspen.Run2(); % Corre la simulation
pause(1); % Espera a que se actualize la interfaz gráfica (GUI)

カテゴリ

Help Center および File ExchangeStatics and Dynamics についてさらに検索

製品


リリース

R2022a

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by