ukaea / neutronics_material_maker

A tool for making parametric material cards for use in neutronics codes. Original developed for the Paramak

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

T dependence

CoronelBuendia opened this issue · comments

I had added T-dependent density functions to some materials in refmaterials.py in develop2, so that the density is modified when writing the material card. (Default temperature is 293.15 K.)

This isn't enough however: the cross-sections inside the libraries need to be adjusted to the temperature (Doppler broadening).

In Serpent II, this is easy:

mat [name] -[T-dependent density in g/cm^3] tmp [T in K]

I don't know how to handle this in MCNP, but I will include this as an argument to the material header. I think this feature should also be included for MCNP.

Below is my present implementation so far (with only changes to nmm.py shown). Will clean up, write some tests, and push to a develop branch. Comments / requests welcome.

    class Base(object):
[...]
    def material_card_header(self, material_card_name, color, code, fractions,
                             **kwargs):
[...]
        if code == 'serpent':
            T = kwargs.get('T', 293.15)
            tmp = ' tmp '+str(T)+' '
            mat_card = [comment, comment + self.material_card_comment,
                        'mat '+material_card_name+density+tmp+color]
            T = kwargs.get('T', 293.15)
[...]
B = Beryllium()  #  from refmaterials.py

print(B.material_card())
%  
%  material card made with neutronics_material_maker
mat Be -1.83 tmp 293.15  rgb 0 0 0
   4009.31c    0.998500803562           % Beryllium_9
   13027.31c   0.000200836350565        % Aluminium_27
 [...]

print(B.material_card(T=400))
%  
%  material card made with neutronics_material_maker
mat Be -1.8224900391645937 tmp 400  rgb 0 0 0
   4009.31c    0.998500803562           % Beryllium_9
   13027.31c   0.000200836350565        % Aluminium_27
 [...]

tmp is a nice feature

In MCNP the flag is the same "tmp" but it is placed in the cell not in the material card.

We can add it as a comment in mcnp material card
c tmp 400

Adding the tmp card might also have impacts when finding the best nuclear library to use in from the xsdir

OK, I pushed to develop2. Let me know what you think.

I think it is a great idea

I have added temperature_K as an option when creating to Isotope, Elements, Compounds, Materials and Homogenised_mixtures. This property is also used for calculating the density of liquids and gases so I think it was already in Compounds.

However temperature_K can be overwritten when creating a material_card with the argument temperature_K.

I have also added test cases to check the temperature property appears in material cards

def test_default_temperature_in_material_cards(self):

  new_element = Element('W',density_g_per_cm3=19.6)

  assert 'temperature =293.15 K' in new_element.material_card(code='mcnp')
  assert 'tmp 293.15' in new_element.material_card(code='serpent')

temp stated at creation of object

new_element = Element('W',density_g_per_cm3=19.6,temperature_K =500)

temp stated at creation of material card

new_element.material_card(temperature_K =600)

If no temperature_K is provided it defaults to 293.15

Oh ok! I had done this last night just for mfmaterial in develop2, but then i guess i only use these. I hope we haven’t crossed implementations.. did you do it in the develop 2 branch?

I also wrote tests for it, but i tend to put them in the same file so i can test while developing. You can drag these into the test suit if you like? Or add the files to the ones to be run during the test suite?

Yes I think I added to your develop 2 branch.

I can track down your tests and put them in the test suite.

I copied your default 293 value but just moved it to the classes instead of the material header

I think this can be merged

Well it does break some things on my end, but I have fixed these up (some of the tests needed modifying mostly).

Going to add some EUROfer properties and push to develop2

Done (first time I have pushed from 30,000 ft :D)

Can we merge this now?

OK, merged.

I would say though, this doesn't work fully for homogenised mixtures. I'm not sure we need to do much; I just wrap this kind of stuff. Depends where you want to draw the line as to what nmm covers.

At the moment, I build the actual windingpacks mixture in BLUEPRINT, where I need to first make all the materials at the right temperature, and then make a compound at the right temperature (otherwise the density is not correctly calculated):

from neutronics_material_maker.refmaterials import (Nb3Sn, NbTi, EUROfer,
                                                    SS316LN, CuCrZr,
                                                    PureCopper, Bronze,
                                                    Tungsten, Beryllium,
                                                    DTPlasma, DDPlasma,
                                                    EpoxyResin, Void,
                                                    H2O, Helium)

from neutronics_material_maker.nmm import Homogenised_mixture


class WPmaterial(Homogenised_mixture):

    def __init__(self, mat_sc, f_sc, f_cu, f_epxy, f_brnz, f_he, f_ss, f_v,
                 T=4.5):
        SC = mat_sc(T=T)
        Cu = PureCopper(T=T)
        Epoxy = EpoxyResin(T=T)
        Bronz = Bronze(T=T)
        He = Helium(T=T, P=6e5)
        SS = SS316LN(T=T)
        V = Void(T=T)
        super().__init__(mixtures=[SC, Cu, Epoxy, Bronz, He, SS, V],
                         volume_fractions=[f_sc, f_cu, f_epxy, f_brnz, f_he,
                                           f_ss, f_v],
                         temperature_K=T)

I'm happy as is, but worth noting maybe?