Esempio n. 1
0
 def itera(self):
     npart = self.initial["npart"]
     masses = self.initial["masses"]
     #Creo una matriu per guardar totes les dades
     All_positions = np.zeros((npart, 3, self.params.niter))
     All_velocities = np.zeros((npart, 3, self.params.niter))
     posicions = self.initial["posicions_inicials"]
     vels = self.initial["velocitats_inicials"]
     logging.info("Starting simulation")
     for step in t(range(self.params.niter)):
         accs = acceleracions(posicions, masses, self.params.A,
                              self.params.B)
 def itera(self):
     npart = self.initial["npart"]
     masses = self.initial["masses"]
     #Creo una matriu per guardar totes les dades
     self.positions = np.zeros((npart, 3, self.params.niter))
     self.velocities = np.zeros((npart, 3, self.params.niter))
     self.accelerations = np.zeros((npart, 3, self.params.niter))
     pos_act = self.initial["posicions_inicials"]
     vel_act = self.initial["velocitats_inicials"]
     integrador = integradors.string2func(self.params.integrador)
     logging.info("Començant simulació, " + str(self.params.niter) +
                  " iteracions, timestep = " + str(self.params.timestep))
     for step in t(range(self.params.niter)):
         pos_ant = self.positions[:, :, step - 1]
         self.positions[:, :, step] = pos_act
         self.velocities[:, :, step] = vel_act
         acc_act = acceleracions(pos_act, masses, self.params.A,
                                 self.params.B)
         self.accelerations[:, :, step] = acc_act
         pos_act, vel_act = integrador(pos_act, vel_act, acc_act, timestep)
def Verlet(x_t, x_t_1, vel_t, masses, timestep):
	acc_t = acceleracions(x_t, masses)
	return 2*x_t-x_t_1+acc_t*np.power(timestep,2), acc_t*timestep + vel_t
def Euler(x_t, x_t_1, vel_t, masses, timestep):

    acc_t = acceleracions(x_t, masses)
	return vel_t*timestep + x_t, acc_t*timestep + vel_t