CFD Online Logo CFD Online URL
www.cfd-online.com
[Sponsors]
Home > Forums > Software User Forums > ANSYS > FLUENT > Fluent UDF and Scheme Programming

Making changes in the fluent user file

Register Blogs Community New Posts Updated Threads Search

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   October 10, 2017, 21:52
Default Making changes in the fluent user file
  #1
New Member
 
Arif
Join Date: Sep 2017
Posts: 17
Rep Power: 9
engrarif is on a distinguished road
Hi everyone,
I am working on modelling of PEM fuel cell. I want to change the value of “phase_ch_const” value in the ansys user file (pem_user.c). I am trying to fix since last month, but not getting any clue. Can someone help to get out of this problem. The pic of code is attached.
Cheers,IMG_5124.jpg
engrarif is offline   Reply With Quote

Old   October 10, 2017, 23:03
Default
  #2
Senior Member
 
Alexander
Join Date: Apr 2013
Posts: 2,363
Rep Power: 34
AlexanderZ will become famous soon enoughAlexanderZ will become famous soon enough
Quote:
Originally Posted by engrarif View Post
Hi everyone,
I am working on modelling of PEM fuel cell. I want to change the value of “phase_ch_const” value in the ansys user file (pem_user.c). I am trying to fix since last month, but not getting any clue. Can someone help to get out of this problem. The pic of code is attached.
Cheers,Attachment 58914
Hello.

Next time put here code, not picture of code.
Did you try this one?
Code:
cxboolean const_rate_from_gui = FALSE;
real phase_ch_const = 999999999999999999999999999;
return phase_ch_const;
Best regards
AlexanderZ is offline   Reply With Quote

Old   October 10, 2017, 23:05
Default
  #3
New Member
 
Arif
Join Date: Sep 2017
Posts: 17
Rep Power: 9
engrarif is on a distinguished road
Quote:
Originally Posted by AlexanderZ View Post
Hello.



Next time put here code, not picture of code.

Did you try this one?

Code:
cxboolean const_rate_from_gui = FALSE;

real phase_ch_const = 999999999999999999999999999;

return phase_ch_const;
Best regards


Do I need to compel it after making changes?
When I try to compel it after changes I get this error ( pic attached)Image1507687508.794312.jpg
engrarif is offline   Reply With Quote

Old   October 10, 2017, 23:13
Default
  #4
Senior Member
 
Alexander
Join Date: Apr 2013
Posts: 2,363
Rep Power: 34
AlexanderZ will become famous soon enoughAlexanderZ will become famous soon enough
Go to the C:\Program Files\ANSYS Inc\v170\fluent\fluentXXXX\addons\fuelcells

Inside you have 2 files INSTRUCTIONS-CLIENT and makefile_master-client.nt

In INSTRUCTIONS-CLIENT there is information regarding FC model
For example
Code:
======================
Customizing the module
======================

  The PEM module has a user-modifiable component called "pem_user.c", which
  can be edited and recompiled to create a customized version of the PEM
  library.

  On both systems it is recommended that you make a copy of 
  the addons/fuelcells directory to a local directory.  Changes to the 
  user-customizable part of the library should be made in your copy.

  The user customizable file is
  .../addons/fuelcells/src/pem_user.c
 
  This is the only source file you will edit.


  ===================
  Customizing on Unix
  ===================

  * Edit line 11 of fuelcells/src/makefile so that FLUENT_INC points 
    to the official fluent installation directory.  
    This is normally [path]/ansys_inc/vXX.X/fluent
    !!! MAKE SURE THAT THERE ARE NO BLANK SPACES TRAILING THIS DIRECTORY NAME
  * Build the library from the fuelcells directory with the following
    command:
    make -f Makefile-client FLUENT_ARCH=lnx86
    (on other systems, use the appropriate architecture)

  ======================
  Customizing on Windows 
  ======================

  * Define environment variable FLUENT_INC to point to the official
    fluent installation directory.
     - note on Windows this looks like [path]\ANSYS Inc\vXX.X\fluent
  * Build the library from the fuelcells directory with the following
    command:
    nmake /f makefile_master-client.nt
So you need to modify (in Windows) .../addons/fuelcells/src/pem_user.c file as we discussed before.
Then run command nmake /f makefile_master-client.nt from SDK command promt. You should be in this folder C:\Program Files\ANSYS Inc\v170\fluent\fluentXXXX\addons\fuelcells

