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 74: Libnucnet__Nuc__new()
- Line 90: Libnucnet__Nuc__addSpecies()
- Line 126: Libnucnet__Nuc__removeSpecies()
- Line 128: Libnucnet__Nuc__getSpeciesByName()
- Line 139: Libnucnet__Nuc__free()
- Line 191: Libnucnet__Nuc__getFirstSpecies()
- Line 195: Libnucnet__Species__getIndex()
- Line 196: Libnucnet__Species__getZ()
- Line 197: Libnucnet__Species__getA()
- Line 198: Libnucnet__Species__getName()
- Line 199: Libnucnet__Species__getMassExcess()
- Line 200: Libnucnet__Species__getSpin()
- Line 201: Libnucnet__Species__getSource()
- Line 204: Libnucnet__Species__getNext()
- Line 212: Libnucnet__Nuc__getNumberOfSpecies()
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 79: Libnucnet__Nuc__new()
- Line 123: Libnucnet__Nuc__addSpecies()
- Line 152: Libnucnet__Nuc__writeToXmlFile()
- Line 158: 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 65: 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.1/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 71: Libnucnet__Nuc__new_from_xml()
- Line 86: Libnucnet__Nuc__free()
- Line 111: Libnucnet__Nuc__getFirstSpecies()
- Line 115: Libnucnet__Species__getIndex()
- Line 116: Libnucnet__Species__getZ()
- Line 117: Libnucnet__Species__getA()
- Line 118: Libnucnet__Species__getName()
- Line 119: Libnucnet__Species__getMassExcess()
- Line 120: Libnucnet__Species__getSpin()
- Line 121: Libnucnet__Species__getSource()
- Line 124: Libnucnet__Species__getNext()
- Line 132: Libnucnet__Nuc__getNumberOfSpecies()
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.1/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 75: Libnucnet__Nuc__new_from_xml()
- Line 91: Libnucnet__Nuc__updateFromXml()
- Line 97: Libnucnet__Nuc__sortSpecies()
- Line 110: Libnucnet__Nuc__free()
- Line 135: Libnucnet__Nuc__getFirstSpecies()
- 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()
- Line 148: Libnucnet__Species__getNext()
- Line 156: Libnucnet__Nuc__getNumberOfSpecies()
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.1/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 69: Libnucnet__Nuc__new_from_xml()
- Line 72: Libnucnet__Nuc__new()
- Line 74: Libnucnet__Nuc__updateFromXml()
- Line 82: Libnucnet__Nuc__getSpeciesByName()
- Line 87: Libnucnet__Nuc__free()
- Line 97: Libnucnet__Species__getZ()
- Line 100: Libnucnet__Species__getA()
- Line 103: Libnucnet__Species__getMassExcess()
- Line 106: Libnucnet__Species__getSpin()
- Line 108: 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 80: Libnucnet__Nuc__new_from_xml()
- Line 90: Libnucnet__Nuc__getSpeciesByZA()
- Line 94: Libnucnet__Species__getName()
- Line 112: Libnucnet__Species__getIndex()
- Line 114: 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 72: Libnucnet__Nuc__new_from_xml()
- Line 80: Libnucnet__Nuc__getSpeciesByName()
- Line 100: Libnucnet__Species__getPartitionFunction()
- Line 109: 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 81: Libnucnet__Nuc__new_from_xml()
- Line 91: Libnucnet__Nuc__getSpeciesByZA()
- Line 95: Libnucnet__Species__getName()
- Line 112: Libnucnet__Nuc__free()
- Line 128: Libnucnet__Species__getPartitionFunction()
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