コード例 #1
0
ファイル: rhs_terms.py プロジェクト: pencil-code/pencil-code
 def heatcond(src, dst, key, par, gd, l1, l2, m1, m2, n1, n2, nghost):
     if key == "hcond":
         n1shift,n2shift,m1shift,m2shift,l1shift,l2shift=der_limits(
                                                  n1,n2,m1,m2,l1,l2,nghost)
         if "tt" in dst["data"].keys():
             tt = dst["data/tt"][n1shift,n2shift,m1shift,m2shift,l1shift,l2shift]
         else:
             calc_derived_data(src["data"], dst["data"], "tt", par,
                                 gd, l1, l2, m1, m2, n1, n2, nghost)
             tt = dst["data/tt"][n1shift,n2shift,m1shift,m2shift,l1shift,l2shift]
             lntt = np.log(dst["data/tt"][n1shift,n2shift,m1shift,m2shift,l1shift,l2shift])
             gradlnT = grad(lntt,grid.dx,grid.dy,grid.dz,x=grid.x[l1shift:l2shift],y=grid.y[m1shift:m2shift],coordinate_system=param.coord_system)
             del2T = del2(tt,grid.dx,grid.dy,grid.dz,x=grid.x[l1shift:l2shift],y=grid.y[m1shift:m2shift],coordinate_system=param.coord_system)
         if "rho" in src["data"].keys():
             lnrho = np.log(src["rho"][n1shift,n2shift,m1shift,m2shift,l1shift,l2shift])
             gradlnrho = grad(lnrho,grid.dx,grid.dy,grid.dz,x=grid.x[l1shift:l2shift],y=grid.y[m1shift:m2shift],coordinate_system=param.coord_system)
             lrho = True
         elif "lnrho" in src["data"].keys():
             lnrho = src["lnrho"][n1shift,n2shift,m1shift,m2shift,l1shift,l2shift]
             gradlnrho = grad(lnrho,grid.dx,grid.dy,grid.dz,x=grid.x[l1shift:l2shift],y=grid.y[m1shift:m2shift],coordinate_system=param.coord_system)
             lrho = True
         else:
             lrho = False
         var = par.cp*par.chi*del2T/tt
         if lrho:
             var += par.cp*par.chi*dot(gradlnrho,gradlnT)
         n1r,m1r,l1r = under_limits(n1,m1,l1,n1shift,m1shift,l1shift,nghost)
         return var[n1r:n2-n1+n1r,m1r:m2-m1+m1r,l1r:l2-l1+l1r]
コード例 #2
0
ファイル: rhs_terms.py プロジェクト: pencil-code/pencil-code
 def advec_heat(src, dst, key, par, gd, l1, l2, m1, m2, n1, n2, nghost):
     if key == "hadvec":
         n1shift,n2shift,m1shift,m2shift,l1shift,l2shift=der_limits(
                                                  n1,n2,m1,m2,l1,l2,nghost)
         uu = np.array([
                           src["data/ux"][n1shift:n2shift,m1shift:m2shift,l1shift:l2shift],
                           src["data/uy"][n1shift:n2shift,m1shift:m2shift,l1shift:l2shift],
                           src["data/uz"][n1shift:n2shift,m1shift:m2shift,l1shift:l2shift]
                           ])
         if "ss" in dst["data"].keys():
             ss = src["ss"][n1shift:n2shift,m1shift:m2shift,l1shift:l2shift]
         sgrad = grad(ss,grid.dx,grid.dy,grid.dz,x=grid.x[l1shift:l2shift],y=grid.y[m1shift:m2shift],coordinate_system=param.coord_system)
         if "tt" in dst["data"].keys():
             tt = dst["tt"][n1shift:n2shift,m1shift:m2shift,l1shift:l2shift]
         else:
             calc_derived_data(src["data"], dst["data"], "tt", par,
                                 gd, l1, l2, m1, m2, n1, n2, nghost)
             tt = dst["data/tt"][n1shift:n2shift,m1shift:m2shift,l1shift:l2shift]
         if "rho" in dst["data"].keys():
             rho = src["data/rho"][n1shift:n2shift,m1shift:m2shift,l1shift:l2shift]
         elif "lnrho" in dst["data"].keys():
             rho = np.exp(src["data/lnrho"][n1shift:n2shift,m1shift:m2shift,l1shift:l2shift])
         else:
             rho=1
         advec = -dot(uu,sgrad)/(rho*tt)
         n1r,m1r,l1r = under_limits(n1,m1,l1,n1shift,m1shift,l1shift,nghost)
         return advec[n1r:n2-n1+n1r,m1r:m2-m1+m1r,l1r:l2-l1+l1r]