Best regards
AlexanderZ is offline   Reply With Quote

Old   October 11, 2017, 00:06
Default
  #5
New Member
 
Arif
Join Date: Sep 2017
Posts: 17
Rep Power: 9
engrarif is on a distinguished road
I have followed the steps but didn’t get any changes in results
engrarif is offline   Reply With Quote

Old   October 11, 2017, 00:50
Default
  #6
Senior Member
 
Alexander
Join Date: Apr 2013
Posts: 2,363
Rep Power: 34
AlexanderZ will become famous soon enoughAlexanderZ will become famous soon enough
You may try to use UDM variable to plot the contour of phase_ch_const

Code:
cxboolean const_rate_from_gui = FALSE;

real phase_ch_const = 999999999999999999999999999;
C_UDMI(c,t,0) = phase_ch_const;
return phase_ch_const;
You may use UDM for both cases (with and without changes) to see the difference

Best regards
AlexanderZ is offline   Reply With Quote

Old   October 11, 2017, 00:52
Default
  #7
New Member
 
Arif
Join Date: Sep 2017
Posts: 17
Rep Power: 9
engrarif is on a distinguished road
How I can make sure that fluent is now using my customisable file?
Regards,
engrarif is offline   Reply With Quote

Old   October 11, 2017, 01:00
Default
  #8
Senior Member
 
Alexander
Join Date: Apr 2013
Posts: 2,363
Rep Power: 34
AlexanderZ will become famous soon enoughAlexanderZ will become famous soon enough
That is the way. You will deg user-defined variable that can be monitored directly from Fluent GUI.

The other way, but it is just to check, is to put output message inside the code.
For example
Code:
real Phase_Change_const(cell_t c, Thread *t)
{
cxboolean const_rate_from_gui = FALSE;

real phase_ch_const = 999999999999999999999999999;
C_UDMI(c,t,0) = phase_ch_const;
Message("Modification is made, phase_ch_const = %f",phase_ch_const);
return phase_ch_const;
}
Best regards
AlexanderZ is offline   Reply With Quote

Old   October 11, 2017, 01:03
Default
  #9
New Member
 
Arif
Join Date: Sep 2017
Posts: 17
Rep Power: 9
engrarif is on a distinguished road
I am running my simulations in parallel for 500 iterations to check the changes in results
engrarif is offline   Reply With Quote

Old   October 11, 2017, 01:06
Default
  #10
Senior Member
 
Alexander
Join Date: Apr 2013
Posts: 2,363
Rep Power: 34
AlexanderZ will become famous soon enoughAlexanderZ will become famous soon enough
For parallel case use
Code:
real Phase_Change_const(cell_t c, Thread *t)
{
cxboolean const_rate_from_gui = FALSE;

real phase_ch_const = 999999999999999999999999999;
C_UDMI(c,t,15) = phase_ch_const;
Message0("Modification is made, phase_ch_const = %f",phase_ch_const);
return phase_ch_const;
}
Do not forget to change the number of UDMs in FLuent GUI
Go to User-Defined -> Memory -> change 15 to 16 (15 is default number regarding source file of FC model, it you made other modifications take it into account)

Best regards
AlexanderZ is offline   Reply With Quote

Old   October 11, 2017, 01:13
Default
  #11
New Member
 
Arif
Join Date: Sep 2017
Posts: 17
Rep Power: 9
engrarif is on a distinguished road
I m using vs12 command prompt instead of sdk, pic attached IMG_5133.jpg
engrarif is offline   Reply With Quote

Old   October 11, 2017, 01:18
Default
  #12
New Member
 
Arif
Join Date: Sep 2017
Posts: 17
Rep Power: 9
engrarif is on a distinguished road
now i m getting this error after making the above changes
>
No error handler available

Error: Cortex received a fatal signal (SEGMENTATION VIOLATION).
Error Object: ()
engrarif is offline   Reply With Quote

Old   October 11, 2017, 02:11
Default
  #13
Senior Member
 
Alexander
Join Date: Apr 2013
Posts: 2,363
Rep Power: 34
AlexanderZ will become famous soon enoughAlexanderZ will become famous soon enough
There were errors during compiling process, don't you see?

Looks like your compiler uses x86, but your computer has x64 architecture.
You need to install x64 compiler. I recommend you to read help article:

https://www.cfd-online.com/Wiki/Flue...Fload_a_UDF.3F

Best regards
AlexanderZ is offline   Reply With Quote

