Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

End to end tests incompatible with - Vectorization of xrd_simulator #9 #11

Closed
AxelHenningsson opened this issue Aug 4, 2024 · 6 comments
Assignees
Labels
bug Something isn't working

Comments

@AxelHenningsson
Copy link
Collaborator

The awesome vectorization work 💪 🔨 of @Marcraven would be awesome to propagate to the end to test and examples of xrd_simulator.

It would seem that all that is required is to propagate the slightly changed call signatures into the scripts in tests/end_to_end_tests. There was recently interest in the powder diffraction example so perhaps start there. 🙂

Cheers
Axel

@AxelHenningsson AxelHenningsson added the bug Something isn't working label Aug 4, 2024
@vamatya
Copy link
Contributor

vamatya commented Aug 7, 2024

While testing the above example(powder diffraction) , first I get Numba - Numpy version mismatch error. Once that is fixed by downgrading numpy, I get the following error:

{
"name": "TypeError",
"message": "unsupported operand type(s) for /: 'function' and 'float'",
"stack": "---------------------------------------------------------------------------
TypeError Traceback (most recent call last)
File ~/WORKSPACE/XRD/xrd_simulator/tests/end_to_end_tests/s3dxrd_odf_sample.py:53
44 def strain_tensor(x): return np.array(
45 [[0, 0, 0], [0, 0, 0], [0, 0, 0.02 * x[2] / sample_bounding_cylinder_height]])
47 # Make the beam much smaller than the sample
48 # vertices = beam.vertices.copy()
49 # vertices[:,1:] = 0.180*vertices[:,1:]/np.max(vertices[:,1:])
50 # beam.set_beam_vertices(vertices)
---> 53 polycrystal = templates.polycrystal_from_odf(orientation_density_function,
54 number_of_crystals,
55 sample_bounding_cylinder_height,
56 sample_bounding_cylinder_radius,
57 unit_cell,
58 sgname,
59 maximum_sampling_bin_seperation,
60 strain_tensor)
61 path = os.path.join(
62 os.path.join(
63 os.path.dirname(file),
64 'saves'),
65 'polycrystal_from_odf')
66 polycrystal.save(path, save_mesh_as_xdmf=True)

File ~/miniconda3/envs/xrd_sim_conda__py3.10/lib/python3.10/site-packages/xrd_simulator/templates.py:169, in polycrystal_from_odf(orientation_density_function, number_of_crystals, sample_bounding_cylinder_height, sample_bounding_cylinder_radius, unit_cell, sgname, path_to_cif_file, maximum_sampling_bin_seperation, strain_tensor)
166 element_phase_map = np.zeros((mesh.number_of_elements,)).astype(int)
168 # Sample spatial texture
--> 169 orientation = _sample_ODF(
170 orientation_density_function,
171 maximum_sampling_bin_seperation,
172 mesh.ecentroids)
174 # Sample spatial strain
175 strain_lab = np.zeros((mesh.number_of_elements, 3, 3))

File ~/miniconda3/envs/xrd_sim_conda__py3.10/lib/python3.10/site-packages/xrd_simulator/templates.py:293, in _sample_ODF(ODF, maximum_sampling_bin_seperation, coordinates)
289 def _sample_ODF(ODF, maximum_sampling_bin_seperation, coordinates):
290 """Draw orientation matrices form an ODF at spatial locations coordinates.
291 """
--> 293 dalpha = maximum_sampling_bin_seperation / 2. # TODO: verify this analytically.
294 dalpha = np.pi / 2. / int(np.pi / (dalpha * 2.))
295 alpha_1 = np.arange(
296 0 +
297 dalpha /
(...)
305 dalpha,
306 dalpha)

TypeError: unsupported operand type(s) for /: 'function' and 'float'"
}

@AxelHenningsson
Copy link
Collaborator Author

Thanks for the stackstrace. ❤️ This bug 🐛 reproduced nicely on a Windows machine building from source for me. Simple syntax drift that could be fixed rapidly.

Now closing with latest updates in commit 21e58b6 which should fix all of this. 10000 tetra mesh grains generated using a custom ODF can be viewed below (see tests/end_to_end_tests/s3dxrd_odf_sample.py)

image

Cheers
Axel

@vamatya
Copy link
Contributor

vamatya commented Aug 7, 2024

Thanks for working on this! I'm able to get the Debye-Scherrer rings. Meanwhile, may I ask how did you generate/plot the figure on right?

Thanks,
Vinay

@AxelHenningsson
Copy link
Collaborator Author

Hi!

I use Paraview for visualizing the samples. 🙂

When you call .save() on a polycrystal object, there is a .xdmf getting written to disk. This file can be opened in paraview and different element attributes can be used to color the tets (like one of the bunge Euler angles as was done above)

In the mentioned example the polycrystal is written to the "save" folder. Check it out 😎 !

Cheers
Axel

@vamatya
Copy link
Contributor

vamatya commented Aug 8, 2024

Thanks Axel! 🙂

@Marcraven
Copy link
Collaborator

Thanks for the kind words and the debugging! I am currently in paternity leave so no more coding until mid September!

Cheers!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants