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?
Answers (1)
0 votes
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 Comments
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.
Categories
Find more on Scope Variables and Generate Names in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!