Old   October 11, 2017, 03:09
Default
  #14
New Member
 
Arif
Join Date: Sep 2017
Posts: 17
Rep Power: 9
engrarif is on a distinguished road
Is there any way to check the value of condensation rate constant in GUI?
engrarif is offline   Reply With Quote

Old   October 11, 2017, 04:01
Default
  #15
Senior Member
 
Alexander
Join Date: Apr 2013
Posts: 2,363
Rep Power: 34
AlexanderZ will become famous soon enoughAlexanderZ will become famous soon enough
I described before the ways, how you can monitor phase content, but it requires modification of source code and compiling

This is a list of built in variables, that you can monitor using default library (without any modifications)

Code:
void Set_UDS_Names(char uds[n_uds_required][STRING_SIZE])
{
    strncpy(uds[0], "Electric Potential", STRING_SIZE-1);
    strncpy(uds[1], "Protonic Potential", STRING_SIZE-1);
    strncpy(uds[2], "Water Saturation",   STRING_SIZE-1);
    strncpy(uds[3], "Water Content",      STRING_SIZE-1);
}

void Set_UDM_Names(char udm[n_udm_required][STRING_SIZE])
{
      strncpy(udm[ 0], "X Current Flux Density",         STRING_SIZE-1);
      strncpy(udm[ 1], "Y Current Flux Density",         STRING_SIZE-1);
      strncpy(udm[ 2], "Z Current Flux Density",         STRING_SIZE-1);
      strncpy(udm[ 3], "Current Flux Density Magnitude", STRING_SIZE-1);
      strncpy(udm[ 4], "Ohmic Heat Source",              STRING_SIZE-1);
      strncpy(udm[ 5], "Reaction Heat Source",           STRING_SIZE-1);
      strncpy(udm[ 6], "Overpotential",                  STRING_SIZE-1);
      strncpy(udm[ 7], "Phase Change Source (PEM)",            STRING_SIZE-1);
      strncpy(udm[ 8], "Osmotic Drag Coefficient (PEM)",       STRING_SIZE-1);
      strncpy(udm[ 9], "Liquid Water Activity (PEM)",          STRING_SIZE-1);
      strncpy(udm[10], "Membrane Water Content (PEM)",         STRING_SIZE-1);
      strncpy(udm[11], "Protonic Conductivity",          STRING_SIZE-1);
      strncpy(udm[12], "Back Diffusion Source(PEM)",     STRING_SIZE-1);
      strncpy(udm[13], "Transfer Current",               STRING_SIZE-1);
      strncpy(udm[14], "Osmotic Drag Source (PEM)",            STRING_SIZE-1);
}
Best regards
AlexanderZ is offline   Reply With Quote

Old   March 26, 2018, 20:15
Default
  #16
New Member
 
Arif
Join Date: Sep 2017
Posts: 17
Rep Power: 9
engrarif is on a distinguished road
Hi Alexander hope u will be fine. I am trying to compare polarization curve of simulation with experimental. My question at which surface should I take the value of current means at membrane/ cathode catalyst interface or external surface ie terminal of cathode side?
engrarif is offline   Reply With Quote

Old   March 26, 2018, 22:21
Default
  #17
Senior Member
 
Alexander
Join Date: Apr 2013
Posts: 2,363
Rep Power: 34
AlexanderZ will become famous soon enoughAlexanderZ will become famous soon enough
i think you should take a look into ANSYS Fluent Advanced Add-On Modules file
in part V you may find information regarding PEMFC simulation in fluent

best regards
AlexanderZ is offline   Reply With Quote

Old   March 26, 2018, 22:22
Default
  #18
New Member
 
Arif
Join Date: Sep 2017
Posts: 17
Rep Power: 9
engrarif is on a distinguished road
Thanks for the reply
engrarif is offline   Reply With Quote

Reply


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Custom Thermophysical Properties wsmith02 OpenFOAM 4 June 1, 2023 15:30
polynomial BC srv537 OpenFOAM Pre-Processing 4 December 3, 2016 10:07
[swak4Foam] swak4foam building problem GGerber OpenFOAM Community Contributions 54 April 24, 2015 17:02
[swak4Foam] Swak4FOAM 0.2.3 / OF2.2.x installation error FerdiFuchs OpenFOAM Community Contributions 27 April 16, 2014 16:14
Version 15 on Mac OS X gschaider OpenFOAM Installation 113 December 2, 2009 11:23


All times are GMT -4. The time now is 18:44.