コード例 #3
0
ファイル: rhs_terms.py プロジェクト: pencil-code/pencil-code
 def visc_heat(src, dst, key, par, gd, l1, l2, m1, m2, n1, n2, nghost):
     if key == "hvisc":
         th1 = 1./3
         n1shift,n2shift,m1shift,m2shift,l1shift,l2shift=der_limits(
                                                  n1,n2,m1,m2,l1,l2,nghost)
         uu = np.array([
                       src["data/ux"][n1shift:n2shift,m1shift:m2shift,l1shift:l2shift],
                       src["data/uy"][n1shift:n2shift,m1shift:m2shift,l1shift:l2shift],
                       src["data/uz"][n1shift:n2shift,m1shift:m2shift,l1shift:l2shift]
                       ])
         tmp0 = grad(uu[0],grid.dx,grid.dy,grid.dz,x=grid.x[l1shift:l2shift],y=grid.y[m1shift:m2shift],coordinate_system=param.coord_system)
         tmp1 = grad(uu[1],grid.dx,grid.dy,grid.dz,x=grid.x[l1shift:l2shift],y=grid.y[m1shift:m2shift],coordinate_system=param.coord_system)
         tmp2 = grad(uu[2],grid.dx,grid.dy,grid.dz,x=grid.x[l1shift:l2shift],y=grid.y[m1shift:m2shift],coordinate_system=param.coord_system)
         var  = tmp0[1]**2
         var += tmp0[2]**2
         var += tmp1[2]**2
         if "tt" in dst["data"].keys():
             tt = dst["tt"][n1shift:n2shift,m1shift:m2shift,l1shift:l2shift]
         else:
             calc_derived_data(src["data"], dst["data"], "tt", par,
                                 gd, l1, l2, m1, m2, n1, n2, nghost)
             tt = dst["data/tt"][n1shift:n2shift,m1shift:m2shift,l1shift:l2shift]
         var *= 2*par.nu*var/tt
         n1r,m1r,l1r = under_limits(n1,m1,l1,n1shift,m1shift,l1shift,nghost)
         return var[n1r:n2-n1+n1r,m1r:m2-m1+m1r,l1r:l2-l1+l1r]
コード例 #4
0
ファイル: rhs_terms.py プロジェクト: pencil-code/pencil-code
 def bcurletadel2a(src, dst, key, par, gd, l1, l2, m1, m2, n1, n2, nghost):
     if key == "bcurletadel2a":
         if "curletadel2a" in dst["calc"].keys():
             tmp = dst["calc/curletadel2a"][:,n1:n2, m1:m2, l1:l2]
         else:
             tmp = curletadel2a(src, dst, "curletadel2a", par, gd, n1, n2,
                             m1, m2, l1, l2, nghost)
         if "bb" in dst["data"].keys():
             bb = dst["data/bb"][:,n1:n2,m1:m2,l1:l2]
         else:
             calc_derived_data(src["data"], dst["data"], "bb", par,
                                 gd, l1, l2, m1, m2, n1, n2, nghost)
             bb = dst["data/bb"][:,n1:n2,m1:m2,l1:l2]
         var = dot(bb,tmp)
         return var
コード例 #5
0
ファイル: rhs_terms.py プロジェクト: pencil-code/pencil-code
 def induction(src, dst, key, par, gd, l1, l2, m1, m2, n1, n2, nghost):
     if key=="uxb":
         if "bb" in dst["data"].keys():
             bb = dst["data/bb"][:,n1:n2,m1:m2,l1:l2]
         else:
             calc_derived_data(src["data"], dst["data"], "bb", par,
                                 gd, l1, l2, m1, m2, n1, n2, nghost)
             bb = dst["data/bb"][:,n1:n2,m1:m2,l1:l2]
         if "ux" in src["data"].keys():
             uu = np.array([
                   src["data/ux"][n1:n2,m1:m2,l1:l2],
                   src["data/uy"][n1:n2,m1:m2,l1:l2],
                   src["data/uz"][n1:n2,m1:m2,l1:l2]
                   ])
             var = cross(uu,bb)
         else:
             print("no velocity used setting uxb=0 in induction calculation")
             var = np.zeros_like(bb)
         return var
