Webnucleo.org

Mail Lists | Developers
small logo


Warning: This is no longer the latest available version of this module. Please see the releases page for the most recent version. The Webnucleo group strongly recommends the use of the latest version of any of its online modules.

Documentation from the file



libnucnet/0.1/src/Libnucnet__Reac.h


Table of Contents

Structures
Name: Libnucnet__Reaction

Description: Libnucnet__Reaction is a structure that stores data for a reaction in a nuclear reaction network. Routines act on the structure to retrieve data, update data, or use data to compute reaction rates based on the data. The contents of the structure are not made public by the API.

-top-


Name: Libnucnet__Reac

Description: Libnucnet__Reac is a structure that stores a collection of reactions for a nuclear network. Routines act on the structure to retrieve data, update data, or use data to compute reaction rates based on the data. The contents of the structure are not made public by the API.

-top-



Routines
Name: Libnucnet__Reac__addNonSmokerReaction()

Description: Add a reaction to a Libnucnet__Reac structure providing non-smoker data.

Syntax:
           void Libnucnet__Reac__addNonSmokerReaction(
             Libnucnet__Reac *self, const char *s_source,
             char **a_reactants, int i_reactants,
             char **a_other_reactants, int i_other_reactants, char **a_products,
             int i_products, char **a_other_products, int i_other_products,
             double a[], double d_spint, double d_spinf, double d_tlowhf,
             double d_tlowfit, double d_acc
           );
             
Input:

self: (required) A pointer to a Libnucnet__Reac structure.

s_source: (required) A string giving the message containing information about the data source.

a_reactants: (required) An array of strings containing the reactants in the reaction.

i_reactants: (required) An int giving number of reactants.

a_other_reactants: (required) An array of strings containing the "other" reactants in the reaction.

i_other_reactants: (required) An int giving number of "other" reactants.

a_products: (required) An array of strings containing the products in the reaction.

i_products: (required) An int giving number of products.

a_other_products: (required) An array of strings containing the "other" products in the reaction.

i_other_products: (required) An int giving number of "other" products.

a: (required) An array of doubles giving the a values.

d_spint: (required) A double giving the spint value.

d_spinf: (required) A double giving the spinf value.

d_tlowhf: (required) A double giving the tlowhf value.

d_tlowfit: (required) A double giving the tlowfit value.

d_acc: (required) A double giving the acc value.

Output:

For valid input, the routine updates the Libnucnet__Reac structure to include the new reaction. If the reaction data are already in the structure, they are overwritten with this data. If the input in invalid or the reaction cannot be added, Libnucnet__Reac error handling is invoked.

Example: Add reaction "h1 + n -> h2 + gamma" to Libnucnet__Reac *p_my_reac with non-smoker data values a, spint, spinf, tlowhf, tlowfit, and acc:

         a_reactants[0] = "h1";
         a_reactants[1] = "n";
         a_products[0] = "h2";
         a_other_products[0] = "gamma";
         Libnucnet__Reac__addNonSmokerReaction(
           p_my_reac, "non_smoker example", a_reactants, 2, a_other_reactants,
           0, a_products, 1, //   a_other_products, 0, a, spint, spinf, tlowhf,
           tlowfit, acc
         );
               

-top-


Name: Libnucnet__Reac__addRateTableReaction()

Description: Add a reaction to a Libnucnet__Reac structure providing a rate table.

Syntax:
           void Libnucnet__Reac__addRateTableReaction(
             Libnucnet__Reac *self, const char *s_source,
             char **a_reactants, int i_reactants,
             char **a_other_reactants, int i_other_reactants, char **a_products,
             int i_products, char **a_other_products, int i_other_products,
             double *a_t9, double *a_rate, double *a_sef, int i_entries
           );
             
Input:

self: (required) A pointer to a Libnucnet__Reac structure.

s_source: (required) A string giving the message containing information about the data source.

