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.2/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-



User-Supplied Routine
Name: Libnucnet__Reaction__iterateFunction()

Description: User-supplied routine to be applied during an iteration over the species in the species collection.

Syntax:
         int
         Libnucnet__Reaction__iterateFunction(
           Libnucnet__Reaction *self,
           void *p_user_data
         );
             
Input:

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

p_user_data: (required) A pointer to a user-defined structure containing extra data for the iterate function.

Output:

User's routine must return 1 to continue or 0 to stop. User's routine must not modify self, that is, the pointer to the input Libnucnet__Reaction structure.


-top-



Routines
Name: Libnucnet__Reac__addReaction()

Description: Add a reaction to a reaction collection.

Syntax:
         void
         Libnucnet__Reac__addReaction(
           Libnucnet__Reac *self,
           Libnucnet__Reaction *p_reaction_to_add
         );
             
Input:

self: (required) A pointer to the Libnucnet reaction collection structure to which to add the reaction.

p_reaction_to_add: (required) A pointer to the Libnucnet reaction structure containing the reaction to add.

Output:

Upon successful return, the reaction pointed to by p_reaction_to_add has been added to self. If any input is invalid, error handling is invoked.

Example: Add the reaction p_reaction_to_add to p_my_reactions:

         Libnucnet__Reac__addReaction(
           p_my_reactions, p_reaction_to_add
         );
               

-top-


Name: Libnucnet__Reac__free()

Description: Free the memory allocated for a Libnucnet reaction collection 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__getDuplicateReactions()

Description: Routine to get duplicate reactions in a structure. A duplicate reaction is one that either has the same reactants and products as another in the reaction collection. For example, c12 + h1 to n13 + gamma and h1 + c12 to n13 + gamma are duplicate reactions. Alternatively, a duplicate reaction may be the reverse of one already in the reaction collection since libnucnet computes reverse rates from detailed balance. For example, c14 + h1 to n14 + n and n14 + n to c14 + h1 are duplicate reactions.

Syntax:
         Libnucnet__Reac *
         Libnucnet__Reac__getDuplicateReactions(
           const Libnucnet__Reac *self
         );
             
Input:

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

Output:

Returns the pointer to a new Libnucnet__Reac structure. The new structure contains the duplicate reactions. If the input reaction is invalid, error handling is invoked.

Example: Given p_my_reactions, get Libnucnet__Reac structure p_my_duplicates containing the duplicate reactions.

          p_my_duplicates =
            Libnucnet__Reac__getDuplicateReactions( p_my_reactions );
               

-top-


Name: Libnucnet__Reac__getNumberOfReactions()

Description: Retrieves the number of reactions.

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

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

Output:

Routine returns a size_t integer giving 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:

         size_t 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,
           const 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:

         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__iterateReactions()

Description: Iterate through the reactions and apply the user-supplied iterate function.

Syntax:
         void
         Libnucnet__Reac__iterateReactions(
           Libnucnet__Reac *self,
           Libnucnet__Reaction__iterateFunction pfFunc,
           void *p_user_data
         );
             
Input:

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

pfFunc: (required) The name of the user-supplied function to apply.

p_user_data: (required) A pointer to the user-defined data structure containing extra data for the user's iterate function.

Output:

The routine iterates through the reaction collection and applies the user-supplied routine to each reaction. If any input is invalid, error handling in invoked.

Example: Iterate through the reactions in p_my_reactions and apply the function my_iterate_function and the extra data in p_user_data:

         Libnucnet__Reac__iterateReactions(
           p_my_reactions,
           (Libnucnet__Reaction__iterateFunction) my_iterate_function,
           p_user_data
         );
               

-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 reaction has been removed from the Libnucnet__Reac structure. If the input reaction is invalid, Libnucnet__Reac error handling is invoked.

Example: Remove the reaction p_reaction from Libnucnet__Reac *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:
         void
         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 are written to s_xml_filename.

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__addNonSmokerFit()

Description: Add a non-smoker fit to a Libnucnet__Reaction structure.

