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



liblvls/0.2/src/Liblvls.h


Table of Contents

Structures
Name: Liblvls__Level

Description: Liblvls__Level is a structure that stores data about a particular level. The contents of Liblvls__Level are not made public by the API but rather are accessed through the API routines.

-top-


Name: Liblvls__Species

Description: Liblvls__Species is a structure that stores data about a particular species. The structure is primarily composed of a hash of Liblvls__Level structures. The contents of Liblvls__Species are not made public by the API but rather are accessed through the API routines.

-top-


Name: Liblvls__SpColl

Description: Liblvls__SpColl is a structure that stores data about a collection of species. The structure is primarily composed of a hash of Liblvls__Species structures. The contents of Liblvls__SpColl are not made public by the API but rather are accessed through the API routines.

-top-


Name: Liblvls__Zone

Description: Liblvls__Zone is a structure that stores data about the probabilities of levels of species in a zone. A zone is labelled by three strings. If zone labels are not provided by the user, zones are labelled ( "n", "0", "0" ) where n is an integer that increments for each zone added to the Liblvls structure, starting with zero. Any missing labels will be filled in with "0". For example, if two zones are provided without labels, the first zone would be given labels ( "0", "0", "0" ), and the second would be given labels ( "1", "0", "0" ). A Liblvls__Zone structure also contains a pointer to the Liblvls__SpColl structure. A Liblvls structure thus contains data that can change with each timestep in a calculation (species level probabilities) along with data that are fixed. The contents of Liblvls__Zone are not made public by the API but rather are accessed through the API routines.

-top-


Name: Liblvls

Description: Liblvls is a structure that stores data about level systems of species in a multi-zone system. It is composed of a Liblvls__SpColl structure and a hash of Liblvls__Zone structures. The contents of Liblvls are not made public by the API but rather are accessed through the API routines.

-top-



User-Supplied Routines
Name: Liblvls__Level__iterateFunction()

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

Syntax:
         int
         Liblvls__Level__iterateFunction(
           Liblvls__Level *self,
           void *p_user_data
         );
             
Input:

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

Description: Optional user-supplied routine to calculate transition rates between two levels.

Syntax:
         int
         Liblvls__Level__transitionRatesFunction(
           Liblvls__Level *p_upper_level,
           Liblvls__Level *p_lower_level,
           double d_temperature,
           double *p_up_rate,
           double *p_down_rate,
           void *p_user_data
         );
             
Input:

p_upper_level: (required) A pointer to a Liblvls__Level structure.

p_lower_level: (required) A pointer to a Liblvls__Level structure.

d_temperature: (required) The temperature (in K) at which to calculate transition rates.

p_up_rate: (required) A pointer to a double to be modified to the rate (per second) for the transition from the lower energy level to the higher.

p_down_rate: (required) A pointer to a double to be modified to the rate (per second) for the transition from the higher energy level to the lower.

p_user_data: (required) A pointer to any additional data required to calculate the transition rate using this user-supplied function, or NULL if no extra data are required.

Output:

p_up_rate: (required) A pointer to a double to be modified to the rate (per second) for the transition from the lower energy level to the higher.

p_down_rate: (required) A pointer to a double to be modified to the rate (per second) for the transition from the higher energy level to the lower.

User's routine must return 1 on success or 0 on failure. The user's routine must not modify any Liblvls__Level pointer passed in as an argument.


-top-


Name: Liblvls__Species__iterateFunction()

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

Syntax:
         int
         Liblvls__Species__iterateFunction(
           Liblvls__Species *self,
           void *p_user_data
         );
             
Input:

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

Description: User-supplied routine to be applied during an iteration over the zones.

Syntax:
         int
         Liblvls__Zone__iterateFunction(
           Liblvls__Zone *self,
           void *p_user_data
         );
             
Input:

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



Routines
Name: Liblvls__Level__computeBoltzmannFactor()

Description: Routine to compute the Boltzmann factor for a given level at the input temperature.

Syntax:
         double
         Liblvls__Level__computeBoltzmannFactor(
           const Liblvls__Level *self,
           double d_temperature
         );
             
Input:

self: (required) A pointer to a Liblvls level structure.

d_temperature: (required) A double giving the temperature at which to compute the Boltzmann factor.

Output:

Routine returns a double containing the Boltzmann factor for the given level at the input temperature. If the level is not found or the temperature is not valid (< 0), error handling is invoked.

Example: Print the Boltzmann factor for Liblvls__Level *p_level at 100,000 K:

         printf(
           "Boltzmann factor = %e\n",
           Liblvls__Level__computeBoltzmannFactor(
             p_level, 100000.
           )
         );
               

-top-


Name: Liblvls__Level__computeEinsteinCoefficients()

Description: Routine to compute the Einstein Coefficients for transitions from a given level to another.

Syntax:
         void
         Liblvls__Level__computeEinsteinCoefficients(
           Liblvls__Level *p_upper_level,
           Liblvls__Level *p_lower_level,
           double *p_a_ij,
           double *p_b_ij,
           double *p_b_ji
         );
             
Input:

p_upper_level: (required) A pointer to a Liblvls__Level structure. This is the level from which there can be a spontaneous decay; therefore, it should lie higher in energy than the level pointed to by p_lower_level.

p_lower_level: (required) A pointer to a Liblvls__Level structure. This is the level to which a spontaneous decay occurs; therefore, it should lie lower in energy than the level pointed to by p_upper_level.

Output:

p_a_ij: (required) A pointer to a double giving the Einstein A coefficient for the spontaneous downward transition (per second).

p_b_ij: (required) A pointer to a double giving the Einstein B coefficient for the induced emission transition (in units of seconds per erg).

p_b_ji: (required) A pointer to a double giving the Einstein B coefficient for the induced absorption transition (in units of seconds per erg).

Example: Print the Einstein coefficients for the transitions between the first and second excited states of neutral 4He (stored in Liblvls__SpColl *p_my_species as he4i):

         p_he4_i =
           Liblvls__SpColl__getSpecies( p_my_species, "he4i" );
         if( p_he4_i ) {
           p_level_i = Liblvls__Species__getLevel( p_he4_i, 2 );
           p_level_j = Liblvls__Species__getLevel( p_he4_i, 1 );
           Liblvls__Level__computeEinsteinCoefficients(
             p_level_i, p_level_j, &d_aij, &d_bij, &d_bji
           );
           printf(
             "A_ij = %e (per second)\n", d_aij
           );
           printf(
             "B_ij = %e (seconds per erg)\n", d_bij
           );
           printf(
             "B_ji = %e (seconds per erg)\n", d_bji
           );
         }
               