a_reactants: (required) An array of strings containing the reactants in the reaction.

i_reactants: (required) An int giving number of reactants.

a_other_reactants: (required) An array of strings containing the "other" reactants in the reaction.

i_other_reactants: (required) An int giving number of "other" reactants.

a_products: (required) An array of strings containing the products in the reaction.

i_products: (required) An int giving number of products.

a_other_products: (required) An array of strings containing the "other" products in the reaction.

i_other_products: (required) An int giving number of "other" products.

a_t9: (required) An array of doubles giving the t9 values in the table.

a_rate: (required) An array of doubles giving the rate values in the table.

a_sef: (required) An array of doubles giving the sef values in the table.

i_entries: (required) An integer giving the number of entries in the table.

Output:

For valid input, the routine updates the Libnucnet__Reac structure to include the new reaction. If the reaction data are already in the structure, they are overwritten with this data. If the input in invalid or the reaction cannot be added, Libnucnet__Reac error handling is invoked.

Example: Add reaction "h1 + n -> h2 + gamma" to Libnucnet__Reac *p_my_reac giving 20 rate table values a_t9, a_rate, and a_sef:

         a_reactants[0] = "h1";
         a_reactants[1] = "n";
         a_products[0] = "h2";
         a_other_products[0] = "gamma";
         Libnucnet__Reac__addSingleRateReaction(
           p_my_reac, "example", a_reactants, 2, a_other_reactants, 0, a_products, 1, 
           a_other_products, 0, a_t9, a_rate, a_sef, 20
         );
               

-top-


Name: Libnucnet__Reac__addSingleRateReaction()

Description: Add a reaction to a Libnucnet__Reac structure providing a single rate.

Syntax:
           void Libnucnet__Reac__addSingleRateReaction(
             Libnucnet__Reac *self, const char *s_source,
             char **a_reactants, int i_reactants,
             char **a_other_reactants, int i_other_reactants, char **a_products,
             int i_products, char **a_other_products, int i_other_products,
             double d_forward
           );
             
Input:

self: (required) A pointer to a Libnucnet__Reac structure.

s_source: (required) A string giving the message containing information about the data source.

a_reactants: (required) An array of strings containing the reactants in the reaction.

i_reactants: (required) An int giving number of reactants.

a_other_reactants: (required) An array of strings containing the "other" reactants in the reaction.

i_other_reactants: (required) An int giving number of "other" reactants.

a_products: (required) An array of strings containing the products in the reaction.

i_products: (required) An int giving number of products.

a_other_products: (required) An array of strings containing the "other" products in the reaction.

i_other_products: (required) An int giving number of "other" products.

d_forward: (required) A double giving the forward reaction rate.

Output:

For valid input, the routine updates the Libnucnet__Reac structure to include the new reaction. If the reaction data are already in the structure, they are overwritten with this data. If the input in invalid or the reaction cannot be added, Libnucnet__Reac error handling is invoked.

Example: Add reaction "h1 + n -> h2" to Libnucnet__Reac *p_my_reac with a forward rate of 0.5:

         a_reactants[0] = "h1";
         a_reactants[1] = "n";
         a_products[0] = "h2";
         Libnucnet__Reac__addSingleRateReaction(
           p_my_reac, "single rate example", a_reactants, 2, a_other_reactants,
           0, a_products, 1, //   a_other_products, 0, 0.5
         );
               

-top-


Name: Libnucnet__Reac__free()

Description: Free the memory allocated for a Libnucnet reaction network structure.

Syntax:
         void Libnucnet__Reac__free( Libnucnet__Reac *self );
             
Input:

self: (required) A pointer to a Libnucnet reac structure.

Output:

Upon successful return, the memory for the network has been freed. If the input is invalid, Libnucnet__Reac error handling is invoked.

Example: Free up memory used for Libnucnet__Reac *p_my_reac:

         Libnucnet__Reac__free( p_my_reac );
               

-top-


