Skip to content
Extraits de code Groupes Projets
diffusion_laxwendrof.py 1,42 ko
Newer Older
  • Learn to ignore specific revisions
  • Michel Crucifix's avatar
    Michel Crucifix a validé
    import numpy as np
    import matplotlib.pyplot as plt
    import pltpref
    
    import matplotlib as mp
    mp.rcParams['figure.figsize'] =  9.2, 5.5
    mp.rcParams['figure.subplot.left']    = 0.05   
    mp.rcParams['figure.subplot.right']    = 0.95
    mp.rcParams['figure.subplot.wspace']    = 0.30
    
    #Lax-Wendroff
    ko=np.linspace(0.01,np.pi-0.001,100)
    
    lmb=[0.25,0.5,0.75,1.]
    fig,ax=plt.subplots(1,2,subplot_kw=dict(polar=True))
    for i in range(4):
        ampl_R=1-lmb[i]**2+lmb[i]**2*np.cos(ko)
        ampl_I=-lmb[i]*np.sin(ko)
        ampl=1-lmb[i]**2+lmb[i]**2*np.cos(ko)+(1j)*(-lmb[i]*np.sin(ko))
        ratio=np.arctan(ampl_I/ampl_R)/(-lmb[i]*ko)
        ratio=np.arctan2(np.imag(ampl),np.real(ampl))/(-lmb[i]*ko)
        ax[0].plot(ko,np.sqrt(ampl_R**2+ampl_I**2),label='lambda=%.2f'%(lmb[i]))
        ax[1].plot(ko,np.abs(ratio),label='lambda=%.2f'%(lmb[i]))
    
    fig.suptitle('Schéma Lax-Wendroff') 
    ax[0].set_rmax(2)
    ax[0].set_rgrids([0.0,0.5, 1, 1.5],labels=['0.0','0.5', '1', '1.5'],fontsize=20)
    ax[0].set_frame_on(False)
    ax[0].set_thetamax(180)
    ax[0].set_thetagrids(angles=[0,180],labels=['rh=0','rh=$\pi$'],fontsize=15)
    ax[0].legend()
    ax[0].set_title(r'$|\kappa |$')
    ax[1].set_rmax(2)
    ax[1].set_rgrids([0.0,0.5, 1, 1.5],labels=['0.0','0.5', '1', '1.5'],fontsize=20)
    ax[1].set_frame_on(False)
    ax[1].set_thetamax(180)
    ax[1].set_thetagrids(angles=[0,180],labels=['rh=0','rh=$\pi$'],fontsize=15)
    ax[1].legend()
    ax[1].set_title(r'$\frac{\theta_{d}}{\theta_{a}}$')
    
    fig.savefig("diffusion_laxwendrof.pdf")