def set_hydro_num(self, T, ndens): """Sets the matrix of momentum relaxation collsion rates formulated in the above reference for a system described by hydrodynamics, i.e. only a single temperature is avaliable. Parameters ---------- T : float System temperature in units of energy/kb ndens : (N,) np.ndarray Number density of each ion species in units of 1/length^{3}. """ leff = get_leff(T, T, self.zsolver.zbars, ndens, self.cd, o=self.o) #set each upper triangular nu to g for i in range(ndens.shape[0]): for j in range(i, ndens.shape[0]): self.nu[i, j] = self.zsolver.zbars[i]*self.zsolver.zbars[j] self.nu[i,j] = self.nu[i,j]*self.cd['e']*self.cd['e'] self.nu[i,j] = self.cd['kc']*self.nu[i,j]/leff/(self.cd['kb']*T) self.nu = 128.0*np.pi*np.pi*get_calk(1, 1, self.nu)/3.0/np.power(2*np.pi, 1.5) #set each lower triangular element to its upper triangular equivalent for i in range(ndens.shape[0]): for j in range(i, ndens.shape[0]): self.nu[i,j] = self.nu[i,j]*np.power(self.zsolver.zbars[i]*\ self.zsolver.zbars[j]*self.cd['e']*self.cd['e'], 2.0) self.nu[i,j] = self.nu[i,j]*np.sqrt(self.mass[i]*self.mass[j]) self.nu[i,j] = self.nu[i,j]/np.sqrt((self.mass[i] + self.mass[j])) self.nu[i,j] = ndens[i]*ndens[j]*self.nu[i,j] self.nu[i,j] = self.nu[i,j]/np.power(self.cd['kb']*T, 1.5) self.nu[j,i] = self.nu[i,j] for i in range(ndens.shape[0]): self.nu[i, :] = self.cd['kc']*self.cd['kc']*self.nu[i, :]/(self.mass[i]*ndens[i])
def get_kinetic_num(Te, T, Zbar, ndens, mass, cd, o=3): """Returns the matrix of momentum relaxation collsion rates formulated in the above reference for a system described by kinetics, i.e. each ion species has its own temperature. Parameters ---------- Te : float System electron temperature. T : (N,) np.ndarray System ion temperatures in units of energy/kb Zbar : (N,) np.ndarray The effective charge of each ion species in units of electron charge. ndens : (N,) np.ndarray Number density of each ion species in units of 1/length^{3}. cd : dict A dictionary holding all of the fundamental constants in the same units as the other input args (`ndens`, `T`, `masses`). Must have the following keys: na, kb, e, g, hbar, c, kc, me, mp. mass : (N,) np.ndarray Mass of each species. o : {3, 1, 2}, optional Order of approximation to use. 1->appx with max 2.5% relative error, 2->appx with max 1.1% relative error, and 3->'exact' (with fermi integral fits). Returns ------- nu : (N, N) np.ndarray The collision frequencies between each species. """ leff = get_leff(Te, T, Zbar, ndens, cd, o=o) nu = np.zeros((ndens.shape[0], ndens.shape[0]), dtype=ndens.dtype) #set each upper triangular nu to g for i in range(ndens.shape[0]): for j in range(i, ndens.shape[0]): nu[i, j] = Zbar[i] * Zbar[j] * cd['e'] * cd['e'] * (mass[i] + mass[j]) nu[i, j] = nu[i, j] / leff / (cd['kb'] * (mass[i] * T[j] + mass[j] * T[i])) nu = 128.0 * np.pi * np.pi * get_calk(1, 1, nu) / 3.0 / np.power( 2 * np.pi, 1.5) #set each lower triangular element to its upper triangular equivalent for i in range(ndens.shape[0]): for j in range(i, ndens.shape[0]): nu[i, j] = nu[i, j] * np.power( Zbar[i] * Zbar[j] * cd['e'] * cd['e'], 2.0) nu[i, j] = nu[i, j] * np.sqrt(mass[i] * mass[j]) * (mass[i] + mass[j]) nu[i, j] = ndens[i] * ndens[j] * nu[i, j] nu[i, j] = nu[i, j] / np.power( cd['kb'] * (mass[i] * T[j] + mass[j] * T[i]), 1.5) nu[j, i] = nu[i, j] for i in range(ndens.shape[0]): nu[i, :] = nu[i, :] / (mass[i] * ndens[i]) return nu