-top-


Name: Liblvls__Level__getEnergy()

Description: Routine to retrieve the energy (in specified units) of a given level.

Syntax:
         double
         Liblvls__Level__getEnergy(
           const Liblvls__Level *self, int i_units
         );
             
Input:

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

i_units: (required) An integer to set the units for the returned energy. User may supply EV, KEV, MEV, or GEV for eV, keV, MeV, or GeV, respectively.

Output:

A double giving the energy (in the chosen units) of the desired level. If the level or the input unit is not valid, error handling is invoked.

Example: Print the energy (in eV) of the fifth level of doubly ionized 12C (stored as c12iii) in the species collection p_my_species:

         p_c12_iii =
           Liblvls__SpColl__getSpecies( p_my_species, "c12iii" );
         if( p_c12_iii ) {
           p_level = Liblvls__Species__getLevelByIndex( p_c12_iii, 4 );
           if( p_level ) {
             printf(
               "Energy (eV) = %e\n",
               Liblvls__Level__getEnergy( p_level, EV )
             );
           }
         }
               

-top-


Name: Liblvls__Level__getIndex()

Description: Routine to retrieve the index of a given level.

Syntax:
         size_t
         Liblvls__Level__getIndex(
           const Liblvls__Level *self
         );
             
Input:

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

Output:

A size_t giving the index of the desired level. If the level is not valid, error handling is invoked.

Example: Retrieve the index of the Liblvls__Level *p_level:

         i_level = Liblvls__Level__getIndex( p_level );
               

-top-


Name: Liblvls__Level__getMultiplicity()

Description: Routine to retrieve the multiplicity of a given level.

Syntax:
         unsigned int
         Liblvls__Level__getMultiplicity(
           const Liblvls__Level *self
         );
             
Input:

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

Output:

An unsigned int giving the multiplicity of the desired level. If the level is not valid, error handling is invoked.

Example: Print the multiplicity of the ground state of neutral 16O (stored as o16i) in the species collection p_my_species (assuming levels are correctly sorted in terms of energy):

         p_o16_i =
           Liblvls__SpColl__getSpecies( p_my_species, "o16i" );
         if( p_o16_i ) {
           p_level = Liblvls__Species__getLevelByIndex( p_o16_i, 0 );
           if( p_level ) {
             printf(
               "Multiplicity = %d\n",
               Liblvls__Level__getMultiplicity( p_level )
             );
           }
         }
               

-top-


Name: Liblvls__Level__getProperty()

Description: Routine to retrieve property information for a level.

Syntax:
         const char *
         Liblvls__Level__getProperty(
           const Liblvls__Level *self,
           const char *s_label1,
           const char *s_label2,
           const char *s_label3
         );
             
Input:

self: (required) A pointer to a Liblvls__Level.

s_label1: (required) A string containing the first label for the property to retrieve.

s_label2: (required) A string containing the second label for the property to retrieve.

s_label3: (required) A string containing the third label for the property to retrieve.

Output:

If the property is found, a const char * pointing to the property is returned. If the property is not found, NULL is returned.

Example: Retrieve a property named "parity" from level my_level:

         s_parity =
           Liblvls__Level__getProperty(
             my_level, "parity", NULL, NULL
           );
               

-top-


Name: Liblvls__Level__new()

Description: Routine to create a new level.

Syntax:
         Liblvls__Level *
         Liblvls__Level__new(
           double d_energy,
           unsigned int i_multiplicity
         );
             
Input:

d_energy: (required) A double giving the energy in keV of the new level.

i_multiplicity: (required) An unsigned int giving the multiplicity of the new level.

Output:

Routine returns a pointer to a new level. If memory cannot be allocated, error handling is invoked.

Example: Create a level with energy 104.03 keV, and multiplicity of 3:

         p_new_level =
           Liblvls__Level__new( 104.03, 3 );
              

-top-


Name: Liblvls__Level__updateProperty()

Description: Routine to update a user-defined property for a level.

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

self: (required) A pointer to a Liblvls__Level.

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

s_tag1: (required) A string giving the first optional tag (may be NULL) of the property to be updated.

s_tag2: (required) A string giving the second optional tag (may be NULL) of the property to be updated.

s_value: (required) A string containing the data to be stored.

Output:

