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 1: Create a collection of nuclei, add species, and remove them.
libnucnet routines demonstrated in example1.c are:
- Line 72: Libnucnet__Nuc__new()
- Line 89: Libnucnet__Species__new()
- Line 101: Libnucnet__Nuc__addSpecies()
- Line 144: Libnucnet__Nuc__removeSpecies()
- Line 146: Libnucnet__Nuc__getSpeciesByName()
- Line 157: Libnucnet__Nuc__free()
- Line 234: Libnucnet__Nuc__iterateSpecies()
- Line 247: Libnucnet__Nuc__getNumberOfSpecies()
- Line 272: Libnucnet__Species__getIndex()
- Line 273: Libnucnet__Species__getZ()
- Line 274: Libnucnet__Species__getA()
- Line 275: Libnucnet__Species__getName()
- Line 276: Libnucnet__Species__getMassExcess()
- Line 277: Libnucnet__Species__getSpin()
- Line 278: Libnucnet__Species__getSource()
To run example1, type the following on the command line:
./example1 > ex1_output.txt
The result is ex1_output.txt
Example 2: Create a collection of nuclei, add species, and write data to an xml file.
libnucnet routines demonstrated in example2.c are:
- Line 62: Libnucnet__Nuc__new()
- Line 110: Libnucnet__Species__new()
- Line 122: Libnucnet__Nuc__addSpecies()
- Line 139: Libnucnet__Nuc__writeToXmlFile()
- Line 145: Libnucnet__Nuc__free()
To run example2, type the following on the command line:
./example2 ../../data_pub/example_nuc.txt ex2_output.xml
The result is ex2_output.xml
Example 3: Validate a Libnucnet__Nuc input xml file against Webnucleo's schema.
libnucnet routines demonstrated in example3.c are:
- Line 45: Libnucnet__Nuc__is_valid_input_xml()
To run example3, type the following on the command line:
./example3 ../../data_pub/example_nuc.xml
The result is
Valid input Libnucnet__Nuc xml file!
To see what happens when the input xml is invalid (the following input file has a negative mass number for the neutron), type:
./example3 ../../data_pub/example_nuc_wrong.xml
The result is
../../data_pub/example_nuc_wrong.xml:77: element a: Schemas validity error : Element 'a': '-1' is not a valid value of the atomic type
'{http://nucleo.ces.clemson.edu/home/modules/libnucnet/0.2/xsd_pub/libnucnet__nuc__types/}a_type'.
Example 4: Create a collection of nuclei from an input xml file and output the data about each species.
libnucnet routines demonstrated in example4.c are:
- Line 54: Libnucnet__Nuc__new_from_xml()
- Line 69: Libnucnet__Nuc__free()
- Line 102: Libnucnet__Nuc__iterateSpecies()
- Line 113: Libnucnet__Nuc__getNumberOfSpecies()
- Line 139: Libnucnet__Species__getIndex()
- Line 140: Libnucnet__Species__getZ()
- Line 141: Libnucnet__Species__getA()
- Line 142: Libnucnet__Species__getName()
- Line 143: Libnucnet__Species__getMassExcess()
- Line 144: Libnucnet__Species__getSpin()
- Line 145: Libnucnet__Species__getSource()
To run example4, type the following on the command line:
./example4 ../../data_pub/example_nuc.xml > ex4_output.txt
The result is ex4_output.txt
You can also select out certain species with an xpath expression. For example, to select only isotopes of elements between and including neon and calcium, type:
./example4 ../../data_pub/example_nuc.xml "[ z >= 10 and z <= 20 ]" > ex4_xpath_output.txt
The result is ex4_xpath_output.txt
Finally note you can also read data over the web. For example, to select data from the original example xml file residing on Webnucleo's server, type:
./example4 http://www.webnucleo.org/home/modules/libnucnet/0.2/data_pub/example_nuc.xml > ex4_web_output.txt
The result is ex4_web_output.txt
Example 5: Create a collection of nuclei from data read over the web, output the data, modify the nuclear data with data from a local file, and output the updated data.
libnucnet routines demonstrated in example5.c are:
- Line 59: Libnucnet__Nuc__new_from_xml()
- Line 75: Libnucnet__Nuc__updateFromXml()
- Line 81: Libnucnet__Nuc__sortSpecies()
- Line 94: Libnucnet__Nuc__free()
- Line 127: Libnucnet__Nuc__iterateSpecies()
- Line 140: Libnucnet__Nuc__getNumberOfSpecies()
- Line 161: Libnucnet__Species__getIndex()
- Line 162: Libnucnet__Species__getZ()
- Line 163: Libnucnet__Species__getA()
- Line 164: Libnucnet__Species__getName()
- Line 165: Libnucnet__Species__getMassExcess()
- Line 166: Libnucnet__Species__getSpin()
- Line 167: Libnucnet__Species__getSource()
To modify data for Z < 5 from the original Webnucleo.org nuclear data file with data from a local file (the changes are modified data for beryllium-7 and the addition of carbon 12), type at the command line:
./example5 http://www.webnucleo.org/home/modules/libnucnet/0.2/data_pub/example_nuc.xml ../../data_pub/example_nuc_new.xml "[ z < 5 ]" > ex5_output.txt
The result is ex5_output.txt
Example 6: Create a collection of nuclei from an input xml file and print out data about a particular species selected by its name.
libnucnet routines demonstrated in example6.c are:
- Line 49: Libnucnet__Nuc__new_from_xml()
- Line 52: Libnucnet__Nuc__new()
- Line 54: Libnucnet__Nuc__updateFromXml()
- Line 62: Libnucnet__Nuc__getSpeciesByName()
- Line 67: Libnucnet__Nuc__free()
- Line 77: Libnucnet__Species__getZ()
- Line 80: Libnucnet__Species__getA()
- Line 83: Libnucnet__Species__getMassExcess()
- Line 86: Libnucnet__Species__getSpin()
- Line 88: Libnucnet__Species__getSource()
To run example6, type the following on the command line:
./example6 ../../data_pub/example_nuc.xml si28 > ex6_output.txt
The result is ex6_output.txt
Example 7: Create a collection of nuclei from an input xml file and output data about a particular species selected by its charge, mass, and state.
libnucnet routines demonstrated in example7.c are:
- Line 59: Libnucnet__Nuc__new_from_xml()
- Line 69: Libnucnet__Nuc__getSpeciesByZA()
- Line 86: Libnucnet__Species__getName()
- Line 87: Libnucnet__Species__getIndex()
- Line 89: Libnucnet__Nuc__free()
To run example6, type the following (for the case of al27) on the command line:
./example7 ../../data_pub/example_nuc.xml 13 27 > ex7_output.txt
The result is ex7_output.txt
When there are multiple states present for the isotope, select them by their state index (for example, g or m):
./example7 ../../data_pub/example_nuc.xml 13 26 m > ex7_state_output.txt
The result is ex7_state_output.txt
Example 8: Create a collection of nuclei from an input xml file and print out the nuclear partition function for a particular species selected by its name.
libnucnet routines demonstrated in example8.c are:
- Line 52: Libnucnet__Nuc__new_from_xml()
- Line 60: Libnucnet__Nuc__getSpeciesByName()
- Line 80: Libnucnet__Species__computePartitionFunction()
- Line 89: Libnucnet__Nuc__free()
To run example8, type the following on the command line:
./example8 ../../data_pub/example_nuc.xml ca42 > ex8_output.txt
The result is ex8_output.txt
Example 9: Create a collection of nuclei from an input xml file and print out the nuclear partition function for a particular species selected by its charge, mass, and state.
libnucnet routines demonstrated in example9.c are:
- Line 60: Libnucnet__Nuc__new_from_xml()
- Line 70: Libnucnet__Nuc__getSpeciesByZA()
- Line 85: Libnucnet__Nuc__free()
- Line 93: Libnucnet__Species__getName()
- Line 101: Libnucnet__Species__computePartitionFunction()
To run example9, type the following on the command line:
./example9 ../../data_pub/example_nuc.xml 13 27 > ex9_output.txt
The result is ex9_output.txt
When there are multiple states present for the isotope, select them by their state index (for example, g or m):
./example9 ../../data_pub/example_nuc.xml 13 26 m > ex9_state_output.txt
The result is ex9_state_output.txt