CFD Online Discussion Forums

CFD Online Discussion Forums (http://www.cfd-online.com/Forums/)
-   Fluent UDF and Scheme Programming (http://www.cfd-online.com/Forums/fluent-udf/)
-   -   How to do Design Optimization in Fluent 13.0? (http://www.cfd-online.com/Forums/fluent-udf/86572-how-do-design-optimization-fluent-13-0-a.html)

p36288 March 26, 2011 15:26

How to do Design Optimization in Fluent 13.0?
 
How to do Design Optimization in Fluent 13.0?
Anyone noticed that the latest version ANSYS 13.0 FLUENT solver have integrated Automatic shape flow optimization? I'm trying to do a simple optimization case, however, the objective function can only be provided in one of two ways: either as a UDF, or as a Scheme source file. Here are what the UserGuide said on the definition of objective function:
"
A. If you want to provide the objective function as a user-defined function (UDF), perform the steps that follow.
1. Write a UDF using the DEFINE_ON_DEMAND macro to define the objective function. The function name must be objective_function. At the end of the objective function, the rpvar morpher/objective_function needs to be set to the (current - target) value. It is this value that the optimizer will attempt to minimize.
2. Compile the UDF using the Compiled UDFs dialog box. Make sure libudf appears as the Library Name. Define User-Defined Functions Compiled...

B.If you want to provide the objective function as a Scheme source file, perform the following steps:
1. Write a Scheme source file to define the objective function. The procedure name must be objective-function. At the end of the objective function, the rpvar morpher/objective-function needs to be set to the (current - target) value. It is this value that the optimizer will attempt to minimize.
2. Load the Scheme source file.
"
After reading the guide, i'm still not clear how to define the objective function. Anyone could provide me an example about how to do it?
Thanks a lot.

fox000002 July 20, 2011 00:37

1 UDF

Code:

#include "udf.h"
 
DEFINE_ON_DEMAND(objective_function)
{
    real obj = 0.0;
    /* ... */
    rp_set_real(morpher/objective_function, obj);
}



2 Scheme

Code:

(define (objective-function)
;...
  (rpsetvar 'morpher/objective_function obj)
)



All times are GMT -4. The time now is 08:21.