In [1]:
%pylab nbagg
from ppmpy import ppm

data_dir='/data/ppm_rpod2/YProfiles/'


Populating the interactive namespace from numpy and matplotlib

In [2]:
# Tese are the projects for which data is available
!ls /data/ppm_rpod2/YProfiles/


AGBTP_M2.0Z1.e-5  O-shell-M25	  agb-entrainment-convergence
C-ingestion	  O-shell-mixing  sakurai
M4ZAMS		  RAWD		  sakurai-num-exp-robustness-onset-GOSH

In [3]:
# select project 
project='O-shell-M25'

In [4]:
ppm.set_YProf_path(data_dir+project)

In [5]:
# show the available cases for this project (case=run):
ppm.cases


Out[5]:
['D10',
 'D11',
 'D14',
 'D23',
 'D17',
 'D4',
 'D24b',
 'D1_toomuchoutput',
 'D5',
 'D3',
 'D9',
 'D26',
 'D22',
 'D19',
 'D15',
 'D16',
 'D28',
 'D27',
 'D8',
 'D1',
 'D18',
 'D6',
 'D12',
 'D25',
 'D20',
 'D24a',
 'D21',
 'D2']

In [6]:
D2=ppm.yprofile('D2')

In [7]:
D2.vprofs(100)



In [8]:
# initialize some cases
d1=ppm.yprofile('D1')
d2=ppm.yprofile('D2')

In [9]:
d2.dcols


Out[9]:
['j',
 'Y',
 'FVconv',
 'UYconv',
 'FV H+He',
 'UY H+He',
 'Rho',
 'Rho1',
 'A',
 'RHOconv',
 'RHO1conv',
 'Rho H+He',
 'Rho1 H+He',
 'P',
 'P1',
 'EkY',
 'EkXZ',
 'Ek',
 'EkUy',
 'EiUy',
 'HUy',
 'EkUy conv',
 'EiUy conv',
 'HUy conv',
 'EkUy H+He',
 'EiUy H+He',
 'HUy H+He',
 'EkY conv',
 'EkXZ conv',
 'Ek conv',
 'EkY H+He',
 'EkXZ H+He',
 'Ek H+He']

In [10]:
# plot a profile
ifig=109;close(ifig);figure(ifig)
#ything='FV H+He'
ything='A'
cycs=[0,100]
d1.prof_time(cycs,yaxis_thing=ything,radtop=8.0848,ifig=ifig,ls_offset=10,label_case='D1')
d2.prof_time(cycs,yaxis_thing=ything,radtop=8.0848,ifig=ifig,ls_offset=5,label_case='D2')

xlim(3.5,9.2)
#ylim(-8,0)    # FV H+He
ylim(0.10209, 0.10262) # log A


Out[10]:
(0.10209, 0.10262)

In [11]:
# plot a profile
ifig=110;close(ifig);figure(ifig)
ything='FV H+He'
#ything='A'
cycs=[0,100]
d1.prof_time(cycs,yaxis_thing=ything,radtop=8.0848,ifig=ifig,ls_offset=10,\
             label_case='D1, 768',logy=True)
d2.prof_time(cycs,yaxis_thing=ything,radtop=8.0848,ifig=ifig,ls_offset=5,\
             label_case='D2, 1536',logy=True)

xlim(3.5,9.2)
ylim(-4,0)    # FV H+He
#ylim(0.10209, 0.10262) # log A


