Difference between revisions of "KrakenTools examples"
(Created page with "== Creating Serpent water compositions == Water composition material cards for Serpent can be generated using the krakentools.writeWaterComposition() method: >>> help(krake...") |
(→Creating Serpent water compositions) |
||
Line 3: | Line 3: | ||
Water composition material cards for Serpent can be generated using the krakentools.writeWaterComposition() method: | Water composition material cards for Serpent can be generated using the krakentools.writeWaterComposition() method: | ||
+ | <div class="toccolours mw-collapsible mw-expanded" style="width:60em;"> | ||
+ | '''docstring for the krakentools.writeWaterComposition method''' | ||
+ | <div class="mw-collapsible-content"> | ||
+ | >>> import krakentools | ||
>>> help(krakentools.writeWaterComposition) | >>> help(krakentools.writeWaterComposition) | ||
Line 25: | Line 29: | ||
Raises: | Raises: | ||
RuntimeError: If the target temperature is not bracketed by the thermal scattering libraries. | RuntimeError: If the target temperature is not bracketed by the thermal scattering libraries. | ||
+ | </div> | ||
+ | </div> | ||
By default, the function writes the material card to a file <tt>./watercomp.txt</tt> but a pre-opened file handle can be passed as <tt>fout</tt> keyword argument also. For example: | By default, the function writes the material card to a file <tt>./watercomp.txt</tt> but a pre-opened file handle can be passed as <tt>fout</tt> keyword argument also. For example: | ||
+ | <div class="toccolours mw-collapsible mw-expanded" style="width:60em;"> | ||
+ | '''test1.py''' | ||
+ | <div class="mw-collapsible-content"> | ||
#!/usr/bin/env python3 | #!/usr/bin/env python3 | ||
# -*- coding: utf-8 -*- | # -*- coding: utf-8 -*- | ||
Line 35: | Line 44: | ||
# --- Open a file into which the composition will be written | # --- Open a file into which the composition will be written | ||
− | fout = open("./ | + | fout = open("./some_name.txt","w") |
# --- Water density in g/cm3 (does not include boron) | # --- Water density in g/cm3 (does not include boron) | ||
Line 56: | Line 65: | ||
fout.close() | fout.close() | ||
+ | </div></div> | ||
will produce the following file: | will produce the following file: | ||
+ | <div class="toccolours mw-collapsible mw-expanded" style="width:60em;"> | ||
+ | '''some_name.txt''' | ||
+ | <div class="mw-collapsible-content"> | ||
mat cool_1000B_100D -1.00100 tmp 550 | mat cool_1000B_100D -1.00100 tmp 550 | ||
moder lw550K 1001 | moder lw550K 1001 | ||
Line 69: | Line 82: | ||
B-10.03c 1.105860e-04 | B-10.03c 1.105860e-04 | ||
B-11.03c 4.451225e-04 | B-11.03c 4.451225e-04 | ||
− | + | </div></div> | |
The tmp and moder cards are automatically written based on the requested temperature, but as we provided no thermal scattering libraries, the therm card is not written. We could add a list of thermal scattering library identifiers and their corresponding temperatures, which would also append the correct therm card for the identifier specified in the moder card: | The tmp and moder cards are automatically written based on the requested temperature, but as we provided no thermal scattering libraries, the therm card is not written. We could add a list of thermal scattering library identifiers and their corresponding temperatures, which would also append the correct therm card for the identifier specified in the moder card: | ||
− | + | <div class="toccolours mw-collapsible mw-expanded" style="width:60em;"> | |
+ | '''test2.py''' | ||
+ | <div class="mw-collapsible-content"> | ||
#!/usr/bin/env python3 | #!/usr/bin/env python3 | ||
# -*- coding: utf-8 -*- | # -*- coding: utf-8 -*- | ||
Line 93: | Line 108: | ||
# --- Open a file into which the composition will be written | # --- Open a file into which the composition will be written | ||
− | fout = open("./ | + | fout = open("./some_other_name.txt","w") |
# --- Water density in g/cm3 (does not include boron) | # --- Water density in g/cm3 (does not include boron) | ||
Line 114: | Line 129: | ||
fout.close() | fout.close() | ||
+ | </div></div> | ||
would produce the file | would produce the file | ||
+ | <div class="toccolours mw-collapsible mw-expanded" style="width:60em;"> | ||
+ | '''some_other_name.txt''' | ||
+ | <div class="mw-collapsible-content"> | ||
mat cool_1000B_100D -1.00100 tmp 550 | mat cool_1000B_100D -1.00100 tmp 550 | ||
moder lw550K 1001 | moder lw550K 1001 | ||
Line 129: | Line 148: | ||
therm lw550K lwe7.10t | therm lw550K lwe7.10t | ||
+ | </div></div> | ||
This works even if the material temperature is between two library temperatures, in which case the therm card will use interpolation. | This works even if the material temperature is between two library temperatures, in which case the therm card will use interpolation. |
Revision as of 15:38, 10 July 2019
Creating Serpent water compositions
Water composition material cards for Serpent can be generated using the krakentools.writeWaterComposition() method:
By default, the function writes the material card to a file ./watercomp.txt but a pre-opened file handle can be passed as fout keyword argument also. For example:
will produce the following file:
The tmp and moder cards are automatically written based on the requested temperature, but as we provided no thermal scattering libraries, the therm card is not written. We could add a list of thermal scattering library identifiers and their corresponding temperatures, which would also append the correct therm card for the identifier specified in the moder card:
would produce the file
This works even if the material temperature is between two library temperatures, in which case the therm card will use interpolation.