What is Nature
Nature is a lightweight .NET library for computing thermo chemical properties of individual chemical species and complex multi-component mixtures. In its core, the library takes away the concern of utilizing extensive sets of parameters required when working with realistic physical models, thus resulting in tremendous reduction of the efforts required for building numerical simulators.
Walkthrough
Using Nature in practice means

  • importing the required data
  • accessing the computed values via the class properties
    The following describes both steps and the two main classes involved, namely ModelObject and IdealGasMixture.
    Importing data
    The key type representing the physical/thermo-chemical model in Nature is the ModelObject class located in the Nature namespace. This class encapsulates a number of settings defining the model aspects as well as the set of the required parameters.
    Using Nature in the code starts from building an instance of this class from a set of input data and, if necessary, from additional configuration settings.
    In its core Nature is designed to be extendable towards supporting any kind of data source whether it is Web Service, Relational Database or a well formed markup language. However, due to its wide acceptance, the CHEMKIN data format is chosen to be the default type of data import used with Nature.
    A new instance of the ModelObject class constructed from a given CHEMKIN formatted data, can be obtained using the CkUtil utility class found in the Nature.Data namespace. The following example demonstrates creating the ModelObject instance using the thermodynamic and molecular transport data URIs of the GRI3 model.

ModelObject model = CkUtil.LoadModel(
"http://www.me.berkeley.edu/gri_mech/version30/files30/thermo30.dat",
"http://www.me.berkeley.edu/gri_mech/version30/files30/transport.dat");

Note that if the model files are stored on the local file system, the file paths can be supplied instead. When required, the model data can be reduced with the lambda expression operators as shown below

string[] speciesIDs = new string[] { "ch4", "o2", "co2", "h2o" };
ModelSetupInfo setupInfo = new ModelSetupInfo()
{
ChemicalSpeciesFilter = (species) => speciesIDs.Contains(species.SpeciesID)
};
ModelObject model = CkUtil.LoadModel(setupInfo,
"http://www.me.berkeley.edu/gri_mech/version30/files30/thermo30.dat",
"http://www.me.berkeley.edu/gri_mech/version30/files30/transport.dat");

In this example the GRI3 model is filtered such that only the specified four chemical species are included into the materialized ModelObject.
Once an instance of the ModelObject is available, the actual computing can be started.
Computing thermo-chemical properties
The second most important type in Nature is IdealGasMixture. Objects of this type represent a particular state of the ideal gas mixture. In Nature the state is not limited to only the thermodynamic characteristics like temperature, pressure, molar concentration etc., but it includes all other (secondary) gas properties such as thermodynamic potentials (e.g. entropy, enthalpy etc), molecular transport properties (e.g. individual species and mixture averaged viscosities, diffusivities etc.) and more. The following example demonstrates creating a new object of the IdealGasMixture type by calling the CreateIdealGasMixture method of the ModelObject class.

IdealGasMixture mixture = model.CreateIdealGasMixture(@"
ch4 = 0.5
o2 = ?
");

Here the gas composition (50% if methane and 50% of oxygen at the default temperature and pressure of 300K and 1atm respectively) is defined with the string given in the GMix format (for more information see examples of creating the IdealGasMixture).
Once the ideal gas mixture object is obtained, any property of the mixture can be obtained by simply accessing the corresponding C# property. For example the following code

double diffusivity = mixture.Diffusivity;
double speedOfSound = mixture.SpeedOfSound;

gets computed values of the mixture diffusivity and the speed of sound. Note that there is no need to call a method computing these properties. The get property accessor takes care that the requested value will be computed if it is not yet. The computing is triggered only once on the first call to the C# property. All the following accesses will simple return the cached result.
By employing the Lazy Loading pattern in Nature, the library API is simplified such that there is no learning curve involved to start using Nature in practical modeling.

 

Last edit: Alexey Evlampiev 2013-05-11