Name: Libnucnet__Reac__getFirstReaction()

Description: Routine to return the pointer to the first reaction in a Libnucnet__Reac structure.

Syntax:
         Libnucnet__Reaction *Libnucnet__Reac__getFirstReaction( 
           Libnucnet__Reac *self 
         );
             
Input:

self: (required) A pointer to a Libnucnet reaction structure.

Output:

Returns the pointer to the first reaction in the network. If the input reaction pointer is invalid, error handling is invoked.

Example: Get the first reaction in the Libnucnet structure p_my_reac:

          Libnucnet__Reaction *p_reaction =
            Libnucnet__Reac__getFirstReaction( p_my_reac );
               

-top-


Name: Libnucnet__Reac__getLastReaction()

Description: Routine to return the pointer to the last reaction in a Libnucnet__Reac structure.

Syntax:
         Libnucnet__Reaction *Libnucnet__Reac__getLastReaction( 
           Libnucnet__Reac *self 
         );
             
Input:

self: (required) A pointer to a Libnucnet reaction structure.

Output:

Returns the pointer to the last reaction in the network.

Example: Get the last reaction in the Libnucnet structure p_my_reac: If the input reaction pointer is invalid, error handling is invoked.

          Libnucnet__Reaction *p_reaction =
            Libnucnet__Reac__getLastReaction( p_my_reac );
               

-top-


Name: Libnucnet__Reac__getNumberOfReactions()

Description: Retrieves the number of reactions.

Syntax:
         int Libnucnet__Reac__getNumberOfReactions(
           Libnucnet__Reac *self
         );
             
Input:

self: (required) A pointer to a Libnucnet reaction structure.

Output:

Routine returns an integer representing the number of reactions. If the input reaction pointer is invalid, error handling is invoked.

Example: Retrieve the number of reactions stored in p_reaction_list:

         int i_num_reac;
         i_num_reac =
           Libnucnet__Reac__getNumberOfReactions(
             p_reaction_list
           );
               

-top-


Name: Libnucnet__Reac__getReactionByString()

Description: Routine to retrieve a reaction by its string.

Syntax:
         Libnucnet__Reaction *Libnucnet__Reac__getReactionByString(
           Libnucnet__Reac * self, char * s_reaction
         );
             
Input:

self: (required) A pointer to a Libnucnet reac structure.

s_reaction: (required) A string giving the reaction to be retrieved.

Output:

For valid input, the routine returns a pointer to the requested reaction. If the reaction does not exist in the Libnucnet__Reac structure, the routine returns NULL. If the input Libnucnet__Reac structure is not valid, error handling is invoked.

Example: Return a pointer to the reaction li7 + h1 -> he4 + he4 from the Libnucnet__Reac structure p_my_reactions and store it in Libnucnet__Reaction structure p_reaction:

         p_reaction =
           Libnucnet__Reac__getReactionByString(
             p_my_reactions, "li7 + h1 -> he4 + he4"
           );
               

-top-


Name: Libnucnet__Reac__is_valid_input_xml()

Description: Validate an xml file for Libnucnet__Reac.

Syntax:
         int Libnucnet__Reac__is_valid_input_xml(
           const char *s_xml_filename
         );
             
Input:

s_xml_filename: (required) A string giving the name of the xml file containing the nuclear reaction data.

Output:

For a valid input nuclear reaction data xml file, the routine returns 1 (true). For an invalid file, routine returns 0 (false). If the schema file is invalid, or if the schema file cannot be read over the web, routine stops and prints error message.

