What I did

What I learned

def gen_delta_rho_shift(df, shift_sigma):
  df_temp = df.copy()
  df_temp['shift_val'] = np.random.normal(loc=0, scale=shift_sigma, size=df_temp.shape[0])
  df_temp['theta'] = 6.28*np.random.random_sample(df_temp.shape[0])
  df_temp['phi'] = 6.28*np.random.random_sample(df_temp.shape[0])
  # shift_val=radius of sphere project new point onto = distance of new disordered atom from original location
  df_temp['x'] += round(df_temp.shift_val*np.sin(df_temp.phi)*np.cos(df_temp.theta), 5)
  df_temp['y'] += round(df_temp.shift_val*np.sin(df_temp.phi)*np.sin(df_temp.theta), 5)
  df_temp['z'] += round(df_temp.shift_val*np.cos(df_temp.phi), 5)
  # turn to numpy array
  x1 = df_temp.loc[:, 'x'].values
  y1 = df_temp.loc[:, 'y'].values
  z1 = df_temp.loc[:, 'z'].values
  return x1, y1, z1

I’ve been thinking about this code, and I think there’s a relationship between the middle section of that code and the dot product with the unit vector. I could probably greatly improve the code’s efficiency if I figure this out.

What I will do next