Esempio n. 1
0
    def evolve_floc(self, Deform = True, MaxTimes = 100, TimeRange = None, FullOutput = False):
        """
        
        Inputs:
            MaxTimes         int; number of time points to compute the stress over. The deformation
                             integral returns more than we want to use for efficiency reasons when
                             doing these computations over thousands of flocs at once.
        
            TimeRange        [t0, t1, dt] or None. If None (default), will use dfm's set_tau_cap
                             function to automatically determine the time step and final time.
            
            FullOutput       Bool; if True will set attributes Ra, wV, and T (see below).


        Sets Attributes::
            forces[MaxTimes][NEdges]       float, NEdges is the number of edges in the floc. i j entry
                                           is the fragmentation force acting against the j plane at time i
            aV[MaxTimes][3]                float, axes lenghts at each time step
            (optional)
            Ra[MaxTimes][2]                float, the two unique entries defining rotation R (cos theta, sin theta)
            wV[MaxTimes][3]                float, angular velocity at each time step
            T[MaxTimes]                    float, times 
        """
        if len(self.mst_sph) == 0:
            # then the floc is size 1 and won't fragment so we don't bother deforming it
            Ra = np.array([])
            wV = np.array([])
            T = np.array([])
            forces = np.array([])
        else:
            # compute the time interval if we don't have one
            if TimeRange == None:
                t0, t1, dt, tau, cap = dfm.set_tau_cap(self.a0, self.lam, self.mu, self.gammadot, self.Gamma)
            else:
                t0,t1,dt = TimeRange
            # deform the floc (or just rotate if not deforming or is too elongated already)
            if ( (Deform == True) & (self.a0[0] / self.a0[1] < 6.0) ):
                aV, Ra, wV, T = dfm.deform(t0, t1, dt, self.a0, self.lam, self.mu, self.gammadot, self.Gamma, True)
            else:
                aV, Ra, wV, T = dfm.solid_rotations(t0, t1, dt, self.a0, self.gammadot, True)
            # shorten the length of the output
            if np.shape(T)[0] > MaxTimes:
                StepSize = int(np.floor(np.shape(T)[0] / MaxTimes))
                aV = np.ascontiguousarray( aV[::StepSize] )
                Ra = np.ascontiguousarray( Ra[::StepSize] )
                wV = np.ascontiguousarray( wV[::StepSize] )
                T =  np.ascontiguousarray( T[::StepSize]  )
            # get the force matrix
            forces = frc.py_set_force_Vectorized(aV, Ra, wV, self.pnV_sph, \
                                                 self.pxV_sph, self.gammadot, self.p0, self.mu)
            self.aV = aV
        if FullOutput == True:
            self.Ra = Ra
            self.wV = wV
            self.T = T
        
        self.forces = forces
Esempio n. 2
0
import numpy as np


# import the constants
lam, mu, gammadot, Gamma, max_stress, p0 = import_constants()
# set the initial axes
a0 = np.array([180.0, 160.0, 140.0])
# compute the time interval
t0, t1, dt, tau, cap = dfm.set_tau_cap(a0, lam, mu, gammadot, Gamma)
# get the rotations, axes and angular velocity
aV, RV, wV, T = dfm.deform(t0, t1, dt, a0, lam, mu, gammadot, Gamma)


TimeInd = 100
a = aV[TimeInd]
w = wV[TimeInd]
R = RV[TimeInd]
rotAng = np.array([R[0, 0], R[1, 0]])
pn = np.array([1.0, 0.0, 0.0])
px = np.zeros(3)

fonfV1, cV = frc.set_fonfV(a, w, R, gammadot, p0, mu)
force1 = frc.py_set_force(a, fonfV1, cV, pn, px)

fonfV2, force2 = frc.py_set_force_Vectorized(a, rotAng, w, pn, px, gammadot, p0, mu)

L0 = np.zeros([3, 3])
L0[0, 1] = gammadot

Lrot = np.dot(np.dot(R, L0), R.T)
Esempio n. 3
0
a = aV[ind]
pn = np.array([1,0,0], dtype=float)
px = np.zeros(3)
stress = frc.py_set_stress(a, fonfV, cV, pn, px)
total_force = frc.py_set_force(a, fonfV, cV, pn, px)
print("\n set_force \n")
print("you don't want this to be 0: %e" %total_force)

## test set_force_Vectorized
NN = np.shape(RV)[0]
#rotAngles = np.zeros([NN,2])
#rotAngles[:,0] = RV[:,0,0]
#rotAngles[:,1] = RV[:,1,0]
pnV = np.random.rand(10,3)
pxV = np.zeros([10,3])
forces = frc.py_set_force_Vectorized(aV, RV, wV, pnV, pxV, gammadot, p0, mu)
# check the relevant entry of this matrix with the computation above
test_ind = 0
a = aV[test_ind]
w = wV[test_ind]
R = RV[test_ind]
farg,fonfV,cV,surf_areas_scaled = frc.set_fonfV(a, w, R, gammadot, p0, mu)
pn = pnV[0]
px = pxV[0]
total_force = frc.py_set_force(a, fonfV, cV, pn, px)
# now these should be the same. 
print("\n set_force_Vectorized \n")
rel_err = np.abs((forces[test_ind,0] - total_force)/total_force)
# somehow they are off by ~0.01% or something, really strange, spent too long
# trying to find it. 
Esempio n. 4
0
farg3, fonfV3, srf_centers_scaled3, srf_areas_scaled3 = frc.set_fonfV(aV[ind3], \
                                                                      wV[ind3],  \
                                                                      Ra[ind3], \
                                                                      gammadot, p0, mu)

# compute the force wrt a plane
pn = np.array([1.0,0.0,0.0])
px = np.array([0.0,0.0,0.0])

force0 =  frc.py_set_force(aV[ind0], fonfV0, srf_centers_scaled0, pn, px)
force1 =  frc.py_set_force(aV[ind1], fonfV1, srf_centers_scaled1, pn, px)
force2 =  frc.py_set_force(aV[ind2], fonfV2, srf_centers_scaled2, pn, px)
force3 =  frc.py_set_force(aV[ind3], fonfV3, srf_centers_scaled3, pn, px)

# get all forces so we know the max
forces_all = frc.py_set_force_Vectorized(aV, Ra, wV, pn, px, gammadot, p0, mu)
forcemax = np.max(np.abs(forces_all))


indices = [ind0, ind1, ind2, ind3]
forces =  [force0, force1, force2, force3, forcemax]
angles =  [Ra[ind] for ind in indices]
axes =    [aV[ind] for ind in indices]
angvels = [wV[ind,2] for ind in indices]
fargs =   [farg0, farg1, farg2, farg3]


pltind0 = 0
pltind1 = 1000
plt.subplot(2,2,1)
plt.plot(aV[pltind0:pltind1,0], 'bo')