kklmn / xrt

Package xrt (XRayTracer) is a python software library for ray tracing and wave propagation in x-ray regime. It is primarily meant for modeling synchrotron sources, beamlines and beamline elements.
MIT License
84 stars 30 forks source link

laterally graded thicknesses #155

Open leverglow opened 1 year ago

leverglow commented 1 year ago

Hi, Depth graded multilayer can be set by xrtQook easily,but xrtQook says that'If you need laterally graded thicknesses, modify get_t_thickness and/or get_b_thickness in a subclass.' My question is how to set the laterally graded multilayer.I don't know how to'modify get_t_thickness and/or get_b_thickness in a subclass'

kklmn commented 1 year ago

Hi, The method's signature can be found in the docs. x and y are in mm, the returned thickness is in Å.

leverglow commented 1 year ago

Thanks for your reply,I found what it means in the docs.So may I set the laterally graded multilayer directly in xrtQook by commenting or uncommenting codes?Or I need to wirte codes myself to set it.

kklmn commented 1 year ago

If you want it in xrtQook then it's a bit harder. You have to create a derived class of Multilayer yourself where you implement the methods get_t_thickness and get_b_thickness, xrtQook cannot know the lateral thickness variation you are going to implement. There is a mechanism in xrtQook for registering custom (user) optical element classes, but not custom material classes. So you will have to also make a derived class from the optical element you're using, in whose __init__ you specify the custom multilayer material. Then you register this OE class in xrtQook, as explained in xrtQookStart.py.

leverglow commented 1 year ago

OK,that's too difficult for me.So how I can directly use 'get_t_thickness'.If I use gradedMultilayer,the codes are'gradedMultilayer02 = rmats.GradedMultilayer( tLayer=Ru, tThickness=16.5, bLayer=C, bThickness=16.5, nPairs=60, tThicknessLow=19.9, bThicknessLow=19.9, name=None)' I can determine depth graded multilayer's thickness through' tThickness=16.5',so how to determine laterally graded thicknesses through'get_t_thickness'

kklmn commented 1 year ago

So how I can directly use 'get_t_thickness'.

It is not you who uses the method, xrt uses it. You create it.

leverglow commented 1 year ago

So in which program(.py) should I modify the code to implement laterally graded thicknesses.

kklmn commented 1 year ago

You should subclass Multilayer from xrt/backends/raycing/materials.

leverglow commented 1 year ago

I write the code 'class LMultilayer(Multilayer): def get_t_thickness(self, x, y, iPair): global XY # to extract x,y values XY = np.array([x,y]) return self.dti[iPair] def get_b_thickness(self, x, y, iPair): return self.dti[iPair]'in materials.py. Then I tried to use it through 'gradedMultilayer01 = rmats.LMultilayer(
tLayer=Ru, bLayer=C, tThickness=19.5, bThickness=19.5, nPairs=150, tThicknessLow=15.2, bThicknessLow=15.2, name=None)' but it does't work,the results are the same when I change'gradedMultilayer01 = rmats.LMultilayer(' to 'gradedMultilayer01 = rmats.GradedMultilayer('. I don't know if I'm calling the function(class LMultilayer) in a wrong way or if the function itself is wrong

kklmn commented 1 year ago

How do you want to define the graded thickness? How does it change in space as a function of x and y?

leverglow commented 1 year ago

The laterally graded multilayer consists of two materials and their thickness only varies with x,so no matter where the laser hits, it can have a high reflectivity.There is a function between x and thickness.So do I need to write complex computational relationships between them as part of the code?Or just modify parts of depth graded multilayer's code.

kklmn commented 1 year ago

There is a function between x and thickness.

You need to implement this dependence inside the two methods get_t_thickness and get_b_thickness in your subclass.

leverglow commented 1 year ago

Okay, so how does the depth gradient multilayer set up the function between x and depth? I would like to refer to it to set up the lateral gradient multilayer.

kklmn commented 1 year ago

If I understand your question correctly (I am not sure about it) then my first reply in this thread is the answer to it.

leverglow commented 1 year ago

I know the function'get_b_thickness(x, y, iPair)' and what each parameter represents,but how can I use it in my python program.For example, my lateral gradient multilayer goes from 30nm to 20nm, and there are 100 pairs.I mean what exactly is the code to use 'get_b_thickness(x, y, iPair)'and 'get_t_thickness(x, y, iPair)'.

kklmn commented 1 year ago

Any reason why somebody should code for you?

kklmn commented 1 year ago

One such reason could be your will to share experimental data that you're trying to model. Another reason for me could be in seeing that this study is a part of a bigger and attractive project.