Routine returns true (1) if the property was successfully updated and false (0) if not. On successful return, the data for the property has been either added (if the data for the property didn't previously exist) or updated (if the property did previously exist). If the level to which the property is to be attached is not valid, error handling is invoked.

Example: Update the level p_level to include an parity stored in the string named s_parity:

         Liblvls__Level__updateProperty(
           p_level,
           "parity",
           NULL,
           NULL,
           s_parity
         );
              

-top-


Name: Liblvls__Level__updateTransitionData()

Description: Routine to update the data for a transition from a level.

Syntax:
         void
         Liblvls__Level__updateTransitionData(
           Liblvls__Level *self,
           double d_to_energy,
           unsigned int i_to_multiplicity,
           double d_A
         );
             
Input:

self: (required) A pointer to a Liblvls level.

d_to_energy: (required) A double giving the energy of the level the transition goes to.

i_to_multiplicity: (required) An unsigned int giving the multiplicity of the level the transition goes to.

d_A: (required) A double giving the Einstein A coefficient for the transition.

Output:

Upon successful return, the data for the transition has been either added (if the data for the transition didn't previously exist) or updated (if the data did previously exist). If the level from which the transition starts is not valid, error handling is invoked. The transition will be created or updated even if the target level is invalid.

Example: Update the Einstein A coefficient for the transition from the level p_level to the level with energy 100. keV, multiplicity 3, with the new rate 1.e13:

         Liblvls__Level__updateTransitionData(
           p_level, 100., 3, 1.e13
         );
              

-top-


Name: Liblvls__SpColl__addSpecies()

Description: Routine to add a species to a species collection.

Syntax:
         void
         Liblvls__SpColl__addSpecies(
           Liblvls__SpColl *self,
           Liblvls__Species *p_species
         );
             
Input:

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

p_species: (required) A pointer to the Liblvls__Species to add.

Output:

Upon successful return, the species has been added to the collection. If the species cannot be added error handling is invoked.

Example: Create a species c12ii (singly-ionized c12) and add it to the collection p_my_collection:

         p_c12ii =
           Liblvls__Species__new( "c12ii" );
         Liblvls__SpColl__addSpecies( p_my_collection, p_c12ii );
              

-top-


Name: Liblvls__SpColl__free()

Description: Routine to free the memory allocated for a Liblvls__SpColl structure.

Syntax:
         void
         Liblvls__SpColl__free
           Liblvls__SpColl *self
         );
             
Input:

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

Output:

Upon successful return, the memory for the species collection structure has been freed.

Example: Free the memory previously allocated for the Liblvls__SpColl structure p_my_collection:

         Liblvls__SpColl__free( p_my_collection );
               

-top-


Name: Liblvls__SpColl__getNumberOfSpecies()

Description: Routine to get the number of species in a Liblvls__SpColl structure.

Syntax:
         size_t
         Liblvls__SpColl__getNumberOfSpecies(
           const Liblvls__SpColl *self
         );
             
Input:

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

Output:

A size_t giving the number of species in the Liblvls__SpColl structure.

Example: Print the number of species in p_my_species:

         printf(
           "Number of species = %d\n",
           Liblvls__SpColl__getNumberOfSpecies( p_my_species )
         );
               

-top-


Name: Liblvls__SpColl__getProperty()

Description: Routine to retrieve property information for a species collection.

Syntax:
         const char *
         Liblvls__SpColl__getProperty(
           const Liblvls__SpColl *self,
           const char *s_label1,
           const char *s_label2,
           const char *s_label3
         );
             
Input:

self: (required) A pointer to a Liblvls__SpColl.

s_label1: (required) A string containing the first label for the property to retrieve.

s_label2: (required) A string containing the second label for the property to retrieve.

s_label3: (required) A string containing the third label for the property to retrieve.

Output:

If the property is found, a const char * pointing to the property is returned. If the property is not found, NULL is returned.

Example: Retrieve a property named "group_name" from species collection my_spcoll:

         s_group_name =
           Liblvls__SpColl__getProperty(
             my_spcoll, "group_name", NULL, NULL
           );
               

-top-


Name: Liblvls__SpColl__getSpecies()

Description: Routine to retrieve a species from a species collection.

Syntax:
         Liblvls__Species *
         Liblvls__SpColl__getSpecies(
           const Liblvls__SpColl *self,
           const char *s_species
         );
             
Input:

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

s_species: (required) A string giving the name of the desired species.

Output:

A pointer to the Liblvls__Species structure for the desired species. If the species cannot be found, the routine returns NULL.

Example: Retrieve the pointer to the Liblvls__Species structure for neutral 4He (he4i) from the Liblvls__SpColl structure p_my_species:

         p_he4_i =
           Liblvls__SpColl__getSpecies( 
             p_my_species, "he4i"
           );
               

-top-


Name: Liblvls__SpColl__is_valid_input_xml()

Description: Routine to check an input species collection xml file against the schema for validity.

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

s_xml_filename: (required) A string containing the name of the file to be checked for validity.

Output:

Returns 1 for a valid xml input file, 0 for invalid input, and prints an error if the schema file is invalid or unable to be read over the web.

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

         if( Liblvls__SpColl__is_valid_input_xml( "species_collection.xml" ) ) {
           printf( "Valid xml input!\n" );
         }
               

-top-


Name: Liblvls__SpColl__iterateSpecies()

Description: Iterate through the species in a given species collection and apply the user-supplied iterate function.

Syntax:
         void
         Liblvls__SpColl__iterateSpecies(
           const Liblvls__SpColl *self,
           Liblvls__Species__iterateFunction pf_func,
           void *p_user_data
         );
             
Input:

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

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

p_user_data: (required) A pointer to the user-defined extra data.

Output:

The routine iterates through the species and applies the user-supplied routine to each. Species are iterated in alphabetical order according their names. If any input is invalid, error handling is invoked.

Example: Iterate through the species in Liblvls__SpColl p_my_spcoll and apply the function my_iterate_function using the extra data in p_user_data:

         Liblvls__SpColl__iterateSpecies(
           p_my_spcoll,
           (Liblvls__Species__iterateFunction) my_iterate_function,
           p_user_data
         );
               

-top-


Name: Liblvls__SpColl__new()

Description: Routine to create a new Liblvls__SpColl structure.

Syntax:
         Liblvls__SpColl *Liblvls__SpColl__new( );
             
Output:

A pointer to a new Liblvs__SpColl structure.

Example: Create the Liblvls__SpColl structure p_my_species:

         p_my_species = Liblvls__SpColl__new( );
               

-top-


Name: Liblvls__SpColl__new_from_xml()

Description: Routine to read in level data from an xml file and store them into a Liblvls data structure. Duplicate entries for a given species in the xml file will be overwritten in the returned structure.

Syntax:
         Liblvls__SpColl *
         Liblvls__SpColl__new_from_xml(
           const char *s_xml_filename,
           const char *s_xpath_suffix
         );
             
Input:

s_xml_filename: (required) s_xml_filename is the name of the xml file that contains the level data.

s_xpath_suffix: (required) A string giving an xpath expression to apply.

Output:

A pointer to a Liblvls__SpColl structure containing the level data.

Example: Store the level data in levels.xml to p_species_collection:

         p_species_collection =
           Liblvls__SpColl__new_from_xml( "levels.xml", NULL );
               

-top-


Name: Liblvls__SpColl__updateFromXml()

Description: Routine to update a pre-existing Liblvls__SpColl structure with data from an xml file. Replaces existing species data and adds data about new species.

Syntax:
         void
         Liblvls__SpColl__updateFromXml(
           Liblvls__SpColl *self,
           const char *s_xml_filename,
           const char *s_xpath_suffix
         );
             
Input:

self: (required) A pointer to the Liblvls__SpColl structure to be updated.

s_xml_filename: (required) s_xml_filename is the name of the xml file that contains the level data.

s_xpath_suffix: (required) A string giving an xpath expression to apply.

Output:

For a valid Liblvls__SpColl structure and a valid input data xml file, the routine updates the structure with the data in the input data file. If the routine cannot allocate enough memory or if the xpath expression is invalid, error handling is invoked.

Example: Update p_species_collection with the data stored in levels.xml:

         Liblvls__SpColl__updateFromXml( p_species_collection, "levels.xml", NULL );
               

-top-


Name: Liblvls__SpColl__updateProperty()

Description: Routine to update a user-defined property for a species collection.

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

self: (required) A pointer to a Liblvls__SpColl.

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

s_tag1: (required) A string giving the first optional tag (may be NULL) of the property to be updated.

s_tag2: (required) A string giving the second optional tag (may be NULL) of the property to be updated.

s_value: (required) A string containing the data to be stored.

Output:

Routine returns true (1) if the property was successfully updated and false (0) if not. On successful return, the data for the property has been either added (if the data for the property didn't previously exist) or updated (if the property did previously exist). If the collection to which the property is to be attached is not valid, error handling is invoked.

Example: Update the species collection p_spcoll to include a group number stored in the string named s_group_number:

         Liblvls__SpColl__updateProperty(
           p_spcoll,
           "group_number",
           NULL,
           NULL,
           s_group_number
         );
              

-top-


Name: Liblvls__SpColl__writeToXmlFile()

Description: Output a Liblvls__SpColl structure to an xml file.

Syntax:
         void
         Liblvls__SpColl__writeToXmlFile(
           const Liblvls__SpColl *self,
           const char *s_xml_filename
         );
             
Input:

self: (required) A pointer to a Liblvls species collection.

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

Output:

Upon successful return, the contents of the collection of species have been written to an xml file. If the input is invalid, Liblvls error handling is invoked.

Example: Dump the contents of Liblvls_SpColl *p_sp_coll to the xml file my.xml:

         Liblvls__SpColl__writeToXmlFile( p_sp_coll, "my.xml" );
               

-top-


Name: Liblvls__Species__addLevel()

Description: Routine to add a level to a species.

Syntax:
         void
         Liblvls__Species__addLevel(
           Liblvls__Species *self,
           Liblvls__Level *p_level
         );
             
Input:

self: (required) A pointer to a Liblvls__Species.

p_level: (required) A pointer to the Liblvls__Level to add.

Output:

Upon successful return, the level has been added to the species. If the level cannot be added error handling is invoked.

Example: Create a level with energy 50 keV and multiplicity 3, and add it to p_species:

         p_new_level =
           Liblvls__Level__new( 50., 3 ).
         Liblvls__Species__addLevel( p_species, p_new_level );
              

-top-


Name: Liblvls__Species__clearTransitionRatesFunction()

Description: Routine to clear the transition rates function for a species.

Syntax:
         void
         Liblvls__Species__clearTransitionRatesFunction(
           Liblvls__Species *self
         );
             
Input:

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

Example: Clear the transition rates function for p_species.

         Liblvls__Species__clearTransitionRatesFunction(
           p_species
         );
               

-top-


Name: Liblvls__Species__computeLevelEquilibriumProbabilities()

Description: Compute the equilibrium probabilities for a levels of a species for the input temperature.

Syntax:
         gsl_vector *
         Liblvls__Species__computeLevelEquilbriumProbabilities(
           Liblvls__Species *self,
           double d_T
         );
             
Input:

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

d_T: (required) The temperature (in K) at which to compute the probabilities.

Output:

Returns a new gsl_vector containing the equilibrium probabilites for all levels in the species. The probabilities are located in the vector according to the level index (ground state with index 0). If any input is invalid, error handling is invoked.

Example: Compute the equilibrium probabilities for all levels in p_species at 10,000 K:

         p_equilibrium_probabilities =
           Liblvls__Species__computeLevelEquilibriumProbabilities(
             p_species,
             1.e4
           );
               

-top-


Name: Liblvls__Species__computePartitionFunction()

Description: Routine to retrieve the partition function for a species at the specified temperature (in K).

Syntax:
         double
         Liblvls__Species__computePartitionFunction(
           Liblvls__Species *self,
           double d_temperature
         );
             
Input:

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

d_temperature: (required) A double giving the temperature (in K) at which to compute the partition function.

Output:

A double giving the partition function. If the species is invalid or if the temperature is negative, error handling is invoked.

Example: Print the partition function for neutral 1H (stored in the species collection Liblvls__SpColl *p_my_species as h1i) at 20,000 K:

         p_h1_i =
           Liblvls__SpColl__getSpecies( p_my_species, "h1i" );
         if( p_h1_i ) {
           printf(
             "Partition function at 20,000 K = %e\n",
               Liblvls__Species __computePartitionFunction( p_h1i, 20000. )
           );
         }
               

-top-


Name: Liblvls__Species__computeRateMatrix()

Description: Routine to compute the rate matrix for a species at a specified temperature.

Syntax:
         WnMatrix *
         Liblvls__Species__computeRateMatrix(
           Liblvls__Species *self,
           double d_temperature,
           void *p_user_rate_data
         );
             
Input:

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

d_temperature: (required) A double giving the temperature at which to compute the rate matrix.

p_user_rate_data: (required) A pointer to data to be used when calculating transition rates with a user-supplied rate function, or NULL if no extra data are required.

Output:

Routine returns the rate matrix in native WnMatrix format. If the species is not found or the temperature is not valid (< 0), error handling is invoked.

Example: Return the rate matrix for neutral 1H (stored as h1i in the species collection p_my_collection) at 15,000 K with no extra data:

         p_matrix =
           Liblvls__Species__computeRateMatrix(
             Liblvls__SpColl_getSpecies( p_my_collection, "h1i" ),
             15000.,
             NULL
           );
               

-top-


Name: Liblvls__Species__computeRatesForTransition()

Description: Routine to retrieve the rates for transitions from a given level to another using a rate calculation specified by the species.

Syntax:
         void
         Liblvls__Species__computeRatesForTransition(
           Liblvls__Species *self
           Liblvls__Level *p_upper_level,
           Liblvls__Level *p_lower_level,
           double d_temperature,
           double *p_up_rate,
           double *p_down_rate,
           void *p_user_data
         );
             
Input:

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

p_upper_level: (required) A pointer to a Liblvls__Level structure. This is the level from which there can be a spontaneous decay; therefore, it must lie higher in energy than the level pointed to by p_lower_level.

p_lower_level: (required) A pointer to a Liblvls__Level structure. This is the level to which a spontaneous decay occurs; therefore, it must lie lower in energy than the level pointed to by p_upper_level.

d_temperature: (required) A double giving the temperature (in K) at which to calculate the transition rates.

p_up_rate: (required) A pointer to a double to be modified to the rate (per second) for the transition from the lower energy level to the higher.

p_down_rate: (required) A pointer to a double to be modified to the rate (per second) for the transition from the higher energy level to the lower.

p_user_data: (required) A pointer supplying any additional data needed to compute transition rates using a user-supplied function, or NULL if no extra data are required.

Output:

p_up_rate: (required) A pointer to a double to be modified to the rate (per second) for the transition from the lower energy level to the higher.

p_down_rate: (required) A pointer to a double to be modified to the rate (per second) for the transition from the higher energy level to the lower.

Example: Print the rates for the transitions between the first and second excited states of neutral 4He (stored in Liblvls__SpColl *p_my_species as he4i) at 35,000 K with no extra data:

         p_he4_i =
           Liblvls__SpColl__getSpecies( p_my_species, "he4i" );
         if( p_he4_i ) {
           p_level_i = Liblvls__Species__getLevel( p_he4_i, 2 );
           p_level_j = Liblvls__Species__getLevel( p_he4_i, 1 );
           Liblvls__Level__computeRatesForTransition(
             p_my_species,
             p_level_i,
             p_level_j,
             35000.,
             &d_up_rate,
             &d_down_rate,
             NULL
           );
           printf(
             "rate up = %e (per second)\n", d_up_rate
           );
           printf(
             "rate down = %e (per second)\n", d_down_rate
           );
         }
               

-top-


Name: Liblvls__Species__free()

Description: Routine to free the memory allocated for a Liblvls__Species structure.

Syntax:
         void
         Liblvls__Species__free
           Liblvls__Species *self
         );
             
Input:

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

Output:

Upon successful return, the memory for the species structure has been freed.

Example: Free the memory previously allocated for the Liblvls__Species structure p_species:

         Liblvls__Species__free( p_species );
               

-top-


Name: Liblvls__Species__getLevel()

Description: Routine to retrieve a level from a species.

Syntax:
         Liblvls__Level *
         Liblvls__Species__getLevel(
           const Liblvls__Species *self,
           double d_energy,
           unsigned int i_multiplicity
         );
             
Input:

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

d_energy: (required) A double giving the energy of the desired level in keV.

i_multiplicity: (required) An unsigned int giving the multiplicity of the desired level.

Output:

A pointer to the Liblvls__Level structure for the desired level. If the level cannot be found, the routine returns NULL.

Example: Retrieve the pointer p_level to the level in neutral 4He (he4i) with energy 21010 keV, and multiplicity 1 in the Liblvls__SpColl structure p_my_species:

         p_he4_i =
           Liblvls__SpColl__getSpecies( 
             p_my_species, "he4i"
           );
         p_level =
           Liblvls__Species__getLevel(
             p_he4_i, 21010., 1
         );
               

-top-


Name: Liblvls__Species__getLevelByIndex()

Description: Routine to retrieve a level from a species.

Syntax:
         Liblvls__Level *
         Liblvls__Species__getLevelByIndex(
           const Liblvls__Species *self,
           size_t i_level
         );
             
Input:

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

i_level: (required) A size_t giving the number of the desired level (zero-indexed so that the ground state is i_level = 0).

Output:

A pointer to the Liblvls__Level structure for the desired level. If the level cannot be found, the routine returns NULL.

Example: Retrieve the pointer p_level to the fourth level in neutral 4He (he4i) in the Liblvls__SpColl structure p_my_species:

         p_he4_i =
           Liblvls__SpColl__getSpecies( 
             p_my_species, "he4i"
           );
         p_level =
           Liblvls__Species__getLevelByIndex(
             p_he4_i, 3L
         );
               

-top-


Name: Liblvls__Species__getName()

Description: Routine to return the name of a species.

Syntax:
         const char *
         Liblvls__Species__getName(
           const Liblvls__Species *self
         );
             
Input:

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

Output:

Routine returns a string containing the name of the species. If the species is not found, error handling is invoked.

Example: Print the name of the species p_species:

         printf(
           "The name of the species is %s\n",
           Liblvls__Species__getName( p_species )
         );
               

-top-


Name: Liblvls__Species__getNumberOfLevels()

Description: Routine to get the number of levels in a Liblvls__Species structure.

Syntax:
         size_t
         Liblvls__Species__getNumberOfLevels(
           const Liblvls__Species *self
         );
             
Input:

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

Output:

A size_t giving the number of levels in the Liblvls__Species structure.

Example: Print the number of levels in triply-ionized 56Fe (fe56iv) in the species collection p_my_species:

         p_fe56_iv =
           Liblvls__SpColl__getSpecies( 
             p_my_species, "fe56iv"
           );
         if( p_fe56_iv ) {
           printf(
             "Number of levels in fe56iv = %d\n",
             Liblvls__Species__getNumberOfLevels( p_fe56_iv )
           );
         }
               

-top-


Name: Liblvls__Species__getProperty()

Description: Routine to retrieve property information for a species.

Syntax:
         const char *
         Liblvls__Species__getProperty(
           const Liblvls__Species *self,
           const char *s_label1,
           const char *s_label2,
           const char *s_label3
         );
             
Input:

self: (required) A pointer to a Liblvls__Species.

s_label1: (required) A string containing the first label for the property to retrieve.

s_label2: (required) A string containing the second label for the property to retrieve.

s_label3: (required) A string containing the third label for the property to retrieve.

Output:

If the property is found, a const char * pointing to the property is returned. If the property is not found, NULL is returned.

Example: Retrieve a property called "atomic_number" from species my_species:

         s_atomic_number =
           Liblvls__Species__getProperty(
             my_species, "atomic_number", NULL, NULL
           );
               

-top-


Name: Liblvls__Species__iterateLevels()

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

Syntax:
         void
         Liblvls__Species__iterateLevels(
           const Liblvls__Species *self,
           Liblvls__Level__iterateFunction pf_func,
           void *p_user_data
         );
             
Input:

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

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

p_user_data: (required) A pointer to the user-defined extra data.

Output:

The routine iterates through the levels and applies the user-supplied routine to each. Levels are iterated according to their index. If any input is invalid, error handling is invoked.

Example: Iterate through the levels in p_my_species and apply the function my_iterate_function and the extra data in p_user_data:

         Liblvls__Species__iterateLevels(
           p_my_species,
           (Liblvls__Level__iterateFunction) my_iterate_function,
           p_user_data
         );
               

-top-


Name: Liblvls__Species__new()

Description: Routine to create a new species.

Syntax:
         Liblvls__Species *
         Liblvls__Species__new(
            const char *s_species_name
         );
             
Input:

s_species_name: (required) A string giving the name of the species to add.

Output:

Routine returns a pointer to a new species. If memory cannot be allocated, error handling is invoked.

Example: Create the species c12ii (singly-ionized carbon-12):

         p_c12_ii = Liblvls__Species__new( "c12ii" );
              

-top-


Name: Liblvls__Species__removeLevel()

Description: Routine to remove a level from a species.

Syntax:
         int 
         Liblvls__Species__removeLevel(
           Liblvls__Species *self,
           Liblvls__Level *p_level
         );
             
Input:

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

p_level: (required) A pointer to the level to be removed.

Output:

Routine returns 1 (true) if removal successful and 0 (false) if not. Upon successful return, the level has been removed from the species. If any input is invalid, or if the level cannot be removed, error handling is invoked.

Example: Remove the level with energy 50 keV and multiplicity 3 from the species stored in p_species:

          p_level = Liblvls__Species__getLevel( p_species, 50., 3 );
          Liblvls__Species__removeLevel( p_species, p_level );
              

-top-


Name: Liblvls__Species__setTransitionRatesFunction()

Description: Routine to set the optional user-supplied transition rates function for a species.

Syntax:
         void
         Liblvls__Species__setTransitionRatesFunction(
           Liblvls__Species *self,
           Liblvls__Level__rateFunction pf_user_function
         );
             
Input:

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

pf_user_function: (required) The name of the user-supplied rate calculator.

Example: Set the user-supplied rate function to my_rate_function for p_species.

         Liblvls__Species__setTransitionRatesFunction(
           p_species,
           (Liblvls__Level__transitionRatesFunction) my_rate_function
         );
               

-top-


Name: Liblvls__Species__updateLevelEnergy()

Description: Routine to self-consistently update the energy of a level in a given species.

Syntax:
         void
         Liblvls__Species__updateLevelEnergy(
           Liblvls__Species *self,
           Liblvls__Level *p_level,
           double d_new_energy
         );
             
Input:

self: (required) A pointer to the species in which the level to be modified resides.

p_level: (required) A pointer to the level.

d_new_energy: (required) A double containing the new energy for the level.

Example: Change the energy of p_level contained in p_species to 53 keV:

         Liblvls__Species__updateLevelEnergy(
           p_species,
           p_level,
           53.
         );
               

-top-


Name: Liblvls__Species__updateLevelMultiplicity()

Description: Routine to self-consistently update the multiplicity of a level in a given species.

Syntax:
         void
         Liblvls__Species__updateLevelMultiplicity(
           Liblvls__Species *self,
           Liblvls__Level *p_level,
           unsigned int i_new_multiplicity
         );
             
Input:

self: (required) A pointer to the species in which the level to be modified resides.

p_level: (required) A pointer to the level.

i_new_multiplicity: (required) An integer containing the new multiplicity for the level.

Example: Change the multiplicity of p_level contained in p_species to 5:

         Liblvls__Species__updateLevelMultiplicity(
           p_species,
           p_level,
           5
         );
               

-top-


Name: Liblvls__Species__updateProperty()

Description: Routine to update a user-defined property for a species.

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

self: (required) A pointer to a Liblvls__Species.

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

s_tag1: (required) A string giving the first optional tag (may be NULL) of the property to be updated.

s_tag2: (required) A string giving the second optional tag (may be NULL) of the property to be updated.

s_value: (required) A string containing the data to be stored.

Output:

Routine returns true (1) if the property was successfully updated and false (0) if not. On successful return, the data for the property has been either added (if the data for the property didn't previously exist) or updated (if the property did previously exist). If the species to which the property is to be attached is not valid, error handling is invoked.

Example: Update the species p_species to include an atomic number stored in the string named s_atomic_number:

         Liblvls__Species__updateProperty(
           p_species,
           "atomic_number",
           NULL,
           NULL,
           s_atomic_number
         );
              

-top-


Name: Liblvls__Zone__computeFlowVector()

Description: Routine to compute the flow vector for a particular species in a given zone at the input temperature. The elements of this vector are the net flow (flow in - flow out) into each level.

Syntax:
         gsl_vector *
         Liblvls__Zone__computeFlowVector(
           Liblvls__Zone *self,
           Liblvls__Species *p_species,
           double d_temperature,
           void *p_user_rate_data
         );
             
Input:

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

p_species: (required) A pointer to a Liblvls__Species structure.

d_temperature: (required) A double giving the temperature at which to compute the flow vector.

p_user_rate_data: (required) A pointer to data to be used when calculating transition rates with a user-supplied rate function, or NULL if no extra data are needed.

Output:

Routine returns a pointer to the flow vector (a gsl_vector). If the zone or species is not found or the temperature is not valid (< 0), error handling is invoked.

Example: Return the flow vector for levels in singly-ionized 4He (stored as he4ii in the species collection p_my_collection) at 25,000 K in zone p_zone with no extra data:

         p_flow_vector =
           Liblvls__Zone__computeFlowVector(
             p_zone,
             Liblvls__SpColl_getSpecies( p_my_collection, "he4ii" ),
             25000.,
             NULL
           );
               

-top-


Name: Liblvls__Zone__free()

Description: Routine to free the memory allocated for a Liblvls__Zone structure.

Syntax:
         void
         Liblvls__Zone__free
           Liblvls__Zone *self
         );
             
Input:

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

Output:

Upon successful return, the memory for the zone structure has been freed.

Example: Free the memory previously allocated for the Liblvls__Zone structure p_my_zone:

         Liblvls__Zone__free( p_my_zone );
               

-top-


Name: Liblvls__Zone__getLabel()

Description: Routine to retrieve a label for the given zone.

Syntax:
         const char *
         Liblvls__Zone__getLabel(
           const Liblvls__Zone *self,
           int i_label
         );
             
Input:

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

i_label: (required) An int (1, 2, or 3) giving the index of the label requested.

Output:

Routine returns a string giving the requested label. If the zone or label is invalid, error handling is invoked.

Example: Print the third label of Liblvls__Zone *p_zone:

         printf(
           "Third label = %s\n",
           Liblvls__Zone__getLabel( p_zone, 3 )
         );
               

-top-


Name: Liblvls__Zone__getLevelProbability()

Description: Routine to retrieve the probability for a level in a particular species in a particular zone.

Syntax:
         double
         Liblvls__Zone__getLevelProbability(
           const Liblvls__Zone *self,
           const Liblvls__Species *p_species,
           const Liblvls__Level *p_level
         );
             
Input:

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

p_species: (required) A pointer to a Liblvls__Species structure.

level: (required) A pointer to a Liblvls__Level structure.

Output:

Routine returns the current population probability for the given level in the input species and zone or zero if the level, species, or zone is not found.

Example: Return the probability of p_level in the p_species in the p_zone:

         d_probability =
           Liblvls__Zone__getLevelProbability(
             p_zone, p_species, p_level
           );
               

-top-


Name: Liblvls__Zone__getLevelProbabilityChange()

Description: Routine to retrieve the change in the probability for a level in a particular species in a particular zone over the last time step of evolution.

Syntax:
         double
         Liblvls__Zone__getLevelProbabilityChange(
           const Liblvls__Zone *self,
           const Liblvls__Species *p_species,
           const Liblvls__Level *p_level
         );
             
Input:

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

p_species: (required) A pointer to a Liblvls__Species structure.

p_level: (required) A pointer to a Liblvls__Level structure.

Output:

Routine returns the change in the population probability for the given level in the input species and zone over the last timestep or zero if the level, species, or zone is not found.

Example: Return the change in the population probability of p_level in p_species in p_zone:

         d_probability_change =
           Liblvls__Zone__getLevelProbabilityChange(
             p_zone, p_species, p_level
           );
               

-top-


Name: Liblvls__Zone__getProbabilities()

Description: Routine to retrieve the probability for an entire species in a particular zone.

Syntax:
         gsl_vector *
         Liblvls__Zone__getProbabilities(
           const Liblvls__Zone *self,
           const Liblvls__Species *p_species
         );
             
Input:

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

p_species: (required) A pointer to a Liblvls__Species structure.

Output:

Routine returns the current population probabilities for all levels in the input species and zone or NULL if the species or zone is not found.

Example: Return the probability for all levels in p_species in p_zone:

         p_probabilities =
           Liblvls__Zone__getProbabilities(
             p_zone,
             p_species
           );
               

-top-


Name: Liblvls__Zone__getProperty()

Description: Routine to retrieve property information for a zone.

Syntax:
         const char *
         Liblvls__Zone__getProperty(
           const Liblvls__Zone *self,
           const char *s_label1,
           const char *s_label2,
           const char *s_label3
         );
             
Input:

self: (required) A pointer to a Liblvls__Zone.

s_label1: (required) A string containing the first label for the property to retrieve.

s_label2: (required) A string containing the second label for the property to retrieve.

s_label3: (required) A string containing the third label for the property to retrieve.

Output:

If the property is found, a const char * pointing to the property is returned. If the property is not found, NULL is returned.

Example: Retrieve a property with first label "temperature" from zone my_zone:

         s_temperature =
           Liblvls__Zone__getProperty(
             my_zone, "temperature", NULL, NULL
           );
               

-top-


Name: Liblvls__Zone__updateLevelProbability()

Description: Routine to update the probability and probability change over the last timestep for a level in a particular species in a particular zone.

Syntax:
         int
         Liblvls__Zone__updateLevelProbability(
           Liblvls__Zone *self,
           Liblvls__Species *p_species,
           Liblvls__Level *p_level,
           double d_probability,
           double d_probability_change
         );
             
Input:

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

p_species: (required) A pointer to a Liblvls__Species structure.

level: (required) A pointer to a Liblvls__Level structure.

d_probability: (required) A double giving the new probability.

d_probability_change: (required) A double giving the probability change over the last timestep.

Output:

Routine returns 0 if the update succeeded and -1 in case of error.

Example: Update the probability and probability change of p_level in p_species in p_zone. The new value of the probability is 1.e-5 and the change is 2.e-7:

         if( 
             Liblvls__Zone__updateLevelProbability(
               p_zone, p_species, p_level, 1.e-5, 2.e-7
             ) == 0
         ) {
           fprintf( stdout, "Update succeeded!\n" );
         }
               

-top-


Name: Liblvls__Zone__updateProbabilities()

Description: Routine to update the probability and probability change over the last timestep for an entire species in a particular zone.

Syntax:
         void
         Liblvls__Zone__updateProbabilities(
           Liblvls__Zone *self,
           Liblvls__Species *p_species,
           gsl_vector *p_probability,
           gsl_vector *p_probability_change
         );
             
Input:

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

p_species: (required) A pointer to a Liblvls__Species structure.

p_probability: (required) A gsl_vector giving the new probabilities.

p_probability_change: (required) A gsl_vector giving the probability changes over the last timestep.

Output:

On successful return, the level probabilities have been updated. If updates fail, error handling is invoked.

Example: Update the probabilities and probability changes of p_species in p_zone. The new values for the probabilities are stored in p_probabilities and the probability changes are stored in p_probability_changes:

         Liblvls__Zone__updateProbabilities(
           p_zone,
           p_species,
           p_probabilities,
           p_probability_changes
         );
               

-top-


Name: Liblvls__Zone__updateProperty()

Description: Routine to update a user-defined property for a zone.

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

self: (required) A pointer to a Liblvls__Zone.

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

s_tag1: (required) A string giving the first optional tag (may be NULL) of the property to be updated.

s_tag2: (required) A string giving the second optional tag (may be NULL) of the property to be updated.

s_value: (required) A string containing the data to be stored.

Output:

Routine returns true (1) if the property was successfully updated and false (0) if not. On successful return, the data for the property has been either added (if the data for the property didn't previously exist) or updated (if the property did previously exist). If the zone to which the property is to be attached is not valid, error handling is invoked.

Example: Update the zone p_zone to include a temperature stored in the string named s_temperature:

         if(
            !(
               Liblvls__Zone__updateProperty(
                 p_zone,
                 "temperature",
                 NULL,
                 NULL,
                 s_temperature
            )
         )
           fprintf( stderr, "Update failed.\n" );
              

-top-


Name: Liblvls__free()

Description: Routine to free the memory allocated for a Liblvls structure.

Syntax:
         void
         Liblvls__free
           Liblvls *self
         );
             
Input:

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

Output:

Upon successful return, the memory for the Liblvls structure has been freed.

Example: Free the memory previously allocated for the Liblvls structure p_my_zones:

         Liblvls__free( p_my_zones );
               

-top-


Name: Liblvls__getNumberOfZones()

Description: Routine to get the number of zones in a Liblvls structure.

Syntax:
         size_t
         Liblvls__getNumberOfZones(
           const Liblvls *self
         );
             
Input:

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

Output:

A size_t giving the number of zones.

Example: Print the number of zones in p_my_liblvls:

         printf(
           "Number of zones = %d\n",
           Liblvls__getNumberOfZones( p_my_liblvls )
         );
               

-top-


Name: Liblvls__getSpColl()

Description: Routine to retrieve a species collection from a Liblvls structure.

Syntax:
         Liblvls__SpColl *
         Liblvls__getSpColl(
           const Liblvls *self
         );
             
Input:

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

Output:

Routine returns the pointer to the species collection.

Example: Return the species collection from p_my_liblvls:

         p_collection =
           Liblvls__getSpColl( p_my_liblvls );
              

-top-


Name: Liblvls__getZone()

Description: Routine to retrieve a zone from a Liblvls structure.

Syntax:
         Liblvls__Zone *
         Liblvls__getZone(
           const Liblvls *self,
           char *s_label_1,
           char *s_label_2,
           char *s_label_3
         );
             
Input:

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

s_label_1: (required) A string giving the first label of the zone.

s_label_2: (required) A string giving the second label of the zone.

s_label_3: (required) A string giving the third label of the zone.

Output:

Routine returns the pointer to desired zone or NULL if the zone is not found.

Example: Return the zone with labels 0, 1, 2 from Liblvls structure p_my_liblvls:

         s_1 = "0";
         s_2 = "1";
         s_3 = "2";
         p_zone = Liblvls__getZone( p_my_liblvls, s_1, s_2, s_3 );
               

-top-


Name: Liblvls__get_energy_units()

Description: Routine to return the energy units flag.

Syntax:
         int
         Liblvls__get_energy_units(
           const char *s_units
         );
             
Input:

s_units: (required) A string giving the units desired. Possible values are "eV", "keV", "MeV", or "GeV".

Example: Get the energy of level p_level in eV by choosing the string "eV":

         d_energy =
           Liblvls__Level__getEnergy(
             p_level,
             Liblvls__get_energy_units( "eV" )
           ); 
               

-top-


Name: Liblvls__is_valid_input_xml()

Description: Routine to check an input liblvls xml file against the schema for validity.

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

s_xml_filename: (required) A string containing the name of the file to be checked for validity.

Output:

Returns 1 for a valid xml input file, 0 for invalid input, and prints an error if the schema file is invalid or unable to be read over the web.

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

         if( Liblvls__is_valid_input_xml( "liblvls.xml" ) ) {
           printf( "Valid xml input!\n" );
         }
               

-top-


Name: Liblvls__is_valid_zone_input_xml()

Description: Routine to check an input zone xml file against the schema for validity.

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

s_xml_filename: (required) A string containing the name of the file to be checked for validity.

Output:

Returns 1 for a valid xml input file, 0 for invalid input, and prints an error if the schema file is invalid or unable to be read over the web.

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

         if( Liblvls__is_valid_zone_input_xml( "zone_data.xml" ) ) {
           printf( "Valid xml input!\n" );
         }
               

-top-


Name: Liblvls__iterateZones()

Description: Iterate through the zones in a Liblvls structure and apply the user-supplied iterate function.

Syntax:
         void
         Liblvls__iterateZones(
           const Liblvls *self,
           Liblvls__Zone__iterateFunction pf_func,
           void *p_user_data
         );
             
Input:

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

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

p_user_data: (required) A pointer to the user-defined extra data.

Output:

The routine iterates through the zones and applies the user-supplied routine to each. Zones are iterated in alphabetical order according to their labels. If any input is invalid, error handling is invoked.

Example: Iterate through the zones in p_my_liblvls and apply the function my_iterate_function and the extra data in p_user_data:

         Liblvls__iterateZones(
           p_my_liblvls,
           (Liblvls__Zone__iterateFunction) my_iterate_function,
           p_user_data
         );
               

-top-


Name: Liblvls__new()

Description: Routine to create a new Liblvls structure.

Syntax:
         Liblvls *Liblvls__new( );
             
Output:

A pointer to a new Liblvs structure.

Example: Create the Liblvls structure p_my_levels:

         p_my_levels = Liblvls__new( );
               

-top-


Name: Liblvls__new_from_xml()

Description: Routine to read in level data from an xml file and store them into a Liblvls data structure.

Syntax:
         Liblvls *
         Liblvls__new_from_xml(
           const char *s_xml_filename,
           const char *s_xpath_suffix
         );
             
Input:

s_xml_filename: (required) s_xml_filename is the name of the xml file that contains the level data along with data about the zones.

s_xpath_suffix: (required) A string giving an xpath expression to apply.

Output:

A pointer to a Liblvls structure.

Example: Store the level and zone data in levels.xml to p_my_liblvls:

         p_my_liblvls = Liblvls__new_from_xml( "levels.xml", NULL );
               

-top-


Name: Liblvls__updateZonesFromXml()

Description:

Syntax:
         void
         Liblvls__updateZonesFromXml(
           Liblvls *self,
           const char *s_xml_filename,
           const char *s_xpath_suffix
         );
             
Input:

self: (required) A pointer to a Liblvls structure to be updated with the zone data.

s_xml_filename: (required) s_xml_filename is the name of the xml file that contains the zone data.

s_xpath_suffix: (required) A string giving an xpath expression to apply.

Output:

On successful return the zone data have been updated with the zone data contained in the input xml file. If the file is not found, error handling is invoked.

Example: Update the zone data in p_liblvls with the data in zones.xml:

         Liblvls__updateZonesFromXml(
           p_liblvls,
           "zones.xml",
           NULL
         );
               

-top-


Name: Liblvls__writeToXmlFile()

Description: Output a Liblvls structure to an xml file.

Syntax:
         void
         Liblvls__writeToXmlFile(
           const Liblvls *self,
           const char *s_xml_filename
         );
             
Input:

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

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

Output:

Upon successful return, the contents of the structure have been written to an xml file. If the input is invalid, Liblvls error handling is invoked.

Example: Dump the contents of Liblvls *p_liblvls to the xml file my.xml:

         Liblvls__writeToXmlFile( p_liblvls, "my.xml" );
               

-top-




Valid XHTML 1.1        Copyright © 2001-2012, Clemson University. All rights reserved.        Valid CSS!
Page last modified on 2010/02/14 09:54