Skip to content

Commit

Permalink
torch-cpu faster than numpy. numpy can be removed for simplicity
Browse files Browse the repository at this point in the history
  • Loading branch information
Marcraven committed Oct 18, 2024
1 parent 6b65013 commit ee5acfd
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 4 deletions.
5 changes: 2 additions & 3 deletions xrd_simulator/cuda.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
import numpy as np
import pandas as pd
# Default to False
fw = np
fw = torch


# ===============================================
Expand All @@ -12,11 +12,10 @@
print("CUDA is available and GPUs are found.")
gpu = input("Do you want to run in GPU? [y/n]").strip().lower() or 'y'
if gpu == 'y':
fw = torch
torch.set_default_device('cuda')
print("Running in GPU...")
else:
fw = np
torch.set_default_device('cpu')
print("Running in CPU...")
else:
print("CUDA is not available.")
Expand Down
2 changes: 1 addition & 1 deletion xrd_simulator/detector.py
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@ def render(self,
# Step 4: Use the new column as a pixel value to be added to each coordinate
rendered_frames[result[:,2].int(),result[:,0].int(),result[:,1].int()] = result[:,3]

rendered_frames = self._apply_point_spread_function(rendered_frames)
#rendered_frames = self._apply_point_spread_function(rendered_frames)

# Chose numpy if you want to write the frames as tiffs
if output_type == 'numpy':
Expand Down
1 change: 1 addition & 0 deletions xrd_simulator/polycrystal.py
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@ def _diffract(dict):
rigid_body_motion.rotation_angle,
)


# We now assemble the tensors with the valid reflections for each grain and phase including time, hkl plane and G vector
#Column names of peaks are 'grain_index','phase_number','h','k','l','structure_factors','times','G0_x','G0_y','G0_z')
if fw is np:
Expand Down

0 comments on commit ee5acfd

Please sign in to comment.