Compiling the customized fuel-cell source code pem_user.c under Windows

1) Set-up the environment variables such that the C compiler is always visible as outlined in Solution 2024478:

2) There is a "fuelcells" directory in the standard ANSYS installation directory.

C:Program FilesANSYS Incv140fluentfluent14.0.0addonsfuelcells

(Please note that folders "v140" & "fluent14.0.0" are valid for Release 14 and are slightly different for other releases. It is advised to find the exact location of the "fuelcells" folder using Windows Explorer)

3) Copy the above "fuelcells" directory from its standard location to your local directory where your case( and data) files are. For example, D:DataPEM_example.

4) Enter the fuelcells/src folder, in our example: D:DataPEM_examplefuelcellssrc. This folder contains customisable pem_user.c file which you can modify. Please make a cosmetic change to this file so that you know and can check if the desired local pem_user.c is used (i.e. from your local directory) and not the one from the standard ANSYS installation directory. For, example you can modify one of the User-Defined Memories slightly. Upon loading the library into ANSYS FLUENT you are able to see the list and naming for all used User-Defined Memories and User-Defined Scalars.
For example, replace the line
strncpy(udm[ 0], "X Current Flux Density", STRING_SIZE-1);
strncpy(udm[ 0], "X CURRENT FLUX DENSITY", STRING_SIZE-1);
and then it will be very easy to spot which file/library is used.

5) Make sure that the FLUENT_INC environment variable is set correctly to the current ANSYS FLUENT installation directory i.e. in our example:

C:Program FilesANSYS Incv140fluent

The above path can be different for a different release of ANSYS Software or if the installation of ANSYS Software has been carried out in a non-default location)

6) Define the FLUENT_ADDONS environment variable to correspond to your customised version of the Fuel Cell and Electrolysis module i.e FLUENT_ADDONS should point to your local directory that contains your case file and the customised "fuelcells" directory i.e. D:DataPEM_Example in our case.

NOTE: In order to define the environment variables in Steps 5 & 6 above please go to:
Start -> Control Panel -> System -> Advanced System Settings -> Environment Variables:
Under "System variables" please press "New" to create "FLUENT_INC" & "FLUENT_ADDONS" variables.

7) Modify the "Path" environment variable by appending:

;C:Program FilesANSYS Incv140fluentntbinwin64

to the existing Path.

8) Return to your local "fuelcells" folder
9) Open a new DOS command prompt and issue the following command:

nmake -f makefile_master-client.nt clean

This will clean all old libraries

10) Issue another command to build a new library so that the changes you've made can become active:

nmake -f makefile_master-client.nt

The new libraries will be build. You can check whether compilation went smoothly or not by examining the contents of a makelog file in your local fuelcellswin643ddp. The exact location can be somewhat different if a single precision solver and/or32-bit operating system is used

In our example the location of the makelog file is in D:DataPEM_examplefuelcellswin643ddp:

11) Open FLUENT session and read in your case and data files. Please ensure that the cosmetic change described in Step 4 took place.

Job done.

Hope this helps and best regards,

P.S. In principle it is possible to do the same by changing the naming of the local fuelcells directory into something different e.g. fuelcells_user. In this case it is necessary to delete the FLUENT_ADDONS environment variable and unload the default FC library in FLUENT, and load the localy compiled one i.e D:DataPEM_examplefuelcells_user in the Define -> User-defined -> Functions -> Manage. The advantage of this approach is that you can easily select which library you would like to use, the disadvantage is that one has to go and modify all function hooks in the case file and this can be rather time consuming.

Show Form
No comments yet. Be the first to add a comment!