FABLE-3DXRD / xrd_simulator

Tools for simulating x-ray diffraction. Detailed documentation is found at the below link.
https://fable-3dxrd.github.io/xrd_simulator/
MIT License
23 stars 8 forks source link

Multiple unit cells or lattice parameters example #15

Open vamatya opened 2 weeks ago

vamatya commented 2 weeks ago

Hi,

For powdered sample (2D) XRD, is there an example with multiple unit cells/lattice parameters as input?

Thanks!

AxelHenningsson commented 2 weeks ago

Hi!

It would be helpful if you could specify more details about what you want.

2D - in what sense? Multiple unit cells - like a two phase material?

What part of your question is not covered by the documentation?

Cheers Axel Henningsson

vamatya commented 2 weeks ago

Hi Axel,

Thanks for the prompt reply.

Yes, I'm looking for an example where I can define a material with multiple phases.

RE 2D: I meant examples generating 2D diffraction rings.

I'm using polycrystal_from_odf(..) function for the above, as used in the "s3dxrd_odf_sample.py" example. As per the documentation, I believe multiple phases can be defined for Polycrystal(...)- is this the only way to define two(/multiple) phase material?

Thanks, Vinay

AxelHenningsson commented 2 weeks ago

Thank you. :=)

This amounts to a simple generalisation of polycrystal_from_odf() at these lines

the following code

    # Sample is uniformly single phase
    phases = [Phase(unit_cell, sgname, path_to_cif_file)]
    element_phase_map = np.zeros((mesh.number_of_elements,)).astype(int)

would change as

    # Sample is multi-phase with each phase equally present (volume fractions the same)
    phases  = [ Phase(uc, sg, path) for uc, sg, path in zip(unit_cell, sgname, path_to_cif_file)]
    element_phase_map  = np.random.randint(len(phases  ), size=(mesh.number_of_elements,))    

The input arguments of polycrystal_from_odf() (unit_cell, sgname and path_to_cif_file) would then need to become iterables.

Perhaps this is something you would like to contribute with? Feel free to open a pull-request.

Cheers Axel

vamatya commented 2 weeks ago

Thanks Axel! :)

I'll try that, and create a pull-request.

AxelHenningsson commented 2 weeks ago

Cool. Let me know if you run into any thing strange - and I will try to support. 👍

Cheers Axel

vamatya commented 2 weeks ago

Axel,

For the 2 phases in the above example, how can one assign phase fraction, eg. 30%,70%?

Thanks, Vinay

vamatya commented 2 weeks ago

I think I'll need to change this: element_phase_map = np.random.randint(len(phases ), size=(mesh.number_of_elements,))