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

How to find indexes of the species in species transport model

Register Blogs Community New Posts Updated Threads Search

Like Tree2Likes
  • 2 Post By obscureed

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   June 13, 2018, 07:00
Default How to find indexes of the species in species transport model
  #1
Member
 
Anomymous
Join Date: May 2018
Posts: 31
Rep Power: 8
Nishant_Sharma is on a distinguished road
Hi all,

I am using a species transport model for my simulation, but there are 3 species predefined in ansys, which cannot be removed (it is showing the error the species are used in one or more equation, but I have not modelled them in any of the equations), and I am using a UDF to define the diffusivities of each species, but I am using only 6 species, and the fluent is adding 3 more by itslef which cannot be removed. On running the calculation it shows the error,

Invalid mass diffusivities(zero mass diffusivities).

so I am assuming that these zero diffusivities are of those species which could not be defined in UDF, as we need indexes of the species to define diffusivities, can anyone please explain how to find the indexes of the same.

Thank you
Attached Images
File Type: png Capture.PNG (19.4 KB, 154 views)
Nishant_Sharma is offline   Reply With Quote

Old   June 13, 2018, 11:34
Default
  #2
Senior Member
 
Join Date: Sep 2017
Posts: 246
Rep Power: 11
obscureed is on a distinguished road
Hi Nishant,

I do not think you should tolerate 3 unwanted species in your model, so the initial focus has to be on reaching a setup without them. (This is not a UDF question, but never mind.)

