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 from data in a text file, and output the data to an xml file.
libnucnet routines demonstrated in example12.c are:
- Line 72: Libnucnet__Reac__new()
- Line 93: Libnucnet__Reaction__new()
- Line 112: Libnucnet__Reaction__updateSource()
- Line 123: Libnucnet__Reaction__addReactant()
- Line 135: Libnucnet__Reaction__addProduct()
- Line 149: Libnucnet__Reaction__updateSingleRate()
- Line 182: Libnucnet__Reaction__updateRateTable()
- Line 228: Libnucnet__Reaction__addNonSmokerFit()
- Line 251: Libnucnet__Reac__addReaction()
- Line 255: Libnucnet__Reaction__getString()
- Line 264: Libnucnet__Reaction__copy()
- Line 266: Libnucnet__Reac__updateReaction()
- Line 289: Libnucnet__Reac__writeToXmlFile()
- Line 295: 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 67: Libnucnet__Reac__new_from_xml()
- Line 76: Libnucnet__Reac__iterateReactions()
- Line 90: Libnucnet__Reac__getNumberOfReactions()
- Line 97: Libnucnet__Reac__free()
- Line 126: Libnucnet__Reaction__getString()
- Line 127: 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 reactions from the NACRE data source, and output the updated data.
libnucnet routines demonstrated in example15.c are:
- Line 72: Libnucnet__Reac__new_from_xml()
- Line 83: Libnucnet__Reac__getNumberOfReactions()
- Line 90: Libnucnet__Reac__getDuplicateReactions()
- Line 106: Libnucnet__Reac__iterateReactions()
- Line 126: Libnucnet__Reac__writeToXmlFile()
- Line 132: Libnucnet__Reac__free()
- Line 149: Libnucnet__Reaction__getString()
- Line 153: Libnucnet__Reaction__getSource()
- Line 164: Libnucnet__Reac__removeReaction()
- Line 166: Libnucnet__Reac__getReactionByString()
- Line 174: 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 73: Libnucnet__Reac__new_from_xml()
- Line 89: Libnucnet__Reac__updateFromXml()
- Line 102: Libnucnet__Reac__free()
- Line 122: Libnucnet__Reac__iterateReactions()
- Line 135: Libnucnet__Reac__getNumberOfReactions()
- Line 157: Libnucnet__Reaction__getString()
- Line 158: 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 71: Libnucnet__Reac__new_from_xml()
- Line 87: Libnucnet__Reac__setReactionCompareFunction()
- Line 92: Libnucnet__Reac__iterateReactions()
- Line 105: Libnucnet__Reac__free()
- Line 128: Libnucnet__Reaction__getString()
- Line 151: Libnucnet__Reaction__getDuplicateReactantFactor()
- Line 152: 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 92: Libnucnet__Reac__new_from_xml()
- Line 103: Libnucnet__Reac__getReactionByString()
- Line 138: Libnucnet__Reaction__iterateReactants()
- Line 144: Libnucnet__Reaction__iterateProducts()
- Line 157: Libnucnet__Reaction__getString()
- Line 251: Libnucnet__Reac__free()
- Line 264: Libnucnet__Reaction__Element__isNuclide()
- Line 302: 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 67: Libnucnet__Reac__new()
- Line 69: Libnucnet__Reac__updateFromXml()
- Line 75: Libnucnet__Reac__getReactionByString()
- Line 82: Libnucnet__Reaction__printRateData()
- Line 88: 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 68: Libnucnet__Reac__new_from_xml()
- Line 74: Libnucnet__Reac__iterateReactions()
- Line 84: Libnucnet__Reac__free()
- Line 103: 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 75: Libnucnet__Reac__new_from_xml()
- Line 96: Libnucnet__Reac__setReactionCompareFunction()
- Line 101: Libnucnet__Reac__iterateReactions()
- Line 113: Libnucnet__Reac__free()
- Line 130: Libnucnet__Reaction__getString()
- Line 131: 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 73: Libnucnet__Reac__new_from_xml()
- Line 79: Libnucnet__Reac__getReactionByString()
- Line 84: Libnucnet__Reaction__getString()
- Line 94: Libnucnet__Reaction__computeRate()
- Line 104: 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 68: Libnucnet__Reac__new_from_xml()
- Line 74: Libnucnet__Reac__iterateReactions()
- Line 84: Libnucnet__Reac__free()
- Line 110: Libnucnet__Reaction__getString()
- Line 120: 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