sandbox/Maknine/DispersionVisc.c

    Dispersion relation for the Rayleigh Taylor instability with viscosity

    #include "grid/multigrid1D.h"
    #include "stabilityRT.h"
    
    
    /*Initialization of the fields to be solved:*/
    scalar REPhi[];
    scalar IMPhi[];
    scalar REEta[];
    scalar IMEta[];
    
    REPhi[left]=dirichlet(0.);
    REPhi[right]=dirichlet(0.);
    
    IMPhi[left]=dirichlet(0.);
    IMPhi[right]=dirichlet(0.);
    
    REEta[left]=dirichlet(0.);
    REEta[right]=dirichlet(0.);
    
    IMEta[left]=dirichlet(0);
    IMEta[right]=dirichlet(0);
    
    double omtol = 0.01;
    
    int main() {
    
        L0 =20.;
        
        X0 = -L0/2.;    
    
        /* Physical parameters*/
        g = 1.;
        rho1 = 1.0; rho2 = 0.7; //Density Ratio (Light/Heavy)
        mu1 = 0.001; mu2 = mu1;
        sigma = 0.;
    
        TOLERANCE = 1e-6;//Tolerance of the Solver
    
        int LEVEL = 12;
    
        double k0=1.;    //Minimum Wave Numer
        double kmax=100; //Max Wave Numer
        double k;
    
        double lmu = pow(sq(mu1)/(sq(rho1)*g),1./3);
        init_grid (1 << LEVEL);
    
        //initial guess
        om= 1 + I;
    	
        for (double DeltaI=0.001 ;DeltaI<=1.; DeltaI *= 2) {
    	    
        for (k=k0 ;k<=kmax; k*=1.1) {
    
          /*Growthrate calculation */
          om = solve_stability_RT (REPhi, IMPhi, REEta, IMEta, DeltaI, k);
          
          fprintf(stdout, "%g %g %g %g  \n", k*lmu, DeltaI/lmu, creal(om)*sqrt(lmu), cimag(om)*sqrt(lmu));
          
    
        }
          
        fprintf(stdout, "\n");
        }
    
    }

    Results

    set xlabel 'k l_{/Symbol m}'
    set ylabel '{/Symbol w}_i (l_{/Symbol m}/g)^{1/2}'
    set cblabel '{/Symbol D}_I/l_{/Symbol m}'
    set log x
    set key left
    set yrange[0:0.15]
    set xrange[0.01:1]
    plot "out" u 1:4:2 not w lp palette pt 7, sqrt(0.3/1.7*x) t 'sharp inviscid' w l lc 2 dt 2, "../Theory" u 1:2 t 'sharp visc' w l lc 2 lw 2
    Dispersion relation (colors represent \Delta_I/l_\mu values) (script)