Difference between revisions of "KrakenTools examples"
(→Creating Serpent water compositions) |
(Restore changes) |
||
(3 intermediate revisions by one other user not shown) | |||
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: | + | <div class="toccolours mw-collapsible mw-expanded" style="width:70em;"> |
'''docstring for the krakentools.writeWaterComposition method''' | '''docstring for the krakentools.writeWaterComposition method''' | ||
<div class="mw-collapsible-content"> | <div class="mw-collapsible-content"> | ||
>>> import krakentools | >>> import krakentools | ||
>>> help(krakentools.writeWaterComposition) | >>> help(krakentools.writeWaterComposition) | ||
+ | Help on function writeWaterComposition in module krakentools.utils: | ||
− | writeWaterComposition(fresh_water_mass_density, boron_in_ppm_weight, temperature, fout=None, fname='./watercomp.txt', thermlibs=None | + | writeWaterComposition(fresh_water_mass_density:float, boron_in_ppm_weight:float, |
+ | temperature:float, fout:TextIO=None, fname:str='./watercomp.txt', thermlibs:Sequence[Tuple[str, float]]=[], mat_name:str='') -> None | ||
Writes water material card and optionally the therm-card for Serpent into a file | Writes water material card and optionally the therm-card for Serpent into a file | ||
for a specific state point (fresh water density + boron ppm) | for a specific state point (fresh water density + boron ppm) | ||
Arguments: | Arguments: | ||
− | fresh_water_mass_density {float} -- target mass density of non-borated water (positive number, g/cm3) | + | fresh_water_mass_density {float} -- |
− | boron_in_ppm_weight {float} -- boron concentration in ppm weight | + | target mass density of non-borated water (positive number, g/cm3) |
− | temperature {float} -- water temperature in Kelvin | + | boron_in_ppm_weight {float} -- |
+ | boron concentration in ppm weight | ||
+ | temperature {float} -- | ||
+ | water temperature in Kelvin | ||
Keyword Arguments: | Keyword Arguments: | ||
− | fout {file handle} -- Handle to a pre-opened file into which the water | + | fout {file handle} -- |
− | + | Handle to a pre-opened file into which the water composition will be | |
− | fname {str} -- Optional name of file into which the water composition | + | written (default: {None}) |
− | + | fname {str} -- | |
− | thermlibs {[N*[str, float]]} -- A list of (thermal scattering library | + | Optional name of file into which the water composition will be |
− | + | written (default: {"./watercomp.txt"}) | |
− | + | thermlibs {[N*[str, float]]} -- | |
+ | A list of (thermal scattering library identifier)-(temperature) pairs | ||
+ | (default: {None}) | ||
+ | mat_name {str} -- | ||
+ | Name for the created material (default: {""}, will be created based on state point) | ||
Raises: | Raises: | ||
Line 151: | Line 160: | ||
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. | ||
+ | |||
+ | [[Category:KrakenTools]] |
Latest revision as of 09:24, 8 October 2024
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.