File tree Expand file tree Collapse file tree 1 file changed +11
-4
lines changed
Expand file tree Collapse file tree 1 file changed +11
-4
lines changed Original file line number Diff line number Diff line change @@ -53,20 +53,27 @@ def set_up_simulation():
5353 sim .state ["t" ] = 0.0
5454 X , Y = sim .mesh
5555 R = jnp .sqrt ((X - 0.5 ) ** 2 + (Y - 0.5 ) ** 2 )
56+
5657 def v_phi (r ):
5758 return jnp .where (
5859 r < 0.2 ,
5960 5.0 * r ,
6061 jnp .where (r < 0.4 , 2.0 - 5.0 * r , 0.0 ),
6162 )
63+
6264 def P0 (r ):
6365 return jnp .where (
6466 r < 0.2 ,
6567 5.0 + 12.5 * r ** 2 ,
66- jnp .where (r < 0.4 , 9.0 + 12.5 * r ** 2 - 20.0 * r + 4.0 * jnp .log (r / 0.2 ), 3.0 + 4.0 * jnp .log (2.0 )),
68+ jnp .where (
69+ r < 0.4 ,
70+ 9.0 + 12.5 * r ** 2 - 20.0 * r + 4.0 * jnp .log (r / 0.2 ),
71+ 3.0 + 4.0 * jnp .log (2.0 ),
72+ ),
6773 )
68- vx = - v_phi (R ) * (Y - 0.5 ) / (R + (R == 0 ))
69- vy = v_phi (R ) * (X - 0.5 ) / (R + (R == 0 ))
74+
75+ vx = - v_phi (R ) * (Y - 0.5 ) / (R + (R == 0 ))
76+ vy = v_phi (R ) * (X - 0.5 ) / (R + (R == 0 ))
7077 sim .state ["rho" ] = jnp .ones (X .shape )
7178 sim .state ["vx" ] = vx
7279 sim .state ["vy" ] = vy
@@ -78,7 +85,7 @@ def P0(r):
7885def make_plot (sim ):
7986 # Plot the solution
8087 plt .figure (figsize = (6 , 4 ), dpi = 80 )
81- v_phi = jnp .sqrt (sim .state ["vx" ]** 2 + sim .state ["vy" ]** 2 )
88+ v_phi = jnp .sqrt (sim .state ["vx" ] ** 2 + sim .state ["vy" ] ** 2 )
8289 plt .imshow (v_phi .T , cmap = "jet" , vmin = 0.0 , vmax = 1.0 )
8390 plt .gca ().invert_yaxis ()
8491 plt .colorbar (label = "v_phi" )
You can’t perform that action at this time.
0 commit comments