I do admit that there are times when the easiest way to change a species list (even to reorder the list) is to start a new session, read in a mesh file, and set up the whole thing again from scratch. This is particularly true if you have reactions etc -- you cannot remove a species if it is involved in a reaction. (And if you try to put in any other species temporarily, Fluent may complain about the elements not balancing. And if you try to invent a temporary species with the same formula, it complains that you can't duplicate formulas. This bureaucracy continues until you give up and start from scratch. Horrifying but true.) So "start again" is going to be my fallback advice.

Once you have carefully removed the unwanted species from every possible setting (including diffusivity), what stops you from deleting them? What error message do you get when you try?

Good luck!
Ed
obscureed is offline   Reply With Quote

Old   June 13, 2018, 12:18
Default
  #3
Member
 
Anomymous
Join Date: May 2018
Posts: 31
Rep Power: 8
Nishant_Sharma is on a distinguished road
Thanks, Obscureed for your reply, but I have already tried that many times, I even started from scratch but that is also of no use. As I mentioned earlier also, I do not have modeled those species in any of the reaction, but the fluent has and I don't even know in which reactions. So, I think for the time being it's better to find the indexes of those species and make their diffusivities close to zero.

Also, I want to ask, is it possible to compile the UDF without using Microsoft Visual Studio? as the thesis I am referring to has mentioned to use it.

Thank you
Nishant_Sharma is offline   Reply With Quote

Old   June 14, 2018, 04:20
Default
  #4
Senior Member
 
Join Date: Sep 2017
Posts: 246
Rep Power: 11
obscureed is on a distinguished road
Hi Nishant,

OK, can you describe when and how it goes wrong when you start from scratch? The steps as I recall are as follows (in order):
-- Start with a mesh file.
-- Add energy and a turbulence model.
-- Go to Species Transport and activate that (but not any other aspects like Multicomponent diffusion, not yet). This will use the standard template with h2o, o2, n2 species.
-- Go to Materials and create the species you actually want (as Fluids).
-- In Materials, edit the Mixture: Mixture Species...Names. Add the species that you want to the mixture -- get the order right, because it is difficult to change later. Remove the default species.
-- You can now delete the default species (once they are no longer involved in the mixture). You can delete Air as well.
-- Now you can start adding diffusion and so on.

Does that sequence fail? Do h2o etc return? If so, you have a bug. Upgrade to the latest Fluent and try again, then report it (and please tell us how it goes).

Good luck!
Ed
obscureed is offline   Reply With Quote

Old   June 14, 2018, 04:42
Default
  #5
Senior Member
 
Join Date: Sep 2017
Posts: 246
Rep Power: 11
obscureed is on a distinguished road
On the question about Visual Studio as a compiler for Fluent on Windows: one important point is that there are legitimate, free versions of Visual Studio that work. I've had good experience with Microsoft Visual Studio Express 2012 in the past -- and "good experience" included no need to change any environment variables, and no need to change how Fluent is launched. A more recent post Compile Fluent UDF with Windows 10 suggests that the Community 2017 version works, but needs some changes to environment variables. (This does not count as a good experience in my book, but it is a pain that you have to endure infrequently.)



There are some useful posts on compiling UDFs -- for example: links to instructions Visual Studio 2017 for udf use - which modules do I need?; troubleshooting errors How to solve UDF compilation problems in Fluent.; the basic steps of compile/load/hook The UDF library you are trying to load (libudf) is not compiled for 3D on the current.
obscureed is offline   Reply With Quote

Old   June 15, 2018, 02:43
Default
  #6
Member
 
Anomymous
Join Date: May 2018
Posts: 31
Rep Power: 8
Nishant_Sharma is on a distinguished road
Hi obscureed

-- At first, I am not using a turbulence model
--secondly when I am adding new materials in the species transport model (in Ansys fluent 16.0), there were three previously added materials o2, n2, and H2o, which could not be removed....but now I am working on 14.5, and no such problem I am facing, but still I want to know the indexes as it will help me understand whether the indexes I have given in my code are the same as those of the indexes that fluent gave to the species.

Also, earlier I was working in a lab that does not have Microsoft visual studio installed on its pc, but now I got one which has.

also thanks for the link you have provided for the errors in compiling a UDF, I am facing an error "'nmake' is not recognized as an internal or external command, operable program or batch file" and I got to know why is that so, but as it is mentioned there also, I could not find it now how to resolve it.

Thank you
Nishant_Sharma is offline   Reply With Quote

Old   June 15, 2018, 03:27
Default
  #7
Senior Member
 
Join Date: Sep 2017
Posts: 246
Rep Power: 11
obscureed is on a distinguished road
Hi Nishant,

I regard changing from Fluent 16.0 to Fluent 14.5 as a backward move. You never did say what prevented you from removing the species, but never mind.

For looking at species by index in UDF, try the following:
Code:
#include "udf.h"
DEFINE_ON_DEMAND(list_species)
{
  Domain *d;
  Material *m, *sp;
  int i;
  d = Get_Domain(1);
  m = mixture_material(d);
  mixture_species_loop(m,sp,i) {
    Message0("species[%3d]: name = %s, formula = %s\n",
        i,MATERIAL_NAME(sp),MATERIAL_FORMULA(sp));
  }
}
I don't think it should give you any surprises: the order of species is the same as the order in the mixture definition, indexed from 0 upwards.

For the nmake error, try following the instructions in the links that I sent, and/or search for other instructions.

Good luck!
Ed
maniek940 and Aj_45 like this.
obscureed is offline   Reply With Quote

Old   June 26, 2018, 06:22
Default
  #8
Member
 
Anomymous
Join Date: May 2018
Posts: 31
Rep Power: 8
Nishant_Sharma is on a distinguished road
Quote:
Originally Posted by obscureed View Post
Hi Nishant,

I regard changing from Fluent 16.0 to Fluent 14.5 as a backward move. You never did say what prevented you from removing the species, but never mind.

For looking at species by index in UDF, try the following:
Code:
#include "udf.h"
DEFINE_ON_DEMAND(list_species)
{
  Domain *d;
  Material *m, *sp;
  int i;
  d = Get_Domain(1);
  m = mixture_material(d);
  mixture_species_loop(m,sp,i) {
    Message0("species[%3d]: name = %s, formula = %s\n",
        i,MATERIAL_NAME(sp),MATERIAL_FORMULA(sp));
  }
}
I don't think it should give you any surprises: the order of species is the same as the order in the mixture definition, indexed from 0 upwards.

For the nmake error, try following the instructions in the links that I sent, and/or search for other instructions.

Good luck!
Ed

Thanks, that helped
Nishant_Sharma is offline   Reply With Quote

Old   June 27, 2018, 09:12
Default
  #9
Member
 
Anomymous
Join Date: May 2018
Posts: 31
Rep Power: 8
Nishant_Sharma is on a distinguished road
Quote:
Originally Posted by obscureed View Post
Hi Nishant,

I regard changing from Fluent 16.0 to Fluent 14.5 as a backward move. You never did say what prevented you from removing the species, but never mind.

For looking at species by index in UDF, try the following:
Code:
#include "udf.h"
DEFINE_ON_DEMAND(list_species)
{
  Domain *d;
  Material *m, *sp;
  int i;
  d = Get_Domain(1);
  m = mixture_material(d);
  mixture_species_loop(m,sp,i) {
    Message0("species[%3d]: name = %s, formula = %s\n",
        i,MATERIAL_NAME(sp),MATERIAL_FORMULA(sp));
  }
}
I don't think it should give you any surprises: the order of species is the same as the order in the mixture definition, indexed from 0 upwards.

For the nmake error, try following the instructions in the links that I sent, and/or search for other instructions.

Good luck!
Ed
Hi obscureed,

I figured out how to remove nmake error, we have to start the fluent using mv sdk command prompt

thanks
Nishant_Sharma is offline   Reply With Quote

Old   June 27, 2018, 09:17
Default
  #10
Member
 
Anomymous
Join Date: May 2018
Posts: 31
Rep Power: 8
Nishant_Sharma is on a distinguished road
Quote:
Originally Posted by obscureed View Post
Hi Nishant,

I regard changing from Fluent 16.0 to Fluent 14.5 as a backward move. You never did say what prevented you from removing the species, but never mind.

For looking at species by index in UDF, try the following:
Code:
#include "udf.h"
DEFINE_ON_DEMAND(list_species)
{
  Domain *d;
  Material *m, *sp;
  int i;
  d = Get_Domain(1);
  m = mixture_material(d);
  mixture_species_loop(m,sp,i) {
    Message0("species[%3d]: name = %s, formula = %s\n",
        i,MATERIAL_NAME(sp),MATERIAL_FORMULA(sp));
  }
}
I don't think it should give you any surprises: the order of species is the same as the order in the mixture definition, indexed from 0 upwards.

For the nmake error, try following the instructions in the links that I sent, and/or search for other instructions.

Good luck!
Ed
Hi obscureed,

I want to ask whether it is the index of the data structure of the species and can we call the species using these indexes to define the mass fraction/mole-fraction values and/or the reaction rates of the reaction.

Thank you
Nishant_Sharma is offline   Reply With Quote

Old   June 27, 2018, 09:58
Default
  #11
Senior Member
 
Join Date: Sep 2017
Posts: 246
Rep Power: 11
obscureed is on a distinguished road
Hi Nishant,

OK, well it's good that you have the compiler working. In my opinion, the requirement to start Fluent from a particular command prompt is inconvenient (and unnecessary, if you use a good version such as Visual Studio Express 2012), but maybe it's acceptable.

Yes, the index i can be used for things like mass fraction C_YI(c,tc,i).

Mole fractions are not stored, typically -- if you need them, you have to work them out for yourself using molecular masses, which you can get from "MATERIAL_PROP(sp,PROP_mwi)" (where sp is the species pointer returned by the loop, as before).

You can see examples of all these features in the ANSYS help files.

One place where the species index is not necessarily the correct index is when DPM sources include species. Because only one or two species are typically involved (for example, O2 and CO/CO2 for Combusting particles, or the vapour species for Evaporating particles), the DPM species sources do not run through the full array of species. There is some kind of look-up index there -- I forget the details, and the details may be version-dependent. Anyway, everywhere else that I can think of, the index does what you expect.

Good luck,
Ed
obscureed is offline   Reply With Quote

Old   June 27, 2018, 14:22
Default
  #12
Member
 
Anomymous
Join Date: May 2018
Posts: 31
Rep Power: 8
Nishant_Sharma is on a distinguished road
Quote:
Originally Posted by obscureed View Post
Hi Nishant,

OK, well it's good that you have the compiler working. In my opinion, the requirement to start Fluent from a particular command prompt is inconvenient (and unnecessary, if you use a good version such as Visual Studio Express 2012), but maybe it's acceptable.

Yes, the index i can be used for things like mass fraction C_YI(c,tc,i).

Mole fractions are not stored, typically -- if you need them, you have to work them out for yourself using molecular masses, which you can get from "MATERIAL_PROP(sp,PROP_mwi)" (where sp is the species pointer returned by the loop, as before).

You can see examples of all these features in the ANSYS help files.

One place where the species index is not necessarily the correct index is when DPM sources include species. Because only one or two species are typically involved (for example, O2 and CO/CO2 for Combusting particles, or the vapour species for Evaporating particles), the DPM species sources do not run through the full array of species. There is some kind of look-up index there -- I forget the details, and the details may be version-dependent. Anyway, everywhere else that I can think of, the index does what you expect.

Good luck,
Ed
Hi obscureed,

Yes, it is not always necessary to load fluent with ms sdk command prompt, but in some cases when there is the problem with versions, and the nmake error occurs, and it is safe to load fluent with it. And thanks for the index thing, that helped a lot.
Nishant_Sharma is offline   Reply With Quote

Old   September 26, 2023, 11:05
Default
  #13
New Member
 
Mariusz
Join Date: Aug 2013
Posts: 4
Rep Power: 13
maniek940 is on a distinguished road
Quote:
Originally Posted by obscureed View Post
Hi Nishant,

I regard changing from Fluent 16.0 to Fluent 14.5 as a backward move. You never did say what prevented you from removing the species, but never mind.

For looking at species by index in UDF, try the following:
Code:
#include "udf.h"
DEFINE_ON_DEMAND(list_species)
{
  Domain *d;
  Material *m, *sp;
  int i;
  d = Get_Domain(1);
  m = mixture_material(d);
  mixture_species_loop(m,sp,i) {
    Message0("species[%3d]: name = %s, formula = %s\n",
        i,MATERIAL_NAME(sp),MATERIAL_FORMULA(sp));
  }
}
I don't think it should give you any surprises: the order of species is the same as the order in the mixture definition, indexed from 0 upwards.

For the nmake error, try following the instructions in the links that I sent, and/or search for other instructions.

Good luck!
Ed
Could you please write a similar UDF to list site species? I need to know their indexes for making surface reaction UDF, but I need help finding them, and your code returns only fluid species without site species.
maniek940 is offline   Reply With Quote

Old   September 27, 2023, 09:53
Default
  #14
New Member
 
Mariusz
Join Date: Aug 2013
Posts: 4
Rep Power: 13
maniek940 is on a distinguished road
Ok I found it. I will pase the modified code here to list both fluid phase species and site species. Someone may find it helpful.

#include "udf.h"
DEFINE_ON_DEMAND(list_species)
{
Domain *d;
Material *m, *sp;
int i;
d = Get_Domain(1);
m = mixture_material(d);
mixture_species_loop(m,sp,i) {
Message0("species[%3d]: name = %s, formula = %s\n",
i,MATERIAL_NAME(sp),MATERIAL_FORMULA(sp));
}
mixture_site_species_loop(m, sp, i) {
Message0("site species[%3d]: name = %s\n", i, MATERIAL_NAME(sp));
}
}
maniek940 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
Species transport model problem argeus FLUENT 8 September 20, 2019 07:23
Species Transport Model Abdul Basit FLUENT 0 August 25, 2015 09:40
Species transport : how to model a contrast dye in blood vix FLUENT 0 August 13, 2013 10:28
Problem in Cell Zone conditions for Species Transport model CFDP FLUENT 3 March 5, 2013 04:14
confused with the coupled VOF and species transport model yfling27 FLUENT 0 November 30, 2012 02:18


All times are GMT -4. The time now is 20:04.