コード例 #6
0
ファイル: rhs_terms.py プロジェクト: pencil-code/pencil-code
 def gradp(src, dst, key, par, gd, l1, l2, m1, m2, n1, n2, nghost):
     if key == "gradp":
         n1shift,n2shift,m1shift,m2shift,l1shift,l2shift=der_limits(
                                                  n1,n2,m1,m2,l1,l2,nghost)
         if "pp" in dst["data"].keys():
             pp = dst["data/pp"][n1shift:n2shift,m1shift:m2shift,l1shift:l2shift]
         else:
             calc_derived_data(src["data"], dst["data"], "pp", par,
                                 gd, l1, l2, m1, m2, n1, n2, nghost)
             pp = dst["data/pp"][n1shift:n2shift,m1shift:m2shift,l1shift:l2shift]
         var = -grad(pp, gd.dx, gd.dy, gd.dz,x=gd.x[l1shift:l2shift],y=gd.y[m1shift:m2shift],coordinate_system=par.coord_system)
         if "rho" in src["data"].keys():
             rho = dst["data/rho"][n1shift:n2shift,m1shift:m2shift,l1shift:l2shift]
         elif "lnrho" in src["data"].keys():
             rho = np.exp(dst["data/lnrho"][n1shift:n2shift,m1shift:m2shift,l1shift:l2shift])
         else:
             rho = 1.
         var /= rho
         n1r,m1r,l1r = under_limits(n1,m1,l1,n1shift,m1shift,l1shift,nghost)
         return var[:,n1r:n2-n1+n1r,m1r:m2-m1+m1r,l1r:l2-l1+l1r]
コード例 #7
0
ファイル: rhs_terms.py プロジェクト: pencil-code/pencil-code
 def ohmic_heat(src, dst, key, par, gd, l1, l2, m1, m2, n1, n2, nghost):
     if key == "ohmic":
         if "jj" in dst["data"].keys():
             jj = dst["data/jj"][:,n1:n2,m1:m2,l1:l2]
         else:
             calc_derived_data(src["data"], dst["data"], "jj", par,
                                 gd, l1, l2, m1, m2, n1, n2, nghost)
             jj = dst["data/jj"][:,n1:n2,m1:m2,l1:l2]
         if "tt" in dst["data"].keys():
             tt = dst["tt"][n1:n2,m1:m2,l1:l2]
         else:
             calc_derived_data(src["data"], dst["data"], "tt", par,
                                 gd, l1, l2, m1, m2, n1, n2, nghost)
             tt = dst["data/tt"][n1:n2,m1:m2,l1:l2]
         if "rho" in dst["data"].keys():
             rho = src["data/rho"][n1:n2,m1:m2,l1:l2]
         elif "lnrho" in dst["data"].keys():
             rho = np.exp(src["data/lnrho"][n1:n2,m1:m2,l1:l2])
         else:
             rho=1
         var = par.eta*par.mu0*dot2(jj)/(rho*tt)
         return var
コード例 #8
0
ファイル: rhs_terms.py プロジェクト: pencil-code/pencil-code
 def lorentz_force(src, dst, key, par, gd, l1, l2, m1, m2, n1, n2, nghost):
     if key == "lorentz":
         if "bb" in dst["data"].keys():
             bb = dst["data/bb"][:,n1:n2,m1:m2,l1:l2]
         else:
             calc_derived_data(src["data"], dst["data"], "bb", par,
                                 gd, l1, l2, m1, m2, n1, n2, nghost)
             bb = dst["data/bb"][:,n1:n2,m1:m2,l1:l2]
         if "jj" in dst["data"].keys():
             jj = dst["data/jj"][:,n1:n2,m1:m2,l1:l2]
         else:
             calc_derived_data(src["data"], dst["data"], "jj", par,
                                 gd, l1, l2, m1, m2, n1, n2, nghost)
             jj = dst["data/jj"][:,n1:n2,m1:m2,l1:l2]
         if "rho" in src["data"].keys():
             rho = dst["data/rho"][n1:n2,m1:m2,l1:l2]
         elif "lnrho" in src["data"].keys():
             rho = np.exp(dst["data/lnrho"][n1:n2,m1:m2,l1:l2])
         else:
             rho = 1.
         var = cross(jj,bb)/rho
         return var