產品系列
查看所有產品Ansys致力於為當今的學生打下成功的基礎,通過向學生提供免費的模擬工程軟體。
ANSYS BLOG
February 11, 2017
My friend, a fellow Romanian, just told me a funny story. She just relocated to the U.S. and was asking her dentist "When will I have the root channel treatment?". The dentist kindly replied "Did you mean root canal, my dear?"
Human kindness is a beautiful thing. As a software developer, I often wish that computer programs would be equally technically kind. Most of them are not. Many times, when a user mistypes a command, applications crash.
This is pretty common when driving Ansys Fluent from a remote program like Matlab. The Fluent scripting language is contextual. Consequently, the syntactic rules are changing during the simulation. For instance, substantially different commands are available when the CFD solver is changing the state, for example from meshing mode to simulation mode.
Fortunately, the aaS interface supports technical kindness. Consequently, when a command seems to be incorrect or incomplete, Fluent will switch to a "kind" response. Ultimately, the kindness will be offered as a clarifying exception. The exception should help the Matlab user understand the context. At this point such user could correct or complete the command.
My friend is using Matlab to drive Ansys Fluent, so I decided to demonstrate the technique in snippet of Matlab code for her. Here it is for you:
disp('Start Example')
load_ansys_aas;
orb=initialize_orb;
fluent=actfluentserver(orb,'aaS_FluentId.txt');
tui=fluent.getSchemeControllerInstance();
out='Report not received';
bIKnowHowToClarify=false;
try
disp('Requesting <report summary>');
out = tui.doMenuCommandToString('report summary -?')
catch ex
ex_id=ex.identifier;
if strcmp(ex_id , 'MATLAB:Java:GenericException')
ex_object_class=ex.ExceptionObject.getClass;
if strcmp(ex_object_class,'class AAS_CORBA.EYesNoQuestion')
disp(ex.ExceptionObject.questionPromptWithDefaultAnswer);
bIKnowHowToClarify=true
end
end
if bIKnowHowToClarify==false;
rethrow(ex)
end
end
if bIKnowHowToClarify==true
disp('Answering <No> to the clarification question...');
disp('Requesting <report summary no>');
out = tui.doMenuCommandToString('report summary no -?');
end
disp(sprintf('Output:\n%50.50s....\n',char(out)))
Start Example
Requesting <report summary>
write to file? [no]
Answering <No> to the clarification question...
Requesting <report summary no>
Output:
Fluent
Version: 2d, dp, pbns, lam (2d, double pre....
Additionally, I would like to note something in the code. Adding the suffix "-?" to a command indicates that suggestions are welcomed. Similarly, the absence of "-?" will turn off Fluent "kindness". Finally, Fluent supports a set of four clarifying exceptions. Of course, they are properly documented in Ansys manuals. Just search for "aaS" keyword. For more information about Matlab Fluent cosimulation please check out How to Make Matlab Apps for Ansys.