@@ -531,50 +531,81 @@ def plot_spectrum_over_time1e6R4():
531531
532532 # data = get_pySDC_data('1e6', res=48, dt=0.02, config_name='RBC3DG4')
533533 # data = get_pySDC_data('1e7', res=96, dt=0.009, config_name='RBC3DG4')
534- # data = get_pySDC_data('1e7', res=64, dt=0.005, config_name='RBC3DG4R4')
535- data = get_pySDC_data ('1e8' , res = 96 , dt = 0.005 , config_name = 'RBC3DG4R4' )
534+ data = get_pySDC_data ('1e7' , res = 64 , dt = 0.005 , config_name = 'RBC3DG4R4D42' )
535+ # data = get_pySDC_data('1e8', res=96, dt=0.005, config_name='RBC3DG4R4')
536+ # data = get_pySDC_data('1e8', res=256, dt=0.002, config_name='RBC3DG4R4RK')
536537
537538 s = data ['spectrum' ]
538539 t = data ['t' ]
539540 k = data ['k' ]
540541
541- # for i in range(len(s)):
542- # for i in [0, 3, 10, 20, 40, 80, -1]:
543- for i in [0 , 5 , 10 , 20 , 30 , 40 , - 1 ]:
542+ for i in range (len (s )):
543+ # for i in [0, 3, 10, 20, 40, 80, -1]:
544+ # for i in [0, 5, 10, 20, 30, 40, -1]:
544545 print (i , t [i ])
545546 _s = s [i ][0 , data ['res_in_boundary_layer' ]]
546547 _s = np .max (s [i ][0 ], axis = 0 )
547548 ax .loglog (k [_s > 1e-20 ], _s [_s > 1e-20 ], label = f't={ t [i ]:.1f} ' )
548549 ax .legend (frameon = False )
549550
550551
551- def compare_spectra1e8 ( ):
552+ def compare_spectra ( Ra = 1e8 ):
552553 fig , ax = plt .subplots ()
553554
554555 runs = []
555556 labels = []
556- runs .append (get_pySDC_data ('1e8' , res = 96 , dt = 0.005 , config_name = 'RBC3DG4R4' ))
557- labels .append (r'$N=384^2\times96$' )
558- runs .append (get_pySDC_data ('1e8' , res = 128 , dt = 0.005 , config_name = 'RBC3DG4R4' ))
559- labels .append (r'$N=512^2\times128$' )
560- runs .append (get_pySDC_data ('1e8' , res = 96 , dt = 0.006 , config_name = 'RBC3DG4' ))
561- labels .append (r'$N=192^2\times96$' )
557+ if Ra == 1e8 :
558+ runs .append (get_pySDC_data ('1e8' , res = 96 , dt = 0.005 , config_name = 'RBC3DG4R4' ))
559+ labels .append (r'$N=384^2\times96$' )
560+ runs .append (get_pySDC_data ('1e8' , res = 128 , dt = 0.005 , config_name = 'RBC3DG4R4' ))
561+ labels .append (r'$N=512^2\times128$' )
562+ runs .append (get_pySDC_data ('1e8' , res = 96 , dt = 0.006 , config_name = 'RBC3DG4' ))
563+ labels .append (r'$N=192^2\times96$' )
564+ runs .append (get_pySDC_data ('1e8' , res = 256 , dt = 0.002 , config_name = 'RBC3DG4R4RK' ))
565+ labels .append (r'$N=1024^2\times256$' )
566+ elif Ra == 1e7 :
567+ runs .append (get_pySDC_data ('1e7' , res = 64 , dt = 0.005 , config_name = 'RBC3DG4R4' ))
568+ labels .append (r'$N=264^2\times64$' )
569+ runs .append (get_pySDC_data ('1e7' , res = 64 , dt = 0.005 , config_name = 'RBC3DG4R4D2' ))
570+ labels .append (r'$N=264^2\times64$, no dealiasing' )
571+ runs .append (get_pySDC_data ('1e7' , res = 64 , dt = 0.005 , config_name = 'RBC3DG4R4D4' ))
572+ labels .append (r'$N=264^2\times64$, dealiasing 2' )
573+ runs .append (get_pySDC_data ('1e7' , res = 96 , dt = 0.009 , config_name = 'RBC3DG4' ))
574+ labels .append (r'$N=192^2\times96$' )
575+ runs .append (get_pySDC_data ('1e7' , res = 96 , dt = 0.005 , config_name = 'RBC3DG4R4' ))
576+ labels .append (r'$N=384^2\times96$' )
577+ runs .append (get_pySDC_data ('1e7' , res = 128 , dt = 0.005 , config_name = 'RBC3DG4R4' ))
578+ labels .append (r'$N=512^2\times128$' )
579+ elif Ra == 1e5 :
580+ runs .append (get_pySDC_data ('1e5' , res = 32 , dt = 0.06 , config_name = 'RBC3DG4' ))
581+ labels .append (r'$N=64^2\times32$' )
582+ runs .append (get_pySDC_data ('1e5' , res = 32 , dt = 0.06 , config_name = 'RBC3DG4R4' ))
583+ labels .append (r'$N=128^2\times32$' )
584+ else :
585+ raise NotImplementedError
562586
563587 for data , label in zip (runs , labels ):
564- s = data ['spectrum' ]
565- t = data ['t' ]
588+ s_all = data ['spectrum' ]
566589 k = data ['k' ]
567590
568- k = data ['k' ] + 1
569- spectrum = np .array (data ['spectrum' ])
570- u_spectrum = np .mean (spectrum , axis = 0 )[1 ]
571- idx = data ['res_in_boundary_layer' ]
572- _s = u_spectrum [idx ]
573- ax .loglog (k [_s > 1e-20 ], _s [_s > 1e-20 ], label = label )
591+ from pySDC .helpers .spectral_helper import ChebychevHelper
592+
593+ helper = ChebychevHelper (N = s_all [0 ].shape [1 ], x0 = 0 , x1 = 1 )
594+ weights = helper .get_integration_weights ()
595+ s = np .array ([weights @ helper .transform (me [0 ], axes = (0 ,)) for me in s_all ]).mean (axis = 0 )
596+
597+ ax .loglog (k [s > 1e-20 ], s [s > 1e-20 ], label = label )
598+
599+ # spectrum = np.array(data['spectrum'])
600+ # u_spectrum = np.mean(spectrum, axis=0)[1]
601+ # idx = data['res_in_boundary_layer']
602+ # _s = u_spectrum[idx]
603+ # ax.loglog(k[_s > 1e-20], _s[_s > 1e-20], label=label)
574604
575605 ax .legend (frameon = False )
576606 ax .set_xlabel ('$k$' )
577607 ax .set_ylabel (r'$\|\hat{u}_x\|$' )
608+ ax .set_title (f'Ra = { Ra :.1e} ' )
578609
579610
580611if __name__ == '__main__' :
@@ -586,6 +617,6 @@ def compare_spectra1e8():
586617 # compare_Nusselt_over_time1e8()
587618 # plot_thibaut_stuff()
588619 # plot_spectrum_over_time1e6R4()
589- compare_spectra1e8 ( )
620+ compare_spectra ( Ra = 1e5 )
590621
591622 plt .show ()
0 commit comments