dkriegner / xrayutilities

xrayutilities - a package with useful scripts for X-ray diffraction physicists
http://xrayutilities.sourceforge.io
GNU General Public License v2.0
83 stars 29 forks source link

Missing materials attribute #127

Closed mfdecamp closed 3 years ago

mfdecamp commented 3 years ago

I am trying to fit an xray reflectivity curve of a simple tungsten thin film. When I define the layer, I get the following error:

lW = xu.simpack.Layer(xu.materials.W,335)

AttributeError: module 'xrayutilities.materials' has no attribute 'W'

I can see that the tungsten is included in the elements.py, so I am curious how I can call on the scattering files for Tungsten. I am using version 1.7.0

dkriegner commented 3 years ago

I have just added tungsten as a material. so with the next release the error will be gone. the problem is that I never systematically added all elemental materials. the elements themself are all added since they are parsed from the included databases. the material itself however is a bit more since it also contains information about the crystal structure (and not only optical, weight, ... properties of the atom)

To fix it for you I suggest to define the material locally

import xrayutilities as xu
W = xu.materials.Crystal("W", xu.materials.SGLattice(222, 3.1652, atoms=["W", ], pos=["2a", ]))

then layerW = xu.simpack.Layer(W, thickness) should work without problems.

If this fixes your problem please close this issue.

mfdecamp commented 3 years ago

Thank you. That seems to have worked