Syntax:
          void
          Libnucnet__Reaction__addNonSmokerFit(
            Libnucnet__Reaction *self,
            const char *s_note,
            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__Reaction structure.

s_note: (required) A string containing information about the fit.

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__Reaction structure to include the new non-smoker reaction fit data. If the input is invalid or the reaction data cannot be added, Libnucnet__Reac error handling is invoked.

Example: Add the non-smoker data to a Libnucnet__Reaction *p_reaction with non-smoker data values a, spint, spinf, tlowhf, tlowfit, and acc:

         Libnucnet__Reac__addNonSmokerFit(
           p_reaction,
           "My fit data",
           a,
           spint,
           spinf,
           tlowhf,
           tlowfit,
           acc
         );
               

-top-


Name: Libnucnet__Reaction__addProduct()

Description: Add a product to a reaction.

Syntax:
          void
          Libnucnet__Reaction__addProduct(
            Libnucnet__Reaction *self,
            const char *s_product
          );
             
Input:

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

s_product: (required) A string giving the name of the product to add.

Output:

For valid input, the routine updates the Libnucnet__Reaction structure to include the product. If the input is invalid or the product cannot be added, Libnucnet__Reac error handling is invoked.

Example: Add the product "n13" to the reaction p_reaction:

         Libnucnet__Reaction__addProduct(
           p_my_reaction,
           "n13"
         );
               

-top-


Name: Libnucnet__Reaction__addReactant()

Description: Add a reactant to a reaction.

Syntax:
          void
          Libnucnet__Reaction__addReactant(
            Libnucnet__Reaction *self,
            const char *s_reactant
          );
             
Input:

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

s_reactant: (required) A string giving the name of the reactant to add.

Output:

For valid input, the routine updates the Libnucnet__Reaction structure to include the reactant. If the input is invalid or the reactant cannot be added, Libnucnet__Reac error handling is invoked.

Example: Add the reactant "h1" to the reaction p_reaction:

         Libnucnet__Reaction__addReactant(
           p_my_reaction,
           "h1"
         );
               

-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__getNumberOfProducts()

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

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

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

Output:

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

Example: Get the number of products in reaction p_reaction:

         size_t 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:
         size_t
         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:

         size_t i_reactants;
         i_reactants = Libnucnet__Reaction__getNumberOfReactants( p_reaction );
               

-top-


Name: Libnucnet__Reaction__getParentDuplicate()

Description: Get the reaction of which the current reaction is a duplicate.

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

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

Output:

The routine returns a pointer to the reaction the current reaction is a duplicate of (in the Libnucnet__Reac structure that was originally scanned for duplicates). If the parent reaction is no longer present, the routine returns NULL. If the input reaction is invalid, error handling is invoked.

Example: Print the reaction of which p_reaction is a duplicate:

         printf(
           "%s is a duplicate of %s\n",
           Libnucnet__Reaction__getString( p_reaction ),
           Libnucnet__Reaction__getString(
             Libnucnet__Reaction__getParentDuplicate( 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:
         const char *
         Libnucnet__Reaction__getSource( 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:
         const 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-


Name: Libnucnet__Reaction__updateRateTable()

Description: Update rate table for a reaction.

Syntax:
         void
         Libnucnet__Reaction__updateRateTable(
           Libnucnet__Reaction *self,
           gsl_vector *p_t9,
           gsl_vector *p_rate,
           gsl_vector *p_sef
         );
             
Input:

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

p_t9: (required) A gsl_vector containing the t9 values in the table.

p_rate: (required) A gsl_vector containing the rate values in the table.

p_sef: (required) A gsl_vector containing the sef values in the table.

Output:

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

Example: Update a Libnucnet__Reaction p_reaction table with the rate table values contained in the gsl_vectors p_t9, p_rate, and p_sef:

         Libnucnet__Reaction__addRateTable(
           p_reaction, 
           p_t9,
           p_rate,
           p_sef
         );
               

-top-


Name: Libnucnet__Reaction__updateSingleRate()

Description: Update the single reaction rate for a reaction.

Syntax:
          void
          Libnucnet__Reaction__updateSingleRate(
             Libnucnet__Reaction *self,
             double d_forward
           );
             
Input:

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

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

Output:

For valid input, the routine updates the Libnucnet__Reaction structure to have the new single rate. If the reaction data are already in the structure, they are overwritten with this data. If the input is invalid, Libnucnet__Reac error handling is invoked.

Example: Update Libnucnet__Reaction *p_my_reaction with a forward rate of 0.5:

         Libnucnet__Reaction__updateSingleRate(
           p_my_reaction,
           0.5
         );
               

-top-


Name: Libnucnet__Reaction__updateSource()

Description: Update the source string for a reaction.

Syntax:
         void
         Libnucnet__Reaction__updateSource(
           Libnucnet__Reaction *self,
           const char *s_source
         );
             
Input:

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

s_source: (required) A string giving any information about the source of the data.

Output:

For valid input, the routine updates the Libnucnet__Reaction structure to have the new source string. If the reaction source string is already in the structure, it is overwritten with this data. If the input is invalid, Libnucnet__Reac error handling is invoked.

Example: Update the reaction Libnucnet__Reaction *p_my_reaction with a message "My data":

         Libnucnet__Reaction__updateSource(
           p_my_reaction,
           "My data"
         );
               

-top-




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