Example: Validate the input xml file "reaction_data.xml":

         if( Libnucnet__Reac__is_valid_input_xml( "reaction_data.xml" ) ) {
             printf( "Valid xml!\" );
         }
               

-top-


Name: Libnucnet__Reac__new()

Description: Create a new Libnucnet__Reac structure.

Syntax:
         Libnucnet__Reac *Libnucnet__Reac__new( );
             
Output:

The routine returns a pointer to a Libnucnet reaction structure. If the routine cannot allocate memory for the structure, Libnucnet_Reac error handling is invoked.

Example: Create a Libnucnet reaction structure p_my_reac:

         p_my_reac = Libnucnet__Reac__new();
               

-top-


Name: Libnucnet__Reac__new_from_xml()

Description: Reads in nuclear network reaction data from xml file and stores the reactions in a structure. The reactions to be stored are selected with an xpath expression.

Syntax:
         Libnucnet__Reac *Libnucnet__Reac__new_from_xml( 
           const char *s_xml_filename, char *s_xpath 
         );
             
Input:

s_xml_filename: (required) A string giving the name of the xml file contain the reaction data. This may be the name of a local file or a URL.

s_xpath: (required) A string giving an xpath expression for the reactants or products in the reaction(s) desired. If all reactions are required, this string should be empty or NULL.

Output:

If the input is valid, routine returns a pointer to a Libnucnet reaction structure containing reactions selected by the xpath expression. If no reactions were found, p_reactions_list is empty. If the input file or xpath expression is invalid, Libnucnet__Reac error handling is invoked.

Examples: Store all the reactions from "reactions.xml" to p_reactions_list:

         p_reactions_list =
           Libnucnet__Reac__new_from_xml( "reactions.xml", NULL );
               
Store the reactions from "reactions.xml" containing 'h1' as a reactant to p_h1_reactions_list:

         p_h1_reactions_list = Libnucnet__Reac__new_from_xml(
           "reactions.xml", "[reactant = 'h1']"
         );
               

-top-


Name: Libnucnet__Reac__removeReaction()

Description: Remove a reaction from a Libnucnet__Reac structure.

Syntax:
         void Libnucnet__Reac__removeReaction(
           Libnucnet__Reac *self, Libnucnet__Reaction *p_reaction
         );
             
Input:

self: (required) A pointer to a Libnucnet reac structure.

p_reaction: (required) A pointer to a Libnucnet reaction structure to be removed from self.

Output:

Upon successful return, the species has been removed from the Libnucnet__Reac structure. If the input reaction is invalid, Libnucnet__Reac error handling is invoked.

Example: Remove the first reaction from Libnucnet__Reac *p_my_reac:

         Libnucnet__Reaction *p_reaction;
         p_reaction = Libnucnet__Reac__getFirstReaction( p_my_reac );
         Libnucnet__Reac__removeReaction( p_my_reac, p_reaction );
               

-top-


Name: Libnucnet__Reac__updateFromXml()

Description: Updates nuclear network reaction data in a Libnucnet__Reac structure from and xml file.

Syntax:
         Libnucnet__Reac__updateFromXml( 
           Libnucnet__Reac *self, const char *s_xml_filename, char *s_xpath 
         );
             
Input:

self: (required) A pointer to the pre-existing Libnucnet__Reac structure to be updated.

s_xml_filename: (required) A string giving the name of the xml file contain the new reaction data. This may be the name of a local file or a URL.

s_xpath: (required) A string giving an xpath expression for the reactants or products in the reaction(s) desired. If all reactions are required, this string should be empty or NULL.

Output:

If the input is valid, routine returns a pointer to a Libnucnet

Example: Update the reaction data in p_my_reaction, with data from the file "reactions_new.xml"

         Libnucnet__Reac__updateFromXml( p_my_reactions, "reactions_new.xml", NULL );
               

-top-


Name: Libnucnet__Reac__writeToXmlFile()

Description: Output a Libnucnet__Reac structure to an xml file.

Syntax:
         void Libnucnet__Reac__writeToXmlFile(
           Libnucnet__Reac *self,
           const char *s_xml_filename
         );
             
Input:

self: (required) A pointer to a Libnucnet nuclear reaction collection.

s_xml_filename: (required) The name of the output xml file.

Output:

Upon successful return, the contents of the collection of reactions

Example: Dump the contents of Libnucnet__Reac *p_my_reactions to the xml file my.xml:

         Libnucnet__Reac__writeToXmlFile( p_my_reactions, "my.xml" );
               

-top-


Name: Libnucnet__Reaction__computeRate()

Description: Computes the rate of the reaction at the input temperature.

Syntax:
         double Libnucnet__Reaction__computeRate(
           Libnucnet__Reaction *self, double d_t9
         );
             
Input:

self: (required) A pointer to a Libnucnet reaction structure.

d_t9: (required) A double giving the temperature (in billions of K) at which to compute the rate.

Output:

Routine returns the rate for the input temperature. If the input reaction or the temperature is invalid, Libnucnet__Reac error handling is invoked.

Example: Print the rate for Libnucnet__Reaction * p_reaction at t9 = 3.:

         printf( "Rate = %e\n",
                 Libnucnet__Reaction__computeRate( p_reaction, 3. )
         );
               

-top-


Name: Libnucnet__Reaction__getDuplicateProductFactor()

Description: Routine to retrieve the factor by which to divide a reverse reaction rate to account for duplicate products.

Syntax:
         double Libnucnet__Reaction__getDuplicateProductFactor(
           Libnucnet__Reaction * self
         );
             
Input:

self: (required) A pointer to a Libnucnet reaction structure.

Output:

For valid input, the routine returns a double giving the appropriate duplicate product factor for the reaction. If the reaction does not exist in the Libnucnet__Reac structure, error handling is invoked.

Example: Print the duplicate product factor for the reaction he3 + he3 -> h1 + h1 + he4 the Libnucnet__Reac structure p_my_reactions (the result is 2! = 2 since there are two h1 products):

         printf( "Duplicate product factor = %e\n",
           Libnucnet__Reaction__getDuplicateProductFactor(
             Libnucnet__Reac__getReactionByString(
               p_my_reactions, "he3 + he3 -> h1 + h1 + he4"
             )
           )
         );
               

-top-


Name: Libnucnet__Reaction__getDuplicateReactantFactor()

Description: Routine to retrieve the factor by which to divide a forward reaction rate to account for duplicate reactants.

Syntax:
         double Libnucnet__Reaction__getDuplicateReactantFactor(
           Libnucnet__Reaction * self
         );
             
Input:

self: (required) A pointer to a Libnucnet reaction structure.

Output:

For valid input, the routine returns a double giving the appropriate duplicate reactant factor for the reaction. If the reaction does not exist in the Libnucnet__Reac structure, error handling is invoked.

Example: Print the duplicate reactant factor for the reaction he4 + he4 + he4 -> c12 + gamma from the Libnucnet__Reac structure p_my_reactions (the result is 3! = 6 since there are three he4 reactants):

         printf( "Duplicate reactant factor = %e\n",
           Libnucnet__Reaction__getDuplicateReactantFactor(
             Libnucnet__Reac__getReactionByString(
               p_my_reactions, "he4 + he4 + he4 -> c12 + gamma"
             )
           )
         );
               

-top-


Name: Libnucnet__Reaction__getIndex()

Description: Routine to return the index of a reaction in a Libnucnet__Reac structure.

Syntax:
         int Libnucnet__Reaction__getIndex( Libnucnet__Reaction *self );
             
Input:

self: (required) A pointer to a Libnucnet reaction structure.

Output:

Returns the index of the reaction in the network. If the reaction is invalid, Libnucnet__Reac error handling is invoked.

Example: Retrieve the index of reaction p_reaction:

          int i_index = Libnucnet__Reaction__getIndex( p_reaction );
               

-top-


Name: Libnucnet__Reaction__getNext()

Description: Routine to return the pointer to the next reaction in a Libnucnet__Reac structure.

Syntax:
         Libnucnet__Reaction *Libnucnet__Reaction__getNext(
           Libnucnet__Reaction *self
         );
             
Input:

self: (required) A pointer to a Libnucnet reaction structure.

Output:

Returns the pointer to the next reaction in the network. If the input reaction is invalid, error handling is invoked.

Example: Given p_reaction, get the next reaction in the network structure:

          p_reaction = Libnucnet__Reaction__getNext( p_reaction );
               

-top-


Name: Libnucnet__Reaction__getNumberOfProducts()

Description: Retrieves the number of products for the specified reaction.

Syntax:
         int Libnucnet__Reaction__getNumberOfProducts( Libnucnet__Reac *self );
             
Input:

self: (required) A pointer to a Libnucnet reaction structure.

Output:

Routine returns the number of products for reaction number i_reac. If the reaction is invalid, error handling is invoked.

Example: Get the number of products in reaction p_reaction:

         int i_products;
         i_products = Libnucnet__Reaction__getNumberOfProducts( p_reaction );
               

-top-


Name: Libnucnet__Reaction__getNumberOfReactants()

Description: Retrieves the number of reactants for the specified reaction.

Syntax:
         int Libnucnet__Reaction__getNumberOfReactants( Libnucnet__Reaction *self );
             
Input:

self: (required) A pointer to a Libnucnet reaction structure.

Output:

Routine returns the number of reactants for reaction number i_reac. If the reaction is invalid, error handling is invoked.

Example: Get the number of reactants in reaction p_reaction:

         int i_reactants;
         i_reactants = Libnucnet__Reaction__getNumberOfReactants( p_reaction );
               

-top-


Name: Libnucnet__Reaction__getPrevious()

Description: Routine to return the pointer to the previous reaction in a Libnucnet__Reac structure.

Syntax:
         Libnucnet__Reaction *Libnucnet__Reaction__getPrevious(
           Libnucnet__Reaction *self
         );
             
Input:

self: (required) A pointer to a Libnucnet reaction structure.

Output:

Returns the pointer to the previous reaction in the network. If the input reaction is invalid, error handling is invoked.

Example: Given p_reaction, get the previous reaction in the network structure:

          p_reaction = Libnucnet__Reaction__getPrevious( p_reaction );
               

-top-


Name: Libnucnet__Reaction__getSource()

Description: Retrieves the string containing the message about the source of the data for the specified reaction.

Syntax:
         char *Libnucnet__Reaction__getString( Libnucnet__Reaction *self ); 
             
Input:

self: (required) A pointer to a Libnucnet reaction structure.

Output:

Routine returns a char * containing the message about the source of the data for the reaction. If there is no information about the reaction's source, the routine returns an empty string. If the reaction is not found, error handling is invoked.

Example: Print the data source for p_reaction:

         printf( "Data source: %s\n", Libnucnet__Reaction__getSource( p_reaction ) );
               

-top-


Name: Libnucnet__Reaction__getString()

Description: Retrieves the reaction string of the specified reaction.

Syntax:
         char *Libnucnet__Reaction__getString( Libnucnet__Reaction *self ); 
             
Input:

self: (required) A pointer to a Libnucnet reaction structure.

Output:

Routine returns a char * representing the reaction string. If the reaction is not found, routine returns NULL.

Example: Print reaction string for reaction p_reaction:

         printf( "%s\n", Libnucnet__Reaction__getString( p_reaction ) );
               

-top-


Name: Libnucnet__Reaction__printRateData()

Description: Prints the rate data for a reaction.

Syntax:
         void Libnucnet__Reaction__printRateData( Libnucnet__Reaction *self );
             
Input:

self: (required) A pointer to a Libnucnet__Reaction structure.

Example: Print rate data for the reaction p_reaction:

         Libnucnet__Reaction__printRateData( p_reaction );
               

-top-




Valid XHTML 1.1        Copyright © 2001-2012, Clemson University. All rights reserved.        Valid CSS!
Page last modified on 2008/07/01 17:37