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 10: Create a collection of nuclear reactions, add reactions, and output the data to an xml file.
libnucnet routines demonstrated in example10.c are:
- Line 84: Libnucnet__Reac__new()
- Line 193: Libnucnet__Reac__addSingleRateReaction()
- Line 222: Libnucnet__Reac__addRateTableReaction()
- Line 250: Libnucnet__Reac__addNonSmokerReaction()
- Line 281: Libnucnet__Reac__writeToXmlFile()
- Line 287: Libnucnet__Reac__free()
To run example10, type the following on the command line:
example10 ../../data_pub/example_reac.txt ex10_output.xml
The result is ex10_output.xml
Example 11: Validate a Libnucnet__Reac input xml file against Webnucleo's schema.
libnucnet routines demonstrated in example11.c are:
To run example11, type the following on the command line:
example11 ../../data_pub/example_reac.xml
The result is
Valid input Libnucnet__Reac xml file!
Example 12: Create a collection of nuclear reactions from an input xml file and output their reaction strings.
libnucnet routines demonstrated in example12.c are:
- Line 75: Libnucnet__Reac__new_from_xml()
- Line 84: Libnucnet__Reac__getFirstReaction()
- Line 90: Libnucnet__Reaction__getString()
- Line 91: Libnucnet__Reaction__getSource()
- Line 93: Libnucnet__Reaction__getNext()
- Line 102: Libnucnet__Reac__getNumberOfReactions()
- Line 109: Libnucnet__Reac__free()
To run example12, type the following on the command line:
example12 ../../data_pub/example_reac.xml > ex12_output.txt
The result is ex12_output.txt
You can also select out certain reactions with an xpath expression. For example, to select only (n,gamma) reactions, type:
example12 ../../data_pub/example_reac.xml "[ reactant = 'n' and product = 'gamma' ]" > ex12_xpath_output.txt
The result is ex12_xpath_output.txt
Example 13: 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 example13.c are:
- Line 80: Libnucnet__Reac__new_from_xml()
- Line 96: Libnucnet__Reac__updateFromXml()
- Line 109: Libnucnet__Reac__free()
- Line 131: Libnucnet__Reac__getFirstReaction()
- Line 137: Libnucnet__Reaction__getString()
- Line 138: Libnucnet__Reaction__getSource()
- Line 140: Libnucnet__Reaction__getNext()
- Line 149: Libnucnet__Reac__getNumberOfReactions()
To run example13, type the following on the command line:
example13 http://www.webnucleo.org/home/modules/libnucnet/0.1/data_pub/example_reac.xml ../../data_pub/example_reac_new.xml "[ product = 'h2' ]" > ex13_output.txt
The result is ex13_output.txt
Example 14: Create a collection of nuclear reactions from an input xml file and print out the duplicate reactant and product factors.
libnucnet routines demonstrated in example14.c are:
- Line 77: Libnucnet__Reac__new_from_xml()
- Line 92: Libnucnet__Reac__getFirstReaction()
- Line 97: Libnucnet__Reaction__getString()
- Line 98: Libnucnet__Reaction__getDuplicateReactantFactor()
- Line 99: Libnucnet__Reaction__getDuplicateProductFactor()
- Line 102: Libnucnet__Reaction__getNext()
- Line 112: Libnucnet__Reac__free()
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, try:
example14 ../../data_pub/example_reac.xml "[ reactant = 'he4' and ( product = 'be9' or product = 'c12' ) ]" > ex14_xpath_output.txt
The result is ex14_xpath_output.txt
Example 15: 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 example15.c are:
- Line 78: Libnucnet__Reac__new()
- Line 80: Libnucnet__Reac__updateFromXml()
- Line 86: Libnucnet__Reac__getReactionByString()
- Line 93: Libnucnet__Reaction__printRateData()
- Line 99: Libnucnet__Reac__free()
To run example15, type the following on the command line:
example15 ../../data_pub/example_reac.xml "si28 + h1 -> p29 + gamma" > ex15_output.txt
The result is ex15_output.txt
Example 16: 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 example16.c are:
- Line 77: Libnucnet__Reac__new_from_xml()
- Line 83: Libnucnet__Reac__getFirstReaction()
- Line 87: Libnucnet__Reaction__printRateData()
- Line 88: Libnucnet__Reaction__getNext()
- Line 96: Libnucnet__Reac__free()
To print out the data for all reactions on magnesium-24, type:
example16 ../../data_pub/example_reac.xml "[ reactant = 'mg24' ]" > 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 reaction rate at the input temperature.
libnucnet routines demonstrated in example17.c are:
- Line 83: Libnucnet__Reac__new_from_xml()
- Line 101: Libnucnet__Reac__getFirstReaction()
- Line 106: Libnucnet__Reaction__getString()
- Line 107: Libnucnet__Reaction__computeRate()
- Line 112: Libnucnet__Reaction__getNext()
- Line 122: Libnucnet__Reac__free()
To compute the rates at a t9 (temperature in billions of K) of 1, type:
example17 ../../data_pub/example_reac.xml 1. > ex17_output.txt
The result is ex17_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:
example17 ../../data_pub/example_reac.xml 1. "[ reactant = 'n' and product = 'gamma' ]" > ex17_xpath_output.txt
The result is ex17_xpath_output.txt
Example 18: 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 example18.c are:
- Line 84: Libnucnet__Reac__new_from_xml()
- Line 90: Libnucnet__Reac__getReactionByString()
- Line 95: Libnucnet__Reaction__getString()
- Line 105: Libnucnet__Reaction__computeRate()
- Line 115: Libnucnet__Reac__free()
To run example18, type the following on the command line:
example18 ../../data_pub/example_reac.xml "cl35 + h1 -> ar36 + gamma" > ex18_output.txt
The result is ex18_output.txt
Example 19: 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 example19.c are:
- Line 84: Libnucnet__Reac__new_from_xml()
- Line 90: Libnucnet__Reac__getFirstReaction()
- Line 95: Libnucnet__Reaction__getString()
- Line 105: Libnucnet__Reaction__computeRate()
- Line 112: Libnucnet__Reaction__getNext()
- Line 120: Libnucnet__Reac__free()
To print out the rates as a function of temperature of all reactions with oxygen-16 as a reactant, type:
example19 ../../data_pub/example_reac.xml "[ reactant = 'o16' ]" > ex19_output.txt
The result is ex19_output.txt