Esempio n. 1
0
 def terminal_velocity(self, values, radius, k1, k2, k3, r1, r2):
     k1 = PrecisionResolver.get_floating_point(k1)
     k2 = PrecisionResolver.get_floating_point(k2)
     k3 = PrecisionResolver.get_floating_point(k3)
     r1 = PrecisionResolver.get_floating_point(r1)
     r2 = PrecisionResolver.get_floating_point(r2)
     self.__terminal_velocity_body.launch_n(values.size(), [values, radius, k1, k2, k3, r1, r2])
Esempio n. 2
0
def thrust(obj):
    if isinstance(obj, list):
        result = [thrust(o) for o in obj]
    elif hasattr(obj, 'data'):
        result = obj.data
    elif isinstance(obj, float):
        result = PrecisionResolver.get_floating_point(obj)
    elif isinstance(obj, int):
        result = trtc.DVInt64(obj)
    else:
        raise ValueError(f"Cannot upload {obj} to device.")
    return result
Esempio n. 3
0
 def __setitem__(self, key, value):
     if hasattr(value, 'data') and hasattr(value, 'shape') and len(value.shape) != 0:
         if isinstance(value, np.ndarray):
             vector = trtc.device_vector_from_numpy(value)
             trtc.Copy(vector, self.data)
         else:
             trtc.Copy(value.data, self.data)
     else:
         if isinstance(value, int):
             dvalue = trtc.DVInt64(value)
         elif isinstance(value, float):
             dvalue = PrecisionResolver.get_floating_point(value)
         else:
             raise TypeError("Only Storage, int and float are supported.")
         trtc.Fill(self.data, dvalue)
     return self
Esempio n. 4
0
 def explicit_euler(self, y, dt, dy_dt):
     dt = PrecisionResolver.get_floating_point(dt)
     dy_dt = PrecisionResolver.get_floating_point(dy_dt)
     self.__explicit_euler_body.launch_n(y.shape[0], (y.data, dt, dy_dt))
Esempio n. 5
0
 def critical_volume(self, v_cr, kappa, v_dry, v_wet, T, cell):
     kappa = PrecisionResolver.get_floating_point(kappa)
     self.__critical_volume_body.launch_n(
         v_cr.shape[0],
         (v_cr.data, kappa, v_dry.data, v_wet.data, T.data, cell.data))