When using MATLAB operations on Fluent through ansys_aas, setting the wall temperature to a function of the Z-axis raises an error. Is there a solution?

21 ビュー (過去 30 日間)
%% 初始化MATLAB与FLUENT的CORBA通讯接口
orb = initialize_orb();
load_ansys_aas();
iCoFluentUnit = actfluentserver(orb, 'aaS_FluentId.txt');
iFluentTuiInterpreter = iCoFluentUnit.getSchemeControllerInstance();
reportSummary = iFluentTuiInterpreter.doMenuCommandToString('report summary');
disp('FLUENT仿真摘要报告:');
disp(reportSummary);
%% 设轴向热通量 质量
iFluentTuiInterpreter.doMenuCommandToString('define boundary-conditions wall wall yes no yes no no yes temperature no "4[K]*z/1[m]" no no no no yes yes yes yes yes yes');

回答 (1 件)

Umar
Umar 2025 年 9 月 28 日 6:35

Hi @耳,

Saw your post about the MATLAB-Fluent temperature function issue and thought I could help out. That error you're running into with the Z-axis temperature function is actually pretty common - you're definitely not doing anything wrong on your end. Looking at your code, your CORBA setup is actually perfect - getting those summary reports means your connection is solid. The issue you're hitting is just a string handling quirk in how MATLAB passes quoted expressions to Fluent's TUI.

The issue you're seeing occurs because MATLAB's string handling gets confused when passing quoted expressions through the CORBA interface to Fluent's Scheme-based TUI. Your "4[K]*z/1[m]" function is valid, but the quotes aren't making it through the interface properly.

Try this modification first - should fix your exact line:

% Replace your current temperature function line with this:
temperatureFunc = '''4[K]*z/1[m]''';  % single quotes around double quotes
command = ['define boundary-conditions wall wall yes no yes no no yes   
temperature no ' temperatureFunc ' no no no no yes yes yes yes yes yes'];
iFluentTuiInterpreter.doMenuCommandToString(command);
*If that still gives you trouble*, try breaking down your long command:
% Instead of your single long line, try step-by-step:
iFluentTuiInterpreter.doMenuCommandToString('define boundary-conditions 
wall wall');
iFluentTuiInterpreter.doMenuCommandToString('yes');  % thermal conditions
iFluentTuiInterpreter.doMenuCommandToString('no');   % heat generation  
iFluentTuiInterpreter.doMenuCommandToString('yes');  % temperature
iFluentTuiInterpreter.doMenuCommandToString('no');   % constant 
temperature
iFluentTuiInterpreter.doMenuCommandToString('no');   % profile
iFluentTuiInterpreter.doMenuCommandToString('yes');  % temperature 
function
iFluentTuiInterpreter.doMenuCommandToString('temperature');
iFluentTuiInterpreter.doMenuCommandToString('no');   % derivative
iFluentTuiInterpreter.doMenuCommandToString('"4[K]*z/1[m]"');  % your 
function here
% then add the remaining 'no' and 'yes' responses...

The first fix works because MATLAB treats the outer single quotes as string delimiters and passes the inner double quotes through correctly. The step-by-step approach will help you pinpoint exactly where the command is failing if the simple fix doesn't work.

Hope this helps get your simulation running! Let me know if you need any clarification on these approaches or run into other issues.

P.S. - Your CORBA initialization code looks really clean, by the way. The way you're handling the summary report output is a nice touch for verification.

  2 件のコメント
耳
約18時間 前
I am honored that you could take the time out of your busy schedule to answer my questions. I carefully reviewed the suggestions you provided and applied them in MATLAB and FLUENT. I found that the code runs when the temperature is set as a constant, but when set as the function "4[K]*z/1[m]", FLUENT still reports an error, showing the following error codes:
Error: eval: unbound variable
Error Object: 4[k]*z/1[m]
When trying to run step-by-step with 'try', FLUENT shows the following error codes:
Error: invalid command
Error Object: "yes"
Therefore, I suspect that the co-simulation toolbox file I am using, ANSYS_aas 1.2.1.mltbx, does not support passing double quotes and uppercase letters.
Umar
Umar 約17時間 前

Hi @耳,

Thanks for following up and for testing those suggestions so carefully. Based on what we’ve dug into, it looks like this issue isn’t caused by a mistake in your MATLAB code — and it’s not exactly a MATLAB bug either. The behavior comes from how the ANSYS_aaS 1.2.1 co-simulation toolbox handles string quoting when MATLAB passes commands through the CORBA interface to Fluent’s Scheme-based TUI.

The documentation and forum posts (both on MathWorks and CFD-Online) show that quoted expressions like `"4[K]*z/1[m]"` can lose their inner quotation marks when sent through aaS, which makes Fluent interpret the string literally as variables (`4[k]*z/1[m]`) instead of an expression. That’s what’s triggering your

   `Error: eval: unbound variable` message.

So your suspicion is correct — the toolbox likely struggles with double quotes and uppercase unit tokens, rather than your syntax being wrong.

Here’s what you can try next:

1. Keep testing with different quoting styles — triple-single-quotes (`'''4[K]*z/1[m]'''`) or escaped quotes (`"\"4[K]*z/1[m]\""`) — while printing each command in MATLAB (`disp(command)`) so you can see exactly what’s being passed to Fluent.

2. If that still fails, define your temperature variation as either:

a *Fluent profile file (`.prof`), or a *User-Defined Function (UDF) in C that specifies the same relationship.

These bypass the CORBA text-handling issue completely and are the recommended fallback methods in Fluent’s own documentation.

3. Finally, if none of these approaches work, it’s worth reporting this directly to ANSYS Support. Include your environment details (MATLAB version, Fluent version, OS, and the exact `command` string that failed). Their engineering team can confirm whether this quoting issue is a known limitation in `ANSYS_aaS 1.2.1` or provide a patch.

Your setup and debugging approach are spot-on — this really just looks like a limitation in how the current toolbox parses string expressions.

Keep me posted on your progress.

サインインしてコメントする。

カテゴリ

Help Center および File ExchangeIntroduction to Installation and Licensing についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by