Vlasiator ebf0dd394 on dev (v5.4.0 + 1054 commits)
Loading...
Searching...
No Matches
faceestimates_amr.py
Go to the documentation of this file.
1from sympy import *
2
3
4
5def solve_face_value(integration_limits, has_mdv, has_pdv):
6 il=integration_limits
7 ans_a=solve([\
8 integrate(rho_hat,(v,il[0][0],il[0][1])) - m3f * (il[0][1] - il[0][0]),\
9 integrate(rho_hat,(v,il[1][0],il[1][1])) - m2f * (il[1][1] - il[1][0]),\
10 integrate(rho_hat,(v,il[2][0],il[2][1])) - m1f * (il[2][1] - il[2][0]),\
11 integrate(rho_hat,(v,il[3][0],il[3][1])) - cf * (il[3][1] - il[3][0]),\
12 integrate(rho_hat,(v,il[4][0],il[4][1])) - p1f * (il[4][1] - il[4][0]),\
13 integrate(rho_hat,(v,il[5][0],il[5][1])) - p2f * (il[5][1] - il[5][0])],\
14 [a,b,c,d,e,f])
15 rho_hat_v=rho_hat.subs([(a,ans_a[a]),(b,ans_a[b]),(c,ans_a[c]),(d,ans_a[d]),(e,ans_a[e]),(f,ans_a[f])])
16 rho_hat_ans=rho_hat_v.subs([(v,0)])
17 d_rho_hat_ans=simplify(diff(rho_hat_v,v).subs(v,0))
18 #print " h6 value "
19 #print simplify(rho_hat_ans)
20 #print " h5 derivative "
21 #print simplify(d_rho_hat_ans)
22 if has_mdv and has_pdv:
23 for mdv_val in [Rational(1,2), 1, 2]:
24 for pdv_val in [Rational(1,2), 1, 2]:
25 print( "mdv = ", mdv_val, " pdv = ", pdv_val)
26 print( "h6 = ")
27 print( simplify(rho_hat_ans.subs([(mdv,mdv_val),(pdv,pdv_val)] )))
28 print( "dh5 = ")
29 print( simplify(d_rho_hat_ans.subs([(mdv,mdv_val),(pdv,pdv_val)] )))
30 elif has_mdv:
31 for mdv_val in [Rational(1,2), 1, 2]:
32 print( " mdv = ", mdv_val)
33 print( " h6 = ")
34 print( simplify(rho_hat_ans.subs(mdv,mdv_val)))
35 print( " dh5 = ")
36 print( simplify(d_rho_hat_ans.subs(mdv,mdv_val)))
37
38 elif has_pdv:
39 for pdv_val in [Rational(1,2), 1, 2]:
40 print( " pdv = ", pdv_val)
41 print( " h6 = ")
42 print( simplify(rho_hat_ans.subs(pdv,pdv_val)))
43 print( " dh5 = ")
44 print( simplify(d_rho_hat_ans.subs(pdv,pdv_val)))
45
46# h6 is the density(-density) function, which when integrated gives us our density values in the cells
47# x is the coordinate, which is normalized such that it is x=(v-v_{i-1/2})/dv, where v_{i-1/2} is the velocity at the left face of the center cell i
48
49print( "h6 /dh5 estimates for blockwise AMR grid. cells in current block have dv=1, neighbors are at 1/2 or 2")
50
51a,b,c,d,e,f=symbols('a b c d e f')
52v,mdv,pdv=symbols('v mdv pdv')
53m3f,m2f, m1f,cf,p1f,p2f=symbols('m3f m2f m1f cf p1f p2f')
54rho_hat=a+b*v+c*v**2 + d*v**3 + e*v**4 + f*v**5
55
56print( "-----------------------------------------------------")
57print( "First face")
58solve_face_value([(-3*mdv,-2*mdv),(-2*mdv,-mdv),(-mdv,0),(0,1),(1,2),(2,3)],True,False)
59print( "-----------------------------------------------------")
60print( "Second face ")
61solve_face_value([(-2*mdv -1 ,-mdv -1),(- mdv-1,-1),(-1,0),(0,1),(1,2),(2,3)],True,False)
62print( "-----------------------------------------------------")
63print( "Third face ")
64solve_face_value([(-mdv -2 ,-2),(-2,-1),(-1,0),(0,1),(1,2),(2,2 + pdv)],True,True)
65print( "-----------------------------------------------------")
66print( "Fourth face ")
67solve_face_value([(-3 ,-2),(-2,-1),(-1,0),(0,1),(1, 1 + pdv ),(1 + pdv ,1 + 2 *pdv)],False,True)
solve_face_value(integration_limits, has_mdv, has_pdv)