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.
This tutorial demonstrates how to use example codes in the libnucnet distribution src/examples directory. The sample input files used in the tutorial are included in the distribution release and may be located in the data_pub directory.
Example 12: Create a collection of nuclear reactions, add reactions, and output the data to an xml file.
libnucnet routines demonstrated in example12.c are:
- Line 60: Libnucnet__Reac__new()
- Line 81: Libnucnet__Reaction__new()
- Line 100: Libnucnet__Reaction__updateSource()
- Line 111: Libnucnet__Reaction__addReactant()
- Line 123: Libnucnet__Reaction__addProduct()
- Line 137: Libnucnet__Reaction__updateSingleRate()
- Line 170: Libnucnet__Reaction__updateRateTable()
- Line 216: Libnucnet__Reaction__addNonSmokerFit()
- Line 239: Libnucnet__Reac__addReaction()
- Line 243: Libnucnet__Reaction__getString()
- Line 252: Libnucnet__Reaction__copy()
- Line 254: Libnucnet__Reac__updateReaction()
- Line 277: Libnucnet__Reac__writeToXmlFile()
- Line 283: Libnucnet__Reac__free()
To run example12, type the following on the command line:
./example12 ../../data_pub/example_reac.txt ex12_output.xml
The result is ex12_output.xml
Example 13: Validate a Libnucnet__Reac input xml file against Webnucleo's schema.
libnucnet routines demonstrated in example13.c are:
To run example13, type the following on the command line:
./example13 ../../data_pub/example_reac.xml
The result is
Valid input Libnucnet__Reac xml file!
Example 14: Create a collection of nuclear reactions from an input xml file and output their reaction strings.
libnucnet routines demonstrated in example14.c are:
- Line 55: Libnucnet__Reac__new_from_xml()
- Line 64: Libnucnet__Reac__iterateReactions()
- Line 78: Libnucnet__Reac__getNumberOfReactions()
- Line 85: Libnucnet__Reac__free()
- Line 114: Libnucnet__Reaction__getString()
- Line 115: Libnucnet__Reaction__getSource()
To run example14, type the following on the command line:
./example14 ../../data_pub/example_reac.xml > ex14_output.txt
The result is ex14_output.txt
You can also select out certain reactions with an xpath expression. For example, to select only (n,gamma) reactions, type:
./example14 ../../data_pub/example_reac.xml "[ reactant = 'n' and product = 'gamma' ]" > ex14_xpath_output.txt
The result is ex14_xpath_output.txt
Example 15: Create a collection of nuclear reactions from an input xml file, remove any duplicate files from the NACRE data source, and output the updated data.
libnucnet routines demonstrated in example15.c are:
- Line 60: Libnucnet__Reac__new_from_xml()
- Line 71: Libnucnet__Reac__getNumberOfReactions()
- Line 78: Libnucnet__Reac__getDuplicateReactions()
- Line 94: Libnucnet__Reac__iterateReactions()
- Line 114: Libnucnet__Reac__writeToXmlFile()
- Line 120: Libnucnet__Reac__free()
- Line 139: Libnucnet__Reaction__getSource()
- Line 147: Libnucnet__Reaction__getString()
- Line 150: Libnucnet__Reac__removeReaction()
- Line 152: Libnucnet__Reac__getReactionByString()
- Line 160: Libnucnet__Reaction__getParentDuplicate()
To run example15, type the following on the command line:
./example15 ../../data_pub/example_reac.xml ex15_output.xml
The result is ex15_output.xml
Example 16: Create a collection of nuclear reactions from an input xml file over the web, output their reaction strings, update the data from a local xml file, and output the updated data.
libnucnet routines demonstrated in example16.c are:
- Line 61: Libnucnet__Reac__new_from_xml()
- Line 77: Libnucnet__Reac__updateFromXml()
- Line 90: Libnucnet__Reac__free()
- Line 110: Libnucnet__Reac__iterateReactions()
- Line 123: Libnucnet__Reac__getNumberOfReactions()
- Line 145: Libnucnet__Reaction__getString()
- Line 146: Libnucnet__Reaction__getSource()
To run example16, type the following on the command line:
./example16 http://www.webnucleo.org/home/modules/libnucnet/0.3/data_pub/example_reac.xml ../../data_pub/example_reac_new.xml "[ product = 'h2' ]" > ex16_output.txt
The result is ex16_output.txt
Example 17: Create a collection of nuclear reactions from an input xml file and print out the duplicate reactant and product factors.
libnucnet routines demonstrated in example17.c are:
- Line 56: Libnucnet__Reac__new_from_xml()
- Line 72: Libnucnet__Reac__iterateReactions()
- Line 85: Libnucnet__Reac__free()
- Line 111: Libnucnet__Reaction__getString()
- Line 112: Libnucnet__Reaction__getDuplicateReactantFactor()
- Line 113: Libnucnet__Reaction__getDuplicateProductFactor()
To run example17, type the following on the command line:
./example17 ../../data_pub/example_reac.xml > ex17_output.txt
The result is ex17_output.txt
You can also select out certain reactions with an xpath expression. For example, try:
./example17 ../../data_pub/example_reac.xml "[ reactant = 'he4' and ( product = 'be9' or product = 'c12' ) ]" > ex17_xpath_output.txt
The result is ex17_xpath_output.txt
Example 18: Print out the reactants and products for a reaction.
libnucnet routines demonstrated in example18.c are:
- Line 80: Libnucnet__Reac__new_from_xml()
- Line 91: Libnucnet__Reac__getReactionByString()
- Line 126: Libnucnet__Reaction__iterateReactants()
- Line 132: Libnucnet__Reaction__iterateProducts()
- Line 229: Libnucnet__Reac__free()
- Line 242: Libnucnet__Reaction__Element__isNuclide()
- Line 280: Libnucnet__Reaction__Element__getName()
To run example18, type the following on the command line:
./example18 ../../data_pub/example_reac.xml "ne28 -> na26 + n + n + electron + anti-neutrino_e" > ex18_output.txt
The result is ex18_output.txt
Example 19: Create a collection of nuclear reactions from an input xml file and print out the data for a particular reaction chosen by its reaction string.
libnucnet routines demonstrated in example19.c are:
- Line 55: Libnucnet__Reac__new()
- Line 57: Libnucnet__Reac__updateFromXml()
- Line 63: Libnucnet__Reac__getReactionByString()
- Line 70: Libnucnet__Reaction__printRateData()
- Line 76: Libnucnet__Reac__free()
To run example19, type the following on the command line:
./example19 ../../data_pub/example_reac.xml "si28 + h1 -> p29 + gamma" > ex19_output.txt
The result is ex19_output.txt
Example 20: Create a collection of nuclear reactions from an input xml file and print out the data for a reaction or reactions chosen by an xpath expression.
libnucnet routines demonstrated in example20.c are:
- Line 56: Libnucnet__Reac__new_from_xml()
- Line 62: Libnucnet__Reac__iterateReactions()
- Line 72: Libnucnet__Reac__free()
- Line 91: Libnucnet__Reaction__printRateData()
To print out the data for all reactions on magnesium-24, type:
./example20 ../../data_pub/example_reac.xml "[ reactant = 'mg24' ]" > ex20_output.txt
The result is ex20_output.txt
Example 21: Create a collection of nuclear reactions from an input xml file and print out the reaction rate at the input temperature.
libnucnet routines demonstrated in example21.c are:
- Line 62: Libnucnet__Reac__new_from_xml()
- Line 83: Libnucnet__Reac__iterateReactions()
- Line 95: Libnucnet__Reac__free()
- Line 112: Libnucnet__Reaction__getString()
- Line 113: Libnucnet__Reaction__computeRate()
To compute the rates at a t9 (temperature in billions of K) of 1, type:
./example21 ../../data_pub/example_reac.xml 1. > ex21_output.txt
The result is ex21_output.txt
This routine also can take an xpath expression. To compute the rates for all (n,gamma) rates at a t9 (temperature in billions of K) of 1, type:
./example21 ../../data_pub/example_reac.xml 1. "[ reactant = 'n' and product = 'gamma' ]" > ex21_xpath_output.txt
The result is ex21_xpath_output.txt
Example 22: Create a collection of nuclear reactions from an input xml file and print the rate as a function of temperature for a particular reaction chosen by its reaction string.
libnucnet routines demonstrated in example22.c are:
- Line 61: Libnucnet__Reac__new_from_xml()
- Line 67: Libnucnet__Reac__getReactionByString()
- Line 72: Libnucnet__Reaction__getString()
- Line 82: Libnucnet__Reaction__computeRate()
- Line 92: Libnucnet__Reac__free()
To run example22, type the following on the command line:
./example22 ../../data_pub/example_reac.xml "cl35 + h1 -> ar36 + gamma" > ex22_output.txt
The result is ex22_output.txt
Example 23: Create a collection of nuclear reactions from an input xml file and print the rate as a function of temperature for a reaction or reactions chosen by an xpath expression.
libnucnet routines demonstrated in example23.c are:
- Line 56: Libnucnet__Reac__new_from_xml()
- Line 62: Libnucnet__Reac__iterateReactions()
- Line 72: Libnucnet__Reac__free()
- Line 98: Libnucnet__Reaction__getString()
- Line 108: Libnucnet__Reaction__computeRate()
To print out the rates as a function of temperature of all reactions with oxygen-16 as a reactant, type:
./example23 ../../data_pub/example_reac.xml "[ reactant = 'o16' ]" > ex23_output.txt
The result is ex23_output.txt