/home/user/PyPPM/ppmpy/ppm.py:1728: RuntimeWarning: divide by zero encountered in log10
  pl.plot(Y,np.log10(y),utils.linestyle(i+ls_offset)[0],
Out[11]:
(-4, 0)

In [31]:
# plot a profile
ifig=113;close(ifig);figure(ifig)
#ything='FV H+He'
ything='EkY conv'
cycs=[0,100]
d1.prof_time(cycs,yaxis_thing=ything,radtop=8.0848,ifig=ifig,ls_offset=10,\
             label_case='D1, 768',logy=True)
d2.prof_time(cycs,yaxis_thing=ything,radtop=8.0848,ifig=ifig,ls_offset=5,\
             label_case='D2, 1536',logy=True)

xlim(3.5,9.2)
#ylim(-4,0)    # FV H+He
#ylim(0.10209, 0.10262) # log A


/home/user/PyPPM/ppmpy/ppm.py:1728: RuntimeWarning: divide by zero encountered in log10
  pl.plot(Y,np.log10(y),utils.linestyle(i+ls_offset)[0],
Out[31]:
(3.5, 9.2)

In [13]:
# Plot maximum kinetic energy
d2.tEkmax(ifig=77,label='VLTP_0.543',id=0)


/usr/local/lib/python3.5/dist-packages/matplotlib/__init__.py:913: UserWarning: text.fontsize is deprecated and replaced with font.size; please use the latter.
  warnings.warn(self.msg_depr % (key, alt_key))

In [14]:
#Plot maximum velocity
d2.tvmax(ifig=78,label='VLTP_0.543',id=0)



In [30]:
# Create a Richardson plot with the default settings
d2.Richardson_plot( fname1 = 0, fname2 = 2, R_low = None, R_top = None, \
                        do_plots = False, logRi_levels = [-1., -0.6, 0., 1., 2., 3.], \
                        ylim_max = 2.02, compressible_fluid = True, plot_type = 0, \
                        ifig = 102)


R_top set to 8.160.
R_low centred on the cell nearest to R_top - 1: R_low = 7.165.

In [16]:
# Calculate and plot an exponentially decaying diffusion coefficient
# given an r0, D0 and f.

# The description in the ppm.py file is incorrect

P = d2.Dov(r0=4,D0=12,f=0.002,fname=1)


400039000.0 161653013.152 313
/home/user/PyPPM/ppmpy/ppm.py:2794: RuntimeWarning: divide by zero encountered in true_divide
  Hp = - P[1:] * np.diff(r) / np.diff(P)

In [17]:
#Solve inverted diffusion equation to see what diffusion coefficient
#profile would have been appropriate to mimic the mixing of species
#seen in the Yprofile dumps

#The two inputs 'fname1' and 'fname2' indicate cycles from which to 
#take initial and final abundance profiles for the diffusion step 
#we want to mimic.

x, D = d2.Dinv(1,640)


/home/user/PyPPM/ppmpy/ppm.py:3173: RuntimeWarning: divide by zero encountered in log10
  pl.plot(x/1.e8,np.log10(-D),'k--',
/home/user/PyPPM/ppmpy/ppm.py:3173: RuntimeWarning: invalid value encountered in log10
  pl.plot(x/1.e8,np.log10(-D),'k--',

In [19]:
#Solve diffusion equation sequentially by iterating over the spatial
#domain inwards from the upper boundary. 

d2.Dsolvedown(1,640)


/home/user/PyPPM/ppmpy/ppm.py:3766: RuntimeWarning: divide by zero encountered in log10
  yplot = np.log10(y0long) if log_X else y0long
/home/user/PyPPM/ppmpy/ppm.py:3775: RuntimeWarning: divide by zero encountered in log10
  yplot = np.log10(y1long) if log_X else y1long
/home/user/PyPPM/ppmpy/ppm.py:3793: RuntimeWarning: divide by zero encountered in log10
  pl.plot(x/1.e8,np.log10(D),'k-',\
/home/user/PyPPM/ppmpy/ppm.py:3793: RuntimeWarning: invalid value encountered in log10
  pl.plot(x/1.e8,np.log10(D),'k-',\
/home/user/PyPPM/ppmpy/ppm.py:3797: RuntimeWarning: divide by zero encountered in log10
  pl.plot(x/1.e8,np.log10(-D),'k--',\
/home/user/PyPPM/ppmpy/ppm.py:3797: RuntimeWarning: invalid value encountered in log10
  pl.plot(x/1.e8,np.log10(-D),'k--',\
Out[19]:
(array([ 3.92383,  3.93659,  3.94935,  3.96211,  3.97487,  3.98763,
         4.00039,  4.01315,  4.02591,  4.03867,  4.05143,  4.06419,
         4.07695,  4.08971,  4.10247,  4.11523,  4.12799,  4.14076,
         4.15352,  4.16628,  4.17904,  4.1918 ,  4.20456,  4.21732,
         4.23008,  4.24284,  4.2556 ,  4.26836,  4.28112,  4.29388,
         4.30664,  4.3194 ,  4.33216,  4.34492,  4.35768,  4.37044,
         4.3832 ,  4.39596,  4.40872,  4.42148,  4.43424,  4.44701,
         4.45977,  4.47253,  4.48529,  4.49805,  4.51081,  4.52357,
         4.53633,  4.54909,  4.56185,  4.57461,  4.58737,  4.60013,
         4.61289,  4.62565,  4.63841,  4.65117,  4.66393,  4.67669,
         4.68945,  4.70221,  4.71497,  4.72773,  4.74049,  4.75326,
         4.76602,  4.77878,  4.79154,  4.8043 ,  4.81706,  4.82982,
         4.84258,  4.85534,  4.8681 ,  4.88086,  4.89362,  4.90638,
         4.91914,  4.9319 ,  4.94466,  4.95742,  4.97018,  4.98294,
         4.9957 ,  5.00846,  5.02122,  5.03398,  5.04674,  5.05951,
         5.07227,  5.08503,  5.09779,  5.11055,  5.12331,  5.13607,
         5.14883,  5.16159,  5.17435,  5.18711,  5.19987,  5.21263,
         5.22539,  5.23815,  5.25091,  5.26367,  5.27643,  5.28919,
         5.30195,  5.31471,  5.32747,  5.34023,  5.35299,  5.36576,
         5.37852,  5.39128,  5.40404,  5.4168 ,  5.42956,  5.44232,
         5.45508,  5.46784,  5.4806 ,  5.49336,  5.50612,  5.51888,
         5.53164,  5.5444 ,  5.55716,  5.56992,  5.58268,  5.59544,
         5.6082 ,  5.62096,  5.63372,  5.64648,  5.65924,  5.67201,
         5.68477,  5.69753,  5.71029,  5.72305,  5.73581,  5.74857,
         5.76133,  5.77409,  5.78685,  5.79961,  5.81237,  5.82513,
         5.83789,  5.85065,  5.86341,  5.87617,  5.88893,  5.90169,
         5.91445,  5.92721,  5.93997,  5.95273,  5.96549,  5.97826,
         5.99102,  6.00378,  6.01654,  6.0293 ,  6.04206,  6.05482,
         6.06758,  6.08034,  6.0931 ,  6.10586,  6.11862,  6.13138,
         6.14414,  6.1569 ,  6.16966,  6.18242,  6.19518,  6.20794,
         6.2207 ,  6.23346,  6.24622,  6.25898,  6.27174,  6.28451,
         6.29727,  6.31003,  6.32279,  6.33555,  6.34831,  6.36107,
         6.37383,  6.38659,  6.39935,  6.41211,  6.42487,  6.43763,
         6.45039,  6.46315,  6.47591,  6.48867,  6.50143,  6.51419,
         6.52695,  6.53971,  6.55247,  6.56523,  6.57799,  6.59076,
         6.60352,  6.61628,  6.62904,  6.6418 ,  6.65456,  6.66732,
         6.68008,  6.69284,  6.7056 ,  6.71836,  6.73112,  6.74388,
         6.75664,  6.7694 ,  6.78216,  6.79492,  6.80768,  6.82044,
         6.8332 ,  6.84596,  6.85872,  6.87148,  6.88424,  6.89701,
         6.90977,  6.92253,  6.93529,  6.94805,  6.96081,  6.97357,
         6.98633,  6.99909,  7.01185,  7.02461,  7.03737,  7.05013,
         7.06289,  7.07565,  7.08841,  7.10117,  7.11393,  7.12669,
         7.13945,  7.15221,  7.16497,  7.17773,  7.19049,  7.20326,
         7.21602,  7.22878,  7.24154,  7.2543 ,  7.26706,  7.27982,
         7.29258,  7.30534,  7.3181 ,  7.33086,  7.34362,  7.35638,
         7.36914,  7.3819 ,  7.39466,  7.40742,  7.42018,  7.43294,
         7.4457 ,  7.45846,  7.47122,  7.48398,  7.49674,  7.50951,
         7.52227,  7.53503,  7.54779,  7.56055,  7.57331,  7.58607,
         7.59883,  7.61159,  7.62435,  7.63711,  7.64987,  7.66263,
         7.67539,  7.68815,  7.70091,  7.71367,  7.72643,  7.73919,
         7.75195,  7.76471,  7.77747,  7.79023,  7.80299,  7.81576,
         7.82852,  7.84128,  7.85404,  7.8668 ,  7.87956,  7.89232,
         7.90508,  7.91784,  7.9306 ,  7.94336,  7.95612,  7.96888,
         7.98164,  7.9944 ,  8.00716,  8.01992,  8.03268,  8.04544,
         8.0582 ,  8.07096,  8.08372,  8.09648,  8.10924,  8.12201,
         8.13477,  8.14753,  8.16029,  8.17305,  8.18581,  8.19857,
         8.21133,  8.22409]),
 array([  0.00000000e+00,   0.00000000e+00,   1.78856896e+17,
          2.44190658e+16,   8.58670146e+15,   1.85731291e+15,
          4.00182285e+14,   9.99707262e+13,   2.26813889e+13,
          5.59345288e+12,   1.95708713e+12,   1.16934779e+12,
          1.09752475e+12,   1.31038324e+12,   1.74209788e+12,
          2.33643525e+12,   3.06062223e+12,   3.87386400e+12,
          4.78637084e+12,   5.88838822e+12,   7.08074840e+12,
          8.45495440e+12,   9.77004075e+12,   1.10849273e+13,
          1.27734442e+13,   1.47859537e+13,   1.63635242e+13,
          1.76384135e+13,   1.95810205e+13,   2.22255219e+13,
          2.51467624e+13,   2.78605111e+13,   3.20557511e+13,
          3.28836864e+13,   3.34306439e+13,   3.66798450e+13,
          3.86231261e+13,   4.07922891e+13,   4.37404968e+13,
          4.69414863e+13,   5.13322022e+13,   5.22441673e+13,
          5.39256122e+13,   5.99282512e+13,   6.36371417e+13,
          7.07053044e+13,   8.04958017e+13,   9.32269849e+13,
          1.11402947e+14,   1.19053438e+14,   1.29634233e+14,
          1.33486646e+14,   1.45303178e+14,   1.56175936e+14,
          1.58765457e+14,   1.94432213e+14,   2.66179636e+14,
          2.89820635e+14,   2.78338553e+14,   2.47396899e+14,
          2.15891029e+14,   3.25648952e+14,   4.33969579e+14,
          2.54839298e+14,   2.68829750e+14,   3.68371510e+14,
          3.13326718e+14,   2.95431571e+14,   3.77462263e+14,
          3.25444029e+14,   3.28321106e+14,   2.86860947e+14,
          2.98834759e+14,   4.71973145e+14,   5.03083882e+14,
          3.29937039e+14,   2.64950889e+14,   3.81416162e+14,
          1.69942248e+15,  -2.46734131e+16,   8.22880406e+15,
          1.06663037e+16,   3.76063513e+15,   1.18903602e+15,
          6.65764059e+14,   7.52379487e+14,   5.42890005e+14,
          3.82565783e+14,   3.84961999e+14,   4.91626296e+14,
          5.50148424e+14,   9.03141285e+14,   5.60070591e+14,
          2.91656976e+14,   2.80740726e+14,   3.84913237e+14,
          7.79547238e+14,   1.89303127e+16,  -1.77309378e+15,
         -1.48288631e+15,  -4.52244311e+15,  -6.44442331e+15,
          1.28563728e+16,   9.32425489e+14,   4.95679712e+14,
          3.92686820e+14,   4.85158863e+14,   6.35035185e+14,
          9.78318047e+14,   2.11049193e+15,   1.33104768e+15,
          1.95850164e+15,   1.18382418e+15,   1.16195383e+15,
          2.93160104e+15,   8.94116442e+14,   6.84015321e+14,
          7.30508936e+14,   6.87026680e+14,   6.05488913e+14,
          7.08555802e+14,   9.07132802e+14,   4.36717442e+16,
         -2.02992219e+15,   2.29759123e+15,   9.62850677e+14,
          1.16318420e+15,   8.14830221e+14,   7.42376153e+14,
          9.55175095e+14,   3.02280541e+15,  -2.42985717e+15,
          1.33717834e+15,   5.18362459e+14,   6.24868921e+14,
          1.09468135e+15,   1.00473996e+15,   7.33371231e+14,
          5.88087307e+14,   5.61830098e+14,   1.21650243e+15,
          8.64437441e+15,   2.27118968e+15,   1.57913162e+15,
          2.83634320e+15,   1.43521574e+15,   1.96222337e+15,
         -6.90815455e+15,  -1.97292499e+15,  -1.37019640e+15,
         -2.80355260e+15,   2.24442502e+15,   2.57495694e+15,
         -2.99465954e+15,  -4.89978588e+15,   1.15321845e+15,
          8.35498974e+14,   1.17362856e+15,   2.35739984e+15,
          1.30908322e+15,   8.59562672e+14,   1.73901416e+15,
          1.07914090e+15,   7.05483945e+14,   2.26994710e+15,
         -1.92823571e+15,  -5.54732998e+15,   3.17024225e+15,
          3.28574073e+15,   3.49549319e+15,   1.30332759e+15,
          1.84611687e+15,   3.38891130e+15,   2.30901488e+15,
         -3.31964871e+16,  -1.53191967e+15,   1.14792977e+15,
          3.93862471e+14,   4.99547985e+14,   4.82366194e+14,
          3.53315074e+14,   3.19438303e+14,   4.02785555e+14,
          6.43052219e+14,   8.94800174e+14,   1.34656573e+15,
          1.00099321e+15,   7.91622044e+14,   6.30435012e+14,
          4.95994778e+14,   5.38678907e+14,   6.25223527e+14,
          4.28710404e+14,   3.41809811e+14,   3.22753979e+14,
          3.31469480e+14,   3.72950678e+14,   4.65641241e+14,
          4.58818070e+14,   3.95335238e+14,   3.68504072e+14,
          3.05507147e+14,   2.75473576e+14,   3.14992419e+14,
          3.30726329e+14,   3.18439393e+14,   2.74707103e+14,
          2.92647323e+14,   3.19076948e+14,   4.19350914e+14,
          4.45341350e+14,   3.83324757e+14,   3.84315858e+14,
          4.35858583e+14,   4.98353263e+14,   3.27245254e+14,
          2.35542009e+14,   2.15938613e+14,   2.67279027e+14,
          3.32047788e+14,   2.98102854e+14,   3.75976214e+14,
          4.15494994e+14,   3.22190008e+14,   3.34865261e+14,
          4.44368457e+14,   4.24791977e+14,   2.77803596e+14,
          2.09045511e+14,   1.71111537e+14,   1.84025350e+14,
          2.04324175e+14,   2.29716778e+14,   2.24225927e+14,
          1.86604040e+14,   1.75435063e+14,   1.87891533e+14,
          1.88549699e+14,   1.64605070e+14,   1.57380653e+14,
          1.63008529e+14,   1.78675764e+14,   1.85023487e+14,
          1.76869748e+14,   1.59448064e+14,   1.52715280e+14,
          1.45711565e+14,   1.29725201e+14,   1.31008391e+14,
          1.52269940e+14,   1.33954521e+14,   1.42146094e+14,
          1.52146694e+14,   1.52123024e+14,   1.31778765e+14,
          1.29755266e+14,   1.28643329e+14,   1.24990810e+14,
          1.14022737e+14,   1.11648431e+14,   1.04041410e+14,
          1.01910617e+14,   1.01906090e+14,   9.21645233e+13,
          8.68133556e+13,   8.19678470e+13,   7.87469294e+13,
          8.55350757e+13,   9.33050690e+13,   8.58064587e+13,
          7.30888764e+13,   6.59526553e+13,   5.98224668e+13,
          5.54966806e+13,   5.13105252e+13,   5.16471838e+13,
          5.40999962e+13,   5.37351361e+13,   5.23947227e+13,
          4.82422191e+13,   4.69548360e+13,   4.70302740e+13,
          4.39710859e+13,   3.71240168e+13,   3.37634485e+13,
          3.15936539e+13,   2.92090872e+13,   2.86669654e+13,
          2.83373755e+13,   2.73778852e+13,   2.44379994e+13,
          2.21263175e+13,   1.99985976e+13,   1.88698008e+13,
          1.78390618e+13,   1.60822649e+13,   1.45969421e+13,
          1.36137423e+13,   1.23973060e+13,   1.10176119e+13,
          1.01607225e+13,   9.11132937e+12,   8.15159930e+12,
          7.50453241e+12,   6.57587610e+12,   5.73783277e+12,
          5.05364964e+12,   4.32922569e+12,   3.58119818e+12,
          3.00634685e+12,   2.50232340e+12,   2.02871088e+12,
          1.62028353e+12,   1.27483109e+12,   9.70415252e+11,
          7.29519039e+11,   5.41048454e+11,   3.94483903e+11,
          2.77384976e+11,   1.84388610e+11,   1.16020874e+11,
          7.01918781e+10,   3.93124801e+10,   2.01261622e+10,
          9.84250829e+09,   4.95528055e+09,   2.73411418e+09,
          1.65818053e+09,   1.21314445e+09,   9.47018999e+08,
          6.67293420e+08,   3.33752277e+08,  -1.13011652e+07,
         -2.52378834e+08,  -3.47868689e+08,  -3.38124908e+08,
         -1.92139736e+08,  -1.45151377e+07]))

In [20]:
#Solve diffusion equation sequentially by iterating over the spatial
#domain inwards from the upper boundary. This version of the method is
#explicit.

D = d2.Dsolvedown(1,640)


/home/user/PyPPM/ppmpy/ppm.py:3766: RuntimeWarning: divide by zero encountered in log10
  yplot = np.log10(y0long) if log_X else y0long
/home/user/PyPPM/ppmpy/ppm.py:3775: RuntimeWarning: divide by zero encountered in log10
  yplot = np.log10(y1long) if log_X else y1long
/home/user/PyPPM/ppmpy/ppm.py:3793: RuntimeWarning: divide by zero encountered in log10
  pl.plot(x/1.e8,np.log10(D),'k-',\
/home/user/PyPPM/ppmpy/ppm.py:3793: RuntimeWarning: invalid value encountered in log10
  pl.plot(x/1.e8,np.log10(D),'k-',\
/home/user/PyPPM/ppmpy/ppm.py:3797: RuntimeWarning: divide by zero encountered in log10
  pl.plot(x/1.e8,np.log10(-D),'k--',\
/home/user/PyPPM/ppmpy/ppm.py:3797: RuntimeWarning: invalid value encountered in log10
  pl.plot(x/1.e8,np.log10(-D),'k--',\

In [21]:
case = 'D1'
resolution = 768
cycles = range(150, 332, 1)
mdot_curve_label = r'{:s} $\left( {:d}^3 \right)$'.format(case, resolution)
mdot = d1.entrainment_rate(cycles, 7.5, 8.5, var = 'vxz', criterion = 'min_grad', offset = -1., \
       integrate_both_fluids = False, ifig0 = 3, mdot_curve_label = mdot_curve_label)


/usr/local/lib/python3.5/dist-packages/matplotlib/font_manager.py:1297: UserWarning: findfont: Font family ['Times New Roman'] not found. Falling back to DejaVu Sans
  (prop.get_family(), self.defaultFamily[fontext]))

In [22]:
b = d1.boundary_radius(cycles, r_min = 7.5, r_max = 8.5)

In [29]:
v = d1.vaverage()

In [24]:
fig2 = figure(19)
d2.spacetime_diagram('Ek',100,fig2)


vlim = [2.928e+03, 1.885e+13]

In [25]:
ppm.set_YProf_path('/data/ppm_rpod2/YProfiles/O-shell-M25/')
cases = ['D15','D2','D1']
ymin = 4. ; ymax = 8.

ppm.v_evolution(cases,ymin,ymax,'radial','max')



In [26]:
#L_H_yp = ppm.luminosity_for_dump('/data/ppm_rpod2/YProfiles/AGBTP_M2.0Z1.e-5/F5')
#t, L_H_rp = ppm.luminosity_for_dump('/data/ppm_rpod2/RProfiles/AGBTP_M2.0Z1.e-5/F5', True)
#ppm.plot_luminosity(L_H_yp,L_H_rp,t)

In [28]:
data_path = "/data/ppm_rpod2/RProfiles/O-shell-M25/D15/"
dump_to_plot = 121
hist_dump_min = 101
hist_dump_max = 135
r1 =7.5
r2 =8.5

ppm.upper_bound_ut(data_path, dump_to_plot, hist_dump_min, hist_dump_max,r1,r2, derivative =True)



In [ ]: