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.5/src/Libnucnet__Reac.h


Table of Contents

Structures
Name: Libnucnet__Reaction__Element

Description: Libnucnet__Reaction__Element is a structure that stores data for a reaction element in a nuclear reaction network. A reaction element is either a reactant or product in the reaction. The contents of the structure are not made public by the API.

-top-


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 Routines
Name: Libnucnet__Reaction__Element__iterateFunction()

Description: User-supplied routine to be applied during an iteration over the reaction elements (reactants or products) in a reaction.

Syntax:
         int
         Libnucnet__Reaction__Element__iterateFunction(
           Libnucnet__Reaction__Element *self,
           void *p_user_data
         );
             
Input:

self: (required) A pointer to a Libnucnet__Reaction__Element 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.


-top-


Name: Libnucnet__Reaction__compare_function()

Description: User-supplied routine to sort reactions during a reaction iteration.

Syntax:
         int
         Libnucnet__Reaction__compare_function(
           const Libnucnet__Reaction *p_reaction1,
           const Libnucnet__Reaction *p_reaction2
         );
             
Input:

p_reaction1: (required) A pointer to the first reaction.

p_reaction2: (required) A pointer to the second reaction.

Output:

User's routine must return -1 if reaction 1 is less than reaction 2, 0 if the two reactions are equal, and 1 if reaction 1 is greater than reaction 2. If this routine is not supplied through Libnucnet__Reac__setReactionCompareFunction, the default is not to sort the reactions but rather to iterate them in the order in which they are stored internally, which is not defined by the user.


-top-


Name: Libnucnet__Reaction__iterateFunction()

Description: User-supplied routine to be applied during an iteration over the reactions in the reaction 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.


-top-


Name: Libnucnet__Reaction__userRateFunction()

Description: User-supplied routine to calculate the rate of a reaction.

Syntax:
         double
         Libnucnet__Reaction__userRateFunction(
           Libnucnet__Reaction *self,
           double d_t9,
           void *p_user_data
         );
             
Input:

self: (required) A pointer to a Libnucnet__Reaction.

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

p_user_data: (required) A pointer giving user-supplied data for the reaction rate calculation.

Output:

User's routine must return the rate for the reaction at the given temperature and for the extra data.


-top-


Name: Libnucnet__Reaction__user_rate_property_iterate_function()

Description: User-supplied routine to be applied during an iteration over the properties for a user-defined rate function.

Syntax:
         void
         Libnucnet__Reaction__user_rate_property_iterate_function(
           const char *s_name,
           const char *s_tag1,
           const char *s_tag2,
           const char *s_value,
           void *p_user_data
         );
             
Input:

s_name: (required) A string giving the property name.

s_tag1: (required) A string giving the first tag for the property (could be NULL).

s_tag2: (required) A string giving the second tag for the property (could be NULL).

s_value: (required) A string giving the value for the property.

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

Output:

On successful return, the function has been applied.


-top-



Routines
Name: Libnucnet__Reac__addReaction()

Description: Add a reaction to a reaction collection.

Syntax:
         int
         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:

Routine returns 1 for successful addition, 0 for failure. 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:

         if(
           Libnucnet__Reac__addReaction(
              p_my_reactions, p_reaction_to_add
           )
         )
           printf( "Successful addition.\n" ); 
               

-top-


Name: Libnucnet__Reac__clearReactionCompareFunction()

Description: Restore the default function to sort reactions during a reaction iteration.

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

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

Output:

Upon successful return, the reaction compare function for the collection has been restored to the default function. If any input is invalid, error handling is invoked.

Example: Clear the reaction compare function in p_my_reactions:

         Libnucnet__Reac__clearReactionCompareFunction(
           p_my_reactions
         );
               

-top-


Name: Libnucnet__Reac__extractSubset()

Description: Extract a subset collection of reactions from another collection by an XPath expression.

Syntax:
         Libnucnet__Reac *
         Libnucnet__Reac__extractSubset(
           const Libnucnet__Reac *self
           const char *s_xpath
         );
             
Input:

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

s_xpath: (required) A string giving an xpath expression to apply to the data or NULL to obtain a complete copy.

Output:

For a valid Libnucnet__Reac structure, the routine returns a new Libnucnet__Reac structure containing reactions selected from the parent collection by the XPath expression. The user must free the structure with Libnucnet__Reac__free() when finished with it. If the input structure is not valid, Libnucnet__Reac error handling is invoked.

Examples: Extract a complete copy of Libnucnet_Reac *p_parent and call it p_copy:

         p_copy =
           Libnucnet__Reac__extractSubset(
             p_parent,
             NULL
           );
               
Extract a subset of Libnucnet__Reac *p_parent that includes only reactions with h2 as a reactant:

         p_copy =
           Libnucnet__Reac__extractSubset(
             p_parent,
             "[reactant = 'h2']"
           );
               

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

Description: Get the extra data for a user-supplied rate function.

Syntax:
         void *
         Libnucnet__Reac__getDataForUserRateFunction(
           const Libnucnet__Reaction *self,
           const char *s_function_key
         );
             
Input:

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

s_function_key: (required) A string giving the key for the rate function function.

Output:

Routine returns a pointer to the currently defined data pointer for the extra data for the rate function defined by the input key. If the input structure is invalid, or if the rate function is not registered, error handling is invoked.

Example: Get the pointer to the extra data (a data structure with prototype my_data) for the user-defined rate function with the key "my_rate_function" from the reaction collection p_my_reactions:

         my_data *p_my_data;
         p_my_data =
           (my_data *)
           Libnucnet__Reac__getDataForUserRateFunction(
             p_my_reactions,
             "my_rate_function"
           );
               

-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 structure 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(
           const 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(
           const 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(
           const 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. The reactions are iterated in the order defined by the user-defined comparison function set with Libnucnet__Reac__setReactionCompareFunction().

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,
           const 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__registerUserRateFunction()

Description: Register a function to be used in rate calculations.

Syntax:
         int
         Libnucnet__Reac__registerUserRateFunction(
           Libnucnet__Reac *self,
           const char *s_function_key,
           Libnucnet__Reaction__userRateFunction pf_func
         );
             
Input:

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

s_function_key: (required) A string giving the key for the function.

pf_func: (required) The name of the function to be registered.

Output:

Routine returns 1 (true) if registration successful or 0 (false) if not. If the input structure is invalid, error handling is invoked.

Example: Register the function my_function with key "my rate function" in p_my_reactions:

         Libnucnet__Reac__registerUserRateFunction(
           p_my_reactions,
           "my rate function",
           (Libnucnet__Reaction__userRateFunction) my_function
         );
               

-top-


Name: Libnucnet__Reac__removeReaction()

Description: Remove a reaction from a Libnucnet__Reac structure.

Syntax:
         int
         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:

Routine returns 1 for successful removal and 0 for failure. Upon successful return, the reaction has been removed from the Libnucnet__Reac structure.

Example: Remove the reaction p_reaction from Libnucnet__Reac *p_my_reac:

         if( Libnucnet__Reac__removeReaction( p_my_reac, p_reaction ) )
           printf( "Reaction successfully removed.\n" );
               

-top-


Name: Libnucnet__Reac__setReactionCompareFunction()

Description: Set the function to sort the reactions during a reaction iteration.

Syntax:
         void
         Libnucnet__Reac__setReactionCompareFunction(
           Libnucnet__Reac *self,
           Libnucnet__Reaction__compare_function pfFunc
         );
             
Input:

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

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

Output:

Upon successful return, the data compare function for reactions in the collection has been set to the input function. If any input is invalid, error handling is invoked.

Example: Set the reaction compare function in p_my_reac to my_sort_function:

         Libnucnet__Reac__setReactionCompareFunction(
           p_my_reac,
           (Libnucnet__Reaction__compare_function) my_sort_function
         );
               

-top-


Name: Libnucnet__Reac__setUserRateFunctions()

Description: Set the user-supplied rate functions for the reactions in a collection.

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

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

Example: For the collection p_my_reactions, set all the user-supplied rate functions:

         Libnucnet__Reac__setUserRateFunctions(
           p_my_reactions
         );
               

-top-


Name: Libnucnet__Reac__updateDataForUserRateFunction()

Description: Update data for a user rate function.

Syntax:
         void
         Libnucnet__Reac__updateDataForUserRateFunction(
           Libnucnet__Reac *self,
           const char *s_function_key,
           void *p_data
         );
             
Input:

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

s_function_key: (required) A string giving the key for the function.

p_data: (required) A pointer to the user-supplied data.

Output:

On successful return, the data for the function has been updated. If the input structure is invalid or if the function key is not recognized, error handling is invoked.

Example: Update the data for the function with key "my function" in p_my_reactions with the data in the structure my_data:

         Libnucnet__Reac__updateDataForUserRateFunction(
           p_my_reactions,
           "my function",
           &my_data
         );
               

-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) in the update file desired. If all reactions are required, this string should be empty or NULL.

Output:

If the input is valid, the input Libnucnet__Reac structure is updated with the reaction data from the input file.

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

Description: Update a reaction in a reaction collection.

Syntax:
         int
         Libnucnet__Reac__updateReaction(
           Libnucnet__Reac *self,
           Libnucnet__Reaction *p_reaction
         );
             
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.

Output:

Routine returns 1 for successful addition, 0 for failure. Upon successful return, the data for the reaction has been replaced with this new version if it previously existed in the collection or has been added if it did not.

Example: Update the reaction p_reaction to in p_my_reactions:

         if(
           Libnucnet__Reac__updateReaction(
              p_my_reactions, p_reaction
           )
         )
           printf( "Successful update.\n" ); 
               

-top-


Name: Libnucnet__Reac__writeToXmlFile()

Description: Output a Libnucnet__Reac structure to an xml file.

Syntax:
         void
         Libnucnet__Reac__writeToXmlFile(
           const 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. Reactions are output in the order determined by the currently defined Libnucnet__Reaction__compare_function.

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

Description: Retrieve the name of a reaction element.

Syntax:
         const char *
         Libnucnet__Reaction__Element__getName(
           const Libnucnet__Reaction__Element *self
         );
             
Input:

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

Output:

The routine returns a string containing the name of the reaction element. If the input is invalid, error handling is invoked.

Example: Print the name of Libnucnet__Reaction__Element *p_element:

         printf(
           "The elements name is %s\n",
           Libnucnet__Reaction__Element__getName( p_element )
         );
               

-top-


Name: Libnucnet__Reaction__Element__isNuclide()

Description: Determine whether a reaction element is a nuclide (like c12) or not (like electron or neutrino_e).

Syntax:
         int
         Libnucnet__Reaction__Element__isNuclide(
           const Libnucnet__Reaction__Element *self
         );
             
Input:

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

Output:

The routine returns 1 (true) if the reactant is a nuclide or 0 (false) if not. If the input is invalid, error handling is invoked.

Example: Determine whether Libnucnet__Reaction__Element *p_element is a nuclide or not:

         if( Libnucnet__Reaction__Element__isNuclide( p_element ) ) {
           printf(
             "%s is a nuclide!\n",
             Libnucnet__Reaction__Element__getName( p_element )
           );
         } else {
           printf(
             "%s is not a nuclide!\n",
             Libnucnet__Reaction__Element__getName( p_element )
           );
         }
               

-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_thighfit,
            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_thighfit: (required) A double giving the thighfit 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, thighfit, and acc:

         Libnucnet__Reac__addNonSmokerFit(
           p_reaction,
           "My fit data",
           a,
           spint,
           spinf,
           tlowhf,
           tlowfit,
           thighfit,
           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__copy()

Description: Copy a Libnucnet__Reaction.

Syntax:
         Libnucnet__Reaction *
         Libnucnet__Reaction__copy( const Libnucnet__Reaction *p_reaction );
             
Input:

p_reaction: (required) A pointer to the reaction to be copied.

Output:

The routine returns a pointer to a new Libnucnet__Reaction structure that is a copy of the input structure. If it is not possible to allocate memory for the new structure, error handling is invoked.

Example: Create a copy of p_reaction:

         p_copy = Libnucnet__Reaction__copy( p_reaction );
               

-top-


Name: Libnucnet__Reaction__free()

Description: Free the memory allocated for a Libnucnet reaction.

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

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

Output:

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

Example: Free up memory used for Libnucnet__Reaction *p_reaction:

         Libnucnet__Reaction__free( p_reaction );
               

-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(
           const 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(
           const 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__getParentDuplicate()

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

Syntax:
         Libnucnet__Reaction *
         Libnucnet__Reaction__getParentDuplicate(
           const 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__getRateFunctionKey()

Description: Get a rate function property for a reaction.

Syntax:
         const char *
         Libnucnet__Reaction__getUserRateFunctionKey(
           const Libnucnet__Reaction *self
         );
             
Input:

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

Example: Print the key for reaction p_my_reaction:

         printf(
           "%s\n",
           Libnucnet__Reaction__getRateFunctionKey(
             p_my_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( const 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( const 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__getUserRateFunctionProperty()

Description: Get a rate function property for a reaction.

Syntax:
         const char *
         Libnucnet__Reaction__getUserRateFunctionProperty(
           const Libnucnet__Reaction *self,
           const char *s_name,
           const char *s_tag1,
           const char *s_tag2
         );
             
Input:

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

s_name: (required) A string giving the name of the property.

s_tag1: (required) A string giving the first tag of the property (could be NULL).

s_tag2: (required) A string giving the second tag of the property (could be NULL).

Output:

Routine returns the value of a rate function property. If the input reaction structure is invalid, error handling is invoked.

Example: Print the value for the property with name "prop", tag1 "8", and no tag2 for reaction p_my_reaction:

         printf(
           "%s\n",
           Libnucnet__Reaction__getUserRateFunctionProperty(
             p_my_reaction,
             "prop",
             "8",
             NULL
           )
               

-top-


Name: Libnucnet__Reaction__iterateProducts()

Description: Iterate over the products in a reaction.

Syntax:
         void
         Libnucnet__Reaction__iterateProducts(
           const Libnucnet__Reaction *self,
           Libnucnet__Reaction__Element__iterateFunction pf_func,
           void *p_user_data
         );
             
Input:

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

pf_func: (required) The name of the user-supplied iterate function to be applied during the iteration.

p_user_data: (required) A pointer to the user-supplied data structure containing the extra data to be applied during the iteration.

Output:

The routine iterates over the products in order and applies the user-supplied function and data. If the input is invalid, error handling is invoked.

Example: Iterate over the products in Libnucnet__Reaction *p_reaction and apply the function my_function and the data my_data:

         Libnucnet__Reaction__iterateProducts(
           p_reaction,
           ( Libnucnet__Reaction__Element__iterateFunction ) my_function,
           &my_data
         );
               

-top-


Name: Libnucnet__Reaction__iterateReactants()

Description: Iterate over the reactants in a reaction.

Syntax:
         void
         Libnucnet__Reaction__iterateReactants(
           const Libnucnet__Reaction *self,
           Libnucnet__Reaction__Element__iterateFunction pf_func,
           void *p_user_data
         );
             
Input:

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

pf_func: (required) The name of the user-supplied iterate function to be applied during the iteration.

p_user_data: (required) A pointer to the user-supplied data structure containing the extra data to be applied during the iteration.

Output:

The routine iterates over the reactants in order and applies the user-supplied function and data. If the input is invalid, error handling is invoked.

Example: Iterate over the reactants in Libnucnet__Reaction *p_reaction and apply the function my_function and the data my_data:

         Libnucnet__Reaction__iterateReactants(
           p_reaction,
           ( Libnucnet__Reaction__Element__iterateFunction ) my_function,
           &my_data
         );
               

-top-


Name: Libnucnet__Reaction__iterateUserRateFunctionProperties()

Description: Iterate over the properties of a user-supplied rate function.

Syntax:
         void
         Libnucnet__Reaction__iterateUserRateFunctionProperties(
           const Libnucnet__Reaction *self,
           const char *s_name,
           const char *s_tag1,
           const char *s_tag2,
           Libnucnet__Reaction__user_rate_property_iterate_function
             pf_func,
           void *p_user_data
         );
             
Input:

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

s_name: (required) The name of the property.

s_tag1: (required) The name of a tag for the property containing extra information about the property.

s_tag2: (required) The name of a second tag for the property containing extra information about the property.

pf_func: (required) A pointer to the function to be applied during the iteration.

p_user_data: (required) A pointer to the user-supplied extra data for the iterate function.

Output:

Routine iterates over the rate function properties in the reaction and applies the user-supplied function. The properties iterated over are those that match s_name, s_tag1, and s_tag2. If any of these is NULL, the comparison is a match. The properties are iterated in the order in which they are internally stored. The user does not have control over this order.

Examples: Iterate over the all rate function properties in p_reaction and apply my_func and the extra data pointed to by p_user_data:

         Libnucnet__Reaction__iterateUserRateFunctionProperties(
           p_reaction,
           NULL,
           NULL,
           NULL,
           (Libnucnet__Reaction__user_rate_property_iterate_function) my_func,
           p_user_data
         );
               
Iterate over all the rate function properties that match "t9" as a name in p_reaction and apply my_func and the extra data pointed to by p_user_data:

         Libnucnet__Reaction__iterateUserRateFunctionProperties(
           p_reaction,
           "t9",
           NULL,
           NULL,
           (Libnucnet__Reaction__user_rate_property_iterate_function) my_func,
           p_user_data
         );
               

-top-


Name: Libnucnet__Reaction__new()

Description: Create a new Libnucnet__Reaction structure.

Syntax:
         Libnucnet__Reaction *Libnucnet__Reaction__new( );
             
Output:

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

Example: Create a Libnucnet reaction p_my_reaction:

         p_my_reaction = Libnucnet__Reaction__new();
               

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

Description: Remove a rate function property for a reaction.

Syntax:
         int
         Libnucnet__Reac__removeUserRateFunctionProperty(
           Libnucnet__Reaction *self,
           const char *s_name,
           const char *s_tag1,
           const char *s_tag2
         );
             
Input:

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

s_name: (required) A string giving the name of the property.

s_tag1: (required) A string giving the first tag of the property (could be NULL).

s_tag2: (required) A string giving the second tag of the property (could be NULL).

Output:

Routine returns 1 (true) if update successful and 0 (false) if not. If the input structure is invalid, error handling is invoked.

Example: Remove the property with name "prop", tag1 "0", and no tag2 for reaction p_my_reaction:

         if(
           Libnucnet__Reaction__removeUserRateFunctionProperty(
             p_my_reaction,
             "prop",
             "0",
             NULL
           )
         )
           printf( "Successful removal!\n" );
               

-top-


Name: Libnucnet__Reaction__setUserRateFunction()

Description: Set the user-supplied rate function for a reaction.

Syntax:
         void
         Libnucnet__Reaction__setUserRateFunction(
           Libnucnet__Reaction *self,
           const char *s_function_key,
           Libnucnet__Reaction__rateFunction pf_func
         );
             
Input:

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

s_function_key: (required) A string giving the key for the function.

pf_func: (required) The name of the function to be registered.

Output:

Upon successful return, the rate function for the reaction has been set to the input. If the input structure is invalid, error handling is invoked.

Example: For p_reaction, set the rate function for the reaction to my_function with key "my rate function":

         Libnucnet__Reaction__setUserRateFunction(
           p_reaction,
           "my rate function",
           (Libnucnet__Reaction__rateFunction) my_function
         );
               

-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__updateRateTable(
           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-


Name: Libnucnet__Reaction__updateUserRateFunctionProperty()

Description: Update a rate function property for a reaction.

Syntax:
         int
         Libnucnet__Reac__updateUserRateFunctionProperty(
           Libnucnet__Reaction *self,
           const char *s_name,
           const char *s_tag1,
           const char *s_tag2,
           const char *s_value
         );
             
Input:

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

s_name: (required) A string giving the name of the property.

s_tag1: (required) A string giving the first tag of the property (could be NULL).

s_tag2: (required) A string giving the second tag of the property (could be NULL).

s_value: (required) A string giving the new value of the property.

Output:

Routine returns 1 (true) if update successful and 0 (false) if not. If the input structure is invalid, error handling is invoked.

Example: Update the data for the property with name "prop", tag1 "0", and no tag2 for reaction p_my_reaction with "new value":

         if(
           Libnucnet__Reaction__updateUserRateFunctionProperty(
             p_my_reaction,
             "prop",
             "0",
             NULL,
             "new value"
           )
         )
           printf( "Successful update!\n" );
               

-top-




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