In [1]:
import yt
import os
import math
from yt import derived_field
import matplotlib.pyplot as plt
import numpy as np
from matplotlib.colors import LogNorm
from yt.units import pc, kpc, second, Kelvin, gram, erg, cm

import Read_binary as Rd
import Locate_Nearby_SN as NSN

import copy
from matplotlib.colors import LogNorm

%matplotlib inline

#import Read_particles as Rd

mp      = 1.6726e-24# g
mu      = 1.2924
kb      = 1.3806e-16   # erg K-1
GNewton = 6.6743e-8   # cm3 g-1 s-2
Msun    = 1.9884e33   # gram
ppc     = 3.0856e18
mm      = mu*mp
In [3]:
Cloud_name = "M3e3"
#resolution = 0.1
resolution = 0.06

tinit       = 0.0
tfin        = 9.8

nmin=100

if resolution < 0.1:
    resolution_str = "%.3i" %(resolution*100)
else:
    resolution_str = "%.2i" %(resolution*10)
In [4]:
cloud = Rd.Restore_One_Snapshot(Cloud_name, resolution, 0)
Reading the File M3e3_CloudObject_snp000.dat
In [5]:
Nearby_SN = NSN.Locate_Nearby_SN(Cloud_name, min_dist=100)
NSN.Print_Nearby_SN(Nearby_SN)
('Total Number of SN:', 4627)
SN at d = 60.33 	, time = 1.17
dx = 30.00, dy = 51.06, dz = 11.48
SN at d = 79.85 	, time = 1.81
dx = 14.84, dy = 77.65, dz = -11.30
SN at d = 56.73 	, time = 2.62
dx = 7.24, dy = 51.48, dz = -22.70
SN at d = 72.57 	, time = 4.26
dx = 60.39, dy = 13.08, dz = 38.07
t = 1.17 	, d = 60.33 	, px = -942.23, py = -51.06, pz = 11.48
t = 1.81 	, d = 79.85 	, px = 14.84, py = -77.64, pz = -11.30
t = 2.62 	, d = 56.73 	, px = 7.24, py = 51.48, pz = -22.70
t = 4.26 	, d = 72.57 	, px = -911.85, py = -13.08, pz = 38.07
In [6]:
# Jeans_length_crit = 3.31 * (n / 100)**(-0.5)

n_crit = (3.31 / (4*resolution))**2 * 100
In [7]:
print n_crit
19021.0069444
In [19]:
global_data, global_props = Rd.Restore_Cloud_Evolution(Cloud_name, resolution, 0, tfin, nmin=100)
Reading the File M3e3_CloudObject_snp000.dat
Reading the File M3e3_CloudObject_snp000.dat
Reading the File M3e3_CloudObject_snp001.dat
Reading the File M3e3_CloudObject_snp002.dat
Reading the File M3e3_CloudObject_snp003.dat
Reading the File M3e3_CloudObject_snp004.dat
Reading the File M3e3_CloudObject_snp005.dat
Reading the File M3e3_CloudObject_snp006.dat
Reading the File M3e3_CloudObject_snp007.dat
Reading the File M3e3_CloudObject_snp008.dat
Reading the File M3e3_CloudObject_snp009.dat
Reading the File M3e3_CloudObject_snp010.dat
Reading the File M3e3_CloudObject_snp011.dat
Reading the File M3e3_CloudObject_snp012.dat
Reading the File M3e3_CloudObject_snp013.dat
Reading the File M3e3_CloudObject_snp014.dat
Reading the File M3e3_CloudObject_snp015.dat
Reading the File M3e3_CloudObject_snp016.dat
Reading the File M3e3_CloudObject_snp017.dat
Reading the File M3e3_CloudObject_snp018.dat
Reading the File M3e3_CloudObject_snp019.dat
Reading the File M3e3_CloudObject_snp020.dat
Reading the File M3e3_CloudObject_snp021.dat
Reading the File M3e3_CloudObject_snp022.dat
Reading the File M3e3_CloudObject_snp023.dat
Reading the File M3e3_CloudObject_snp024.dat
Reading the File M3e3_CloudObject_snp025.dat
Reading the File M3e3_CloudObject_snp026.dat
Reading the File M3e3_CloudObject_snp027.dat
Reading the File M3e3_CloudObject_snp028.dat
Reading the File M3e3_CloudObject_snp029.dat
Reading the File M3e3_CloudObject_snp030.dat
Reading the File M3e3_CloudObject_snp031.dat
Reading the File M3e3_CloudObject_snp032.dat
Reading the File M3e3_CloudObject_snp033.dat
Reading the File M3e3_CloudObject_snp034.dat
Reading the File M3e3_CloudObject_snp035.dat
Reading the File M3e3_CloudObject_snp036.dat
Reading the File M3e3_CloudObject_snp037.dat
Reading the File M3e3_CloudObject_snp038.dat
Reading the File M3e3_CloudObject_snp039.dat
Reading the File M3e3_CloudObject_snp040.dat
Reading the File M3e3_CloudObject_snp041.dat
Reading the File M3e3_CloudObject_snp042.dat
Reading the File M3e3_CloudObject_snp043.dat
Reading the File M3e3_CloudObject_snp044.dat
Reading the File M3e3_CloudObject_snp045.dat
Reading the File M3e3_CloudObject_snp046.dat
Reading the File M3e3_CloudObject_snp047.dat
Reading the File M3e3_CloudObject_snp048.dat
Reading the File M3e3_CloudObject_snp049.dat
Reading the File M3e3_CloudObject_snp050.dat
Reading the File M3e3_CloudObject_snp051.dat
Reading the File M3e3_CloudObject_snp052.dat
Reading the File M3e3_CloudObject_snp053.dat
Reading the File M3e3_CloudObject_snp054.dat
Reading the File M3e3_CloudObject_snp055.dat
Reading the File M3e3_CloudObject_snp056.dat
Reading the File M3e3_CloudObject_snp057.dat
Reading the File M3e3_CloudObject_snp058.dat
Reading the File M3e3_CloudObject_snp059.dat
Reading the File M3e3_CloudObject_snp060.dat
Reading the File M3e3_CloudObject_snp061.dat
Reading the File M3e3_CloudObject_snp062.dat
Reading the File M3e3_CloudObject_snp063.dat
Reading the File M3e3_CloudObject_snp064.dat
Reading the File M3e3_CloudObject_snp065.dat
Reading the File M3e3_CloudObject_snp066.dat
Reading the File M3e3_CloudObject_snp067.dat
Reading the File M3e3_CloudObject_snp068.dat
Reading the File M3e3_CloudObject_snp069.dat
Reading the File M3e3_CloudObject_snp070.dat
Reading the File M3e3_CloudObject_snp071.dat
Reading the File M3e3_CloudObject_snp072.dat
Reading the File M3e3_CloudObject_snp073.dat
Reading the File M3e3_CloudObject_snp074.dat
Reading the File M3e3_CloudObject_snp075.dat
Reading the File M3e3_CloudObject_snp076.dat
Reading the File M3e3_CloudObject_snp077.dat
Reading the File M3e3_CloudObject_snp078.dat
Reading the File M3e3_CloudObject_snp079.dat
Reading the File M3e3_CloudObject_snp080.dat
Reading the File M3e3_CloudObject_snp081.dat
Reading the File M3e3_CloudObject_snp082.dat
Reading the File M3e3_CloudObject_snp083.dat
Reading the File M3e3_CloudObject_snp084.dat
Reading the File M3e3_CloudObject_snp085.dat
Reading the File M3e3_CloudObject_snp086.dat
Reading the File M3e3_CloudObject_snp087.dat
Reading the File M3e3_CloudObject_snp088.dat
Reading the File M3e3_CloudObject_snp089.dat
Reading the File M3e3_CloudObject_snp090.dat
Reading the File M3e3_CloudObject_snp091.dat
Reading the File M3e3_CloudObject_snp092.dat
Reading the File M3e3_CloudObject_snp093.dat
Reading the File M3e3_CloudObject_snp094.dat
Reading the File M3e3_CloudObject_snp095.dat
Reading the File M3e3_CloudObject_snp096.dat
Reading the File M3e3_CloudObject_snp097.dat
Reading the File M3e3_CloudObject_snp098.dat
In [20]:
global_data_mask, global_props_mask = Rd.Restore_Cloud_Evolution(Cloud_name, resolution, 0, tfin, nmin=100, nmax=n_crit)
Reading the File M3e3_CloudObject_snp000.dat
Reading the File M3e3_CloudObject_snp000.dat
Reading the File M3e3_CloudObject_snp001.dat
Reading the File M3e3_CloudObject_snp002.dat
Reading the File M3e3_CloudObject_snp003.dat
Reading the File M3e3_CloudObject_snp004.dat
Reading the File M3e3_CloudObject_snp005.dat
Reading the File M3e3_CloudObject_snp006.dat
Reading the File M3e3_CloudObject_snp007.dat
Reading the File M3e3_CloudObject_snp008.dat
Reading the File M3e3_CloudObject_snp009.dat
Reading the File M3e3_CloudObject_snp010.dat
Reading the File M3e3_CloudObject_snp011.dat
Reading the File M3e3_CloudObject_snp012.dat
Reading the File M3e3_CloudObject_snp013.dat
Reading the File M3e3_CloudObject_snp014.dat
Reading the File M3e3_CloudObject_snp015.dat
Reading the File M3e3_CloudObject_snp016.dat
Reading the File M3e3_CloudObject_snp017.dat
Reading the File M3e3_CloudObject_snp018.dat
Reading the File M3e3_CloudObject_snp019.dat
Reading the File M3e3_CloudObject_snp020.dat
Reading the File M3e3_CloudObject_snp021.dat
Reading the File M3e3_CloudObject_snp022.dat
Reading the File M3e3_CloudObject_snp023.dat
Reading the File M3e3_CloudObject_snp024.dat
Reading the File M3e3_CloudObject_snp025.dat
Reading the File M3e3_CloudObject_snp026.dat
Reading the File M3e3_CloudObject_snp027.dat
Reading the File M3e3_CloudObject_snp028.dat
Reading the File M3e3_CloudObject_snp029.dat
Reading the File M3e3_CloudObject_snp030.dat
Reading the File M3e3_CloudObject_snp031.dat
Reading the File M3e3_CloudObject_snp032.dat
Reading the File M3e3_CloudObject_snp033.dat
Reading the File M3e3_CloudObject_snp034.dat
Reading the File M3e3_CloudObject_snp035.dat
Reading the File M3e3_CloudObject_snp036.dat
Reading the File M3e3_CloudObject_snp037.dat
Reading the File M3e3_CloudObject_snp038.dat
Reading the File M3e3_CloudObject_snp039.dat
Reading the File M3e3_CloudObject_snp040.dat
Reading the File M3e3_CloudObject_snp041.dat
Reading the File M3e3_CloudObject_snp042.dat
Reading the File M3e3_CloudObject_snp043.dat
Reading the File M3e3_CloudObject_snp044.dat
Reading the File M3e3_CloudObject_snp045.dat
Reading the File M3e3_CloudObject_snp046.dat
Reading the File M3e3_CloudObject_snp047.dat
Reading the File M3e3_CloudObject_snp048.dat
Reading the File M3e3_CloudObject_snp049.dat
Reading the File M3e3_CloudObject_snp050.dat
Reading the File M3e3_CloudObject_snp051.dat
Reading the File M3e3_CloudObject_snp052.dat
Reading the File M3e3_CloudObject_snp053.dat
Reading the File M3e3_CloudObject_snp054.dat
Reading the File M3e3_CloudObject_snp055.dat
Reading the File M3e3_CloudObject_snp056.dat
Reading the File M3e3_CloudObject_snp057.dat
Reading the File M3e3_CloudObject_snp058.dat
Reading the File M3e3_CloudObject_snp059.dat
Reading the File M3e3_CloudObject_snp060.dat
Reading the File M3e3_CloudObject_snp061.dat
Reading the File M3e3_CloudObject_snp062.dat
Reading the File M3e3_CloudObject_snp063.dat
Reading the File M3e3_CloudObject_snp064.dat
Reading the File M3e3_CloudObject_snp065.dat
Reading the File M3e3_CloudObject_snp066.dat
Reading the File M3e3_CloudObject_snp067.dat
Reading the File M3e3_CloudObject_snp068.dat
Reading the File M3e3_CloudObject_snp069.dat
Reading the File M3e3_CloudObject_snp070.dat
Reading the File M3e3_CloudObject_snp071.dat
Reading the File M3e3_CloudObject_snp072.dat
Reading the File M3e3_CloudObject_snp073.dat
Reading the File M3e3_CloudObject_snp074.dat
Reading the File M3e3_CloudObject_snp075.dat
Reading the File M3e3_CloudObject_snp076.dat
Reading the File M3e3_CloudObject_snp077.dat
Reading the File M3e3_CloudObject_snp078.dat
Reading the File M3e3_CloudObject_snp079.dat
Reading the File M3e3_CloudObject_snp080.dat
Reading the File M3e3_CloudObject_snp081.dat
Reading the File M3e3_CloudObject_snp082.dat
Reading the File M3e3_CloudObject_snp083.dat
Reading the File M3e3_CloudObject_snp084.dat
Reading the File M3e3_CloudObject_snp085.dat
Reading the File M3e3_CloudObject_snp086.dat
Reading the File M3e3_CloudObject_snp087.dat
Reading the File M3e3_CloudObject_snp088.dat
Reading the File M3e3_CloudObject_snp089.dat
Reading the File M3e3_CloudObject_snp090.dat
Reading the File M3e3_CloudObject_snp091.dat
Reading the File M3e3_CloudObject_snp092.dat
Reading the File M3e3_CloudObject_snp093.dat
Reading the File M3e3_CloudObject_snp094.dat
Reading the File M3e3_CloudObject_snp095.dat
Reading the File M3e3_CloudObject_snp096.dat
Reading the File M3e3_CloudObject_snp097.dat
Reading the File M3e3_CloudObject_snp098.dat
In [62]:
#global_data100, global_props100 = Rd.Restore_Cloud_Evolution(Cloud_name, resolution, 0, tfin, nmin=nmin)
In [63]:
#global_data1000, global_props1000 = Rd.Restore_Cloud_Evolution(Cloud_name, resolution, 0, tfin, nmin=1000)
In [64]:
#global_data10000, global_props10000 = Rd.Restore_Cloud_Evolution(Cloud_name, resolution, 0, tfin, nmin=10000)

I'm not restoring the Cloud properties !!!

Just the cloud data.

In [9]:
# What is ncrit here?
#global_props_ncrit = Rd.get_cloud_global_evolution(Cloud_name, resolution, tinit, tfin, n_crit, 1.0e7)
global_data_ncrit, global_props_ncrit = Rd.Restore_Cloud_Evolution(Cloud_name, resolution, 0, tfin, nmin=n_crit)
Reading the File M3e3_CloudObject_snp000.dat
Reading the File M3e3_CloudObject_snp000.dat
Reading the File M3e3_CloudObject_snp001.dat
Reading the File M3e3_CloudObject_snp002.dat
Reading the File M3e3_CloudObject_snp003.dat
Reading the File M3e3_CloudObject_snp004.dat
Reading the File M3e3_CloudObject_snp005.dat
Reading the File M3e3_CloudObject_snp006.dat
Reading the File M3e3_CloudObject_snp007.dat
Reading the File M3e3_CloudObject_snp008.dat
Reading the File M3e3_CloudObject_snp009.dat
Reading the File M3e3_CloudObject_snp010.dat
Reading the File M3e3_CloudObject_snp011.dat
Reading the File M3e3_CloudObject_snp012.dat
Reading the File M3e3_CloudObject_snp013.dat
Reading the File M3e3_CloudObject_snp014.dat
Reading the File M3e3_CloudObject_snp015.dat
Reading the File M3e3_CloudObject_snp016.dat
Reading the File M3e3_CloudObject_snp017.dat
Reading the File M3e3_CloudObject_snp018.dat
Reading the File M3e3_CloudObject_snp019.dat
Reading the File M3e3_CloudObject_snp020.dat
Reading the File M3e3_CloudObject_snp021.dat
Reading the File M3e3_CloudObject_snp022.dat
Reading the File M3e3_CloudObject_snp023.dat
Reading the File M3e3_CloudObject_snp024.dat
Reading the File M3e3_CloudObject_snp025.dat
Reading the File M3e3_CloudObject_snp026.dat
Reading the File M3e3_CloudObject_snp027.dat
Reading the File M3e3_CloudObject_snp028.dat
Reading the File M3e3_CloudObject_snp029.dat
Reading the File M3e3_CloudObject_snp030.dat
Reading the File M3e3_CloudObject_snp031.dat
Reading the File M3e3_CloudObject_snp032.dat
Reading the File M3e3_CloudObject_snp033.dat
Reading the File M3e3_CloudObject_snp034.dat
Reading the File M3e3_CloudObject_snp035.dat
Reading the File M3e3_CloudObject_snp036.dat
Reading the File M3e3_CloudObject_snp037.dat
Reading the File M3e3_CloudObject_snp038.dat
Reading the File M3e3_CloudObject_snp039.dat
Reading the File M3e3_CloudObject_snp040.dat
Reading the File M3e3_CloudObject_snp041.dat
Reading the File M3e3_CloudObject_snp042.dat
Reading the File M3e3_CloudObject_snp043.dat
Reading the File M3e3_CloudObject_snp044.dat
Reading the File M3e3_CloudObject_snp045.dat
Reading the File M3e3_CloudObject_snp046.dat
Reading the File M3e3_CloudObject_snp047.dat
Reading the File M3e3_CloudObject_snp048.dat
Reading the File M3e3_CloudObject_snp049.dat
Reading the File M3e3_CloudObject_snp050.dat
Reading the File M3e3_CloudObject_snp051.dat
Reading the File M3e3_CloudObject_snp052.dat
Reading the File M3e3_CloudObject_snp053.dat
Reading the File M3e3_CloudObject_snp054.dat
Reading the File M3e3_CloudObject_snp055.dat
Reading the File M3e3_CloudObject_snp056.dat
Reading the File M3e3_CloudObject_snp057.dat
Reading the File M3e3_CloudObject_snp058.dat
Reading the File M3e3_CloudObject_snp059.dat
Reading the File M3e3_CloudObject_snp060.dat
Reading the File M3e3_CloudObject_snp061.dat
Reading the File M3e3_CloudObject_snp062.dat
Reading the File M3e3_CloudObject_snp063.dat
Reading the File M3e3_CloudObject_snp064.dat
Reading the File M3e3_CloudObject_snp065.dat
Reading the File M3e3_CloudObject_snp066.dat
Reading the File M3e3_CloudObject_snp067.dat
Reading the File M3e3_CloudObject_snp068.dat
Reading the File M3e3_CloudObject_snp069.dat
Reading the File M3e3_CloudObject_snp070.dat
Reading the File M3e3_CloudObject_snp071.dat
Reading the File M3e3_CloudObject_snp072.dat
Reading the File M3e3_CloudObject_snp073.dat
Reading the File M3e3_CloudObject_snp074.dat
Reading the File M3e3_CloudObject_snp075.dat
Reading the File M3e3_CloudObject_snp076.dat
Reading the File M3e3_CloudObject_snp077.dat
Reading the File M3e3_CloudObject_snp078.dat
Reading the File M3e3_CloudObject_snp079.dat
Reading the File M3e3_CloudObject_snp080.dat
Reading the File M3e3_CloudObject_snp081.dat
Reading the File M3e3_CloudObject_snp082.dat
Reading the File M3e3_CloudObject_snp083.dat
Reading the File M3e3_CloudObject_snp084.dat
Reading the File M3e3_CloudObject_snp085.dat
Reading the File M3e3_CloudObject_snp086.dat
Reading the File M3e3_CloudObject_snp087.dat
Reading the File M3e3_CloudObject_snp088.dat
Reading the File M3e3_CloudObject_snp089.dat
Reading the File M3e3_CloudObject_snp090.dat
Reading the File M3e3_CloudObject_snp091.dat
Reading the File M3e3_CloudObject_snp092.dat
Reading the File M3e3_CloudObject_snp093.dat
Reading the File M3e3_CloudObject_snp094.dat
Reading the File M3e3_CloudObject_snp095.dat
Reading the File M3e3_CloudObject_snp096.dat
Reading the File M3e3_CloudObject_snp097.dat
Reading the File M3e3_CloudObject_snp098.dat
In [23]:
Mass_ratio_resolved = np.array(global_props_ncrit["mass"]) / np.array(global_props["mass"])

# Locate the Point where the fragmentation and gravitational collapse is unresolved.
for i in range(len(Mass_ratio_resolved)):
    if Mass_ratio_resolved[i] >= 0.49:
        print("Cloud %s is unresolved after %i snapshots"%(Cloud_name, i))
        unresolved_index = i
        break
Cloud M3e3 is unresolved after 75 snapshots
In [24]:
ncloud = np.zeros_like(global_props["time"])

ncloud = np.array(global_props["mass"])/np.array(global_props["volume"]) / mm
In [25]:
Mass_accretion = np.zeros_like(global_props["time"])

for i in range(len(Mass_accretion)-2):

    j = i+1
    
    Mass_accretion[j] = (global_props["mass"][j+1] - global_props["mass"][j-1]) / Msun / \
                        ((global_props["time"][j+1] - global_props["time"][j-1])*1.0e6)

Mass_accretion[-1] = Mass_accretion[-2]
In [27]:
fig = plt.figure(figsize=(20, 6))

# Cloud Mass
################################################
ax = fig.add_subplot(131)

min_mass = np.min(global_props["mass"]) 
max_mass = np.max(global_props["mass"]) 

for sn in range(len(Nearby_SN["time"])):
    # Give the SN line a width with respect to the distance to the cloud.
    lwidth = -(1./25.)*Nearby_SN["distance"][sn] + 4
    yy = [min_mass/Msun-100, max_mass/Msun+100]
    lalpha = -(1/100.)*Nearby_SN["distance"][sn] + 2.0
    if lalpha > 1: lalpha = 1
    #print lwidth, lalpha
    #ax.plot([Nearby_SN["time"][sn], Nearby_SN["time"][sn]], yy, '--b', linewidth=lwidth)
    #ax.plot([Nearby_SN["time"][sn], Nearby_SN["time"][sn]], yy, '--b', linewidth=lwidth, alpha=lalpha)
    
    if (Nearby_SN["distance"][sn] < 95):
        ax.plot([Nearby_SN["time"][sn], Nearby_SN["time"][sn]], yy, '--b', linewidth=lwidth, alpha=lalpha)
        ytxt = (yy[1] - yy[0])*0.95 + yy[0]
        ax.text(Nearby_SN["time"][sn]+0.05, ytxt, "%.2f pc" %(Nearby_SN["distance"][sn]), rotation=90, fontsize=12)

ax.plot(global_props["time"], np.array(global_props["mass"])/Msun,  "-k", linewidth=2)
#ax.plot(global_props["time"], np.array(global_props_mask["mass"])/Msun,  "-r", linewidth=2)

#ax.plot(global_props["time"], M_expected,  "--b", linewidth=2)

ax.set_xlabel("time [Myr]", fontsize=15)
ax.set_ylabel("Mass [M$_{\odot}$]", fontsize=15)
ax.set_title("Cloud Mass and Radius", fontsize=15)

for tick in ax.xaxis.get_major_ticks():
    tick.label.set_fontsize(14) 
for tick in ax.yaxis.get_major_ticks():
    tick.label.set_fontsize(14) 

#min_mass = np.min(global_props["mass"]) 
#max_mass = np.max(global_props["mass"]) 
ax.set_ylim(min_mass/Msun-100, max_mass/Msun+100)
ax.set_xlim(global_props["time"][0], global_props["time"][-1])

start, end = ax.get_xlim()
ax.xaxis.set_ticks(np.arange(start, end, 1))

    
# -------------------------------------------

ax1 = ax.twinx()
    
ax1.plot(global_props["time"], np.array(global_props["radius"])/ppc,  ":k", linewidth=2)
#ax1.plot(global_props["time"], np.array(global_props_mask["radius"])/ppc,  ":r", linewidth=2)

ax1.set_ylabel("Radius [pc]", fontsize=15)

for tick in ax1.yaxis.get_major_ticks():
    tick.label.set_fontsize(14) 

ax1.tick_params(labelsize=14)

ax.fill_between([global_props["time"][unresolved_index], global_props["time"][-1]], [1.0e5, 1.0e5], alpha=0.5, color="grey")
Lx =  global_props["time"][-1] - global_props["time"][0]
Ly =  (max_mass - min_mass )/Msun
ax.text(0.75*Lx, min_mass/Msun + 0.4*Ly, "Unresolved\ncollapse", fontsize=15)


# Mass accretion rate.
################################################

ax = fig.add_subplot(132)

for sn in range(len(Nearby_SN["time"])):
    # Give the SN line a width with respect to the distance to the cloud.
    lwidth = -(1./25.)*Nearby_SN["distance"][sn] + 4
    yy = [1.0e-4, 4.0e-3]
    lalpha = -(1/100.)*Nearby_SN["distance"][sn] + 2.0
    if lalpha > 1: lalpha = 1
    #print lwidth, lalpha
    #ax.plot([Nearby_SN["time"][sn], Nearby_SN["time"][sn]], yy, '--b', linewidth=lwidth)
    #ax.plot([Nearby_SN["time"][sn], Nearby_SN["time"][sn]], yy, '--b', linewidth=lwidth, alpha=lalpha)
    
    if (Nearby_SN["distance"][sn] < 95):
        ax.plot([Nearby_SN["time"][sn], Nearby_SN["time"][sn]], yy, '--b', linewidth=lwidth, alpha=lalpha)
        ytxt = (yy[1] - yy[0])*0.85 + yy[0]
        ax.text(Nearby_SN["time"][sn]+0.05, ytxt, "%.2f pc" %(Nearby_SN["distance"][sn]), rotation=90, fontsize=12)


Acc_pos, Acc_neg = np.zeros_like(Mass_accretion), np.zeros_like(Mass_accretion)

for i in range(len(Acc_neg)):
    if Mass_accretion[i] > 0:
        Acc_pos[i] = Mass_accretion[i]
        Acc_neg[i] = 1.0e-99
    else:
        Acc_neg[i] = np.abs(Mass_accretion[i])
        Acc_pos[i] = 1.0e-99

#ax.plot(global_props["time"], np.array(Mass_accretion),  "-k", linewidth=2)
ax.plot(global_props["time"], Acc_pos,  "-k", linewidth=2)
ax.plot(global_props["time"], Acc_neg,  ":k", linewidth=2)

#ax.text(7, 1.3e-4, 'n$_{ISM}$=10 cm$^{-3}$')
#ax.plot(global_props["time"], Macc_exp10,  "--r", linewidth=1)

#ax.text(7, 2.5e-4, 'n$_{ISM}$=20 cm$^{-3}$')
#ax.plot(global_props["time"], Macc_exp20,  "-.r", linewidth=1)

#ax.text(7, 6.2e-4, 'n$_{ISM}$=50 cm$^{-3}$')
#ax.plot(global_props["time"], Macc_exp50,  ":r", linewidth=1)

ax.set_xlabel("time [Myr]", fontsize=15)
ax.set_ylabel("Accretion rate [M$_{\odot}$ yr$^{-1}$]", fontsize=15)
ax.set_title("Mass Accretion", fontsize=15)

for tick in ax.xaxis.get_major_ticks():
    tick.label.set_fontsize(14) 
for tick in ax.yaxis.get_major_ticks():
    tick.label.set_fontsize(14) 

ax.set_ylim(1.0e-4, 4.0e-3)
ax.set_yscale("log")    

ax.set_xlim(global_props["time"][0], global_props["time"][-1])

start, end = ax.get_xlim()
ax.xaxis.set_ticks(np.arange(start, end, 1))


# Virial Parameter
################################################
ax = fig.add_subplot(133)

ax.plot(global_props["time"], np.array(global_props["alpha_virial"]), "-k", linewidth=2)
#ax.plot(global_props["time"], np.array(global_props_mask["alpha_virial"]), "-r", linewidth=2)

ax.set_xlabel("time [Myr]", fontsize=15)
ax.set_ylabel("alpha virial", fontsize=15)
ax.set_title("Virial Parameter", fontsize=15)

for tick in ax.xaxis.get_major_ticks():
    tick.label.set_fontsize(14) 
for tick in ax.yaxis.get_major_ticks():
    tick.label.set_fontsize(14) 

ax.set_xlim(global_props["time"][0], global_props["time"][-1])

min_virial = np.min(global_props["alpha_virial"]) 
max_virial = np.max(global_props["alpha_virial"])
Ly       =  (max_virial - min_virial ) 

#ax.set_ylim(min_virial - 0.1*Ly, max_virial + 0.1*Ly)
ax.set_ylim(1.0e-1, max_virial + Ly)

ax.set_yscale("log")

start, end = ax.get_xlim()
ax.xaxis.set_ticks(np.arange(start, end, 1))



ax1 = ax.twinx()
ax1.plot(global_props["time"], np.array(global_props["vel_disp_total"])/1.0e5,  ":k", linewidth=2)
#ax1.plot(global_props["time"], np.array(global_props_mask["vel_disp_total"])/1.0e5,  ":r", linewidth=2)


ax1.set_ylabel("$\sigma_{tot}$ [km s$^{-1}$]", fontsize=15)

ax1.set_ylim(0.2, 1.5)
#ax1.set_yscale("log")

for tick in ax1.yaxis.get_major_ticks():
    tick.label.set_fontsize(14) 

ax1.tick_params(labelsize=14)

ax1.fill_between([global_props["time"][unresolved_index], global_props["time"][-1]], [1.0e5, 1.0e5], alpha=0.5, color="grey")
Lx =  global_props["time"][-1] - global_props["time"][0]
Ly =  (1.5 - 0.2 )
ax1.text(0.75*Lx, 0.2 + 0.2*Ly, "Unresolved\ncollapse", fontsize=15)


fig.tight_layout()

fig.show()

save_dir = "/home/jcibanezm/codes/StratBox/AccretingClouds_Paper/Plots/CloudEvolution_props/"
filename = Cloud_name + "_%s" %resolution_str + "_evol"

fig.savefig(save_dir+filename+".pdf", format='pdf')

print("Saving figure: %s.pdf" %(save_dir+filename))
Saving figure: /home/jcibanezm/codes/StratBox/AccretingClouds_Paper/Plots/CloudEvolution_props/M3e3_006_evol.pdf
In [84]:
fig = plt.figure(figsize=(20, 6))

# Cloud Mass
################################################
ax = fig.add_subplot(131)

min_mass = np.min(global_props["mass"]) 
max_mass = np.max(global_props["mass"]) 

for sn in range(len(Nearby_SN["time"])):
    # Give the SN line a width with respect to the distance to the cloud.
    lwidth = -(1./25.)*Nearby_SN["distance"][sn] + 4
    yy = [min_mass/Msun-100, max_mass/Msun+100]
    lalpha = -(1/100.)*Nearby_SN["distance"][sn] + 2.0
    if lalpha > 1: lalpha = 1
    #print lwidth, lalpha
    #ax.plot([Nearby_SN["time"][sn], Nearby_SN["time"][sn]], yy, '--b', linewidth=lwidth)
    #ax.plot([Nearby_SN["time"][sn], Nearby_SN["time"][sn]], yy, '--b', linewidth=lwidth, alpha=lalpha)
    
    if (Nearby_SN["distance"][sn] < 95):
        ax.plot([Nearby_SN["time"][sn], Nearby_SN["time"][sn]], yy, '--b', linewidth=lwidth, alpha=lalpha)
        ytxt = (yy[1] - yy[0])*0.95 + yy[0]
        ax.text(Nearby_SN["time"][sn]+0.05, ytxt, "%.2f pc" %(Nearby_SN["distance"][sn]), rotation=90, fontsize=12)

ax.plot(global_props["time"], np.array(global_props["mass"])/Msun,  "-k", linewidth=2)

#ax.plot(global_props["time"], M_expected,  "--b", linewidth=2)

ax.set_xlabel("time [Myr]", fontsize=15)
ax.set_ylabel("Mass [M$_{\odot}$]", fontsize=15)
ax.set_title("Cloud Mass and Radius", fontsize=15)

for tick in ax.xaxis.get_major_ticks():
    tick.label.set_fontsize(14) 
for tick in ax.yaxis.get_major_ticks():
    tick.label.set_fontsize(14) 

#min_mass = np.min(global_props["mass"]) 
#max_mass = np.max(global_props["mass"]) 
ax.set_ylim(min_mass/Msun-100, max_mass/Msun+100)
ax.set_xlim(global_props["time"][0], global_props["time"][-1])

start, end = ax.get_xlim()
ax.xaxis.set_ticks(np.arange(start, end, 1))

    
# -------------------------------------------

ax1 = ax.twinx()
    
ax1.plot(global_props["time"], np.array(global_props["radius"])/ppc,  ":k", linewidth=2)

ax1.set_ylabel("Radius [pc]", fontsize=15)

for tick in ax1.yaxis.get_major_ticks():
    tick.label.set_fontsize(14) 

ax1.tick_params(labelsize=14)

ax.fill_between([global_props["time"][unresolved_index], global_props["time"][-1]], [1.0e5, 1.0e5], alpha=0.5, color="grey")
Lx =  global_props["time"][-1] - global_props["time"][0]
Ly =  (max_mass - min_mass )/Msun
ax.text(0.75*Lx, min_mass/Msun + 0.4*Ly, "Unresolved\ncollapse", fontsize=15)


# Mass accretion rate.
################################################

ax = fig.add_subplot(132)

for sn in range(len(Nearby_SN["time"])):
    # Give the SN line a width with respect to the distance to the cloud.
    lwidth = -(1./25.)*Nearby_SN["distance"][sn] + 4
    yy = [1.0e-4, 4.0e-3]
    lalpha = -(1/100.)*Nearby_SN["distance"][sn] + 2.0
    if lalpha > 1: lalpha = 1
    #print lwidth, lalpha
    #ax.plot([Nearby_SN["time"][sn], Nearby_SN["time"][sn]], yy, '--b', linewidth=lwidth)
    #ax.plot([Nearby_SN["time"][sn], Nearby_SN["time"][sn]], yy, '--b', linewidth=lwidth, alpha=lalpha)
    
    if (Nearby_SN["distance"][sn] < 95):
        ax.plot([Nearby_SN["time"][sn], Nearby_SN["time"][sn]], yy, '--b', linewidth=lwidth, alpha=lalpha)
        ytxt = (yy[1] - yy[0])*0.85 + yy[0]
        ax.text(Nearby_SN["time"][sn]+0.05, ytxt, "%.2f pc" %(Nearby_SN["distance"][sn]), rotation=90, fontsize=12)


Acc_pos, Acc_neg = np.zeros_like(Mass_accretion), np.zeros_like(Mass_accretion)

for i in range(len(Acc_neg)):
    if Mass_accretion[i] > 0:
        Acc_pos[i] = Mass_accretion[i]
        Acc_neg[i] = 1.0e-99
    else:
        Acc_neg[i] = np.abs(Mass_accretion[i])
        Acc_pos[i] = 1.0e-99

#ax.plot(global_props["time"], np.array(Mass_accretion),  "-k", linewidth=2)
ax.plot(global_props["time"], Acc_pos,  "-k", linewidth=2)
ax.plot(global_props["time"], Acc_neg,  ":k", linewidth=2)

#ax.text(7, 1.3e-4, 'n$_{ISM}$=10 cm$^{-3}$')
#ax.plot(global_props["time"], Macc_exp10,  "--r", linewidth=1)

#ax.text(7, 2.5e-4, 'n$_{ISM}$=20 cm$^{-3}$')
#ax.plot(global_props["time"], Macc_exp20,  "-.r", linewidth=1)

#ax.text(7, 6.2e-4, 'n$_{ISM}$=50 cm$^{-3}$')
#ax.plot(global_props["time"], Macc_exp50,  ":r", linewidth=1)

ax.set_xlabel("time [Myr]", fontsize=15)
ax.set_ylabel("Accretion rate [M$_{\odot}$ yr$^{-1}$]", fontsize=15)
ax.set_title("Mass Accretion", fontsize=15)

for tick in ax.xaxis.get_major_ticks():
    tick.label.set_fontsize(14) 
for tick in ax.yaxis.get_major_ticks():
    tick.label.set_fontsize(14) 

ax.set_ylim(1.0e-4, 4.0e-3)
ax.set_yscale("log")    

ax.set_xlim(global_props["time"][0], global_props["time"][-1])

start, end = ax.get_xlim()
ax.xaxis.set_ticks(np.arange(start, end, 1))


# Virial Parameter
################################################
ax = fig.add_subplot(133)

ax.plot(global_props["time"], np.array(global_props["alpha_virial"]), "-k", linewidth=2)
ax.set_xlabel("time [Myr]", fontsize=15)
ax.set_ylabel("alpha virial", fontsize=15)
ax.set_title("Virial Parameter", fontsize=15)

for tick in ax.xaxis.get_major_ticks():
    tick.label.set_fontsize(14) 
for tick in ax.yaxis.get_major_ticks():
    tick.label.set_fontsize(14) 

ax.set_xlim(global_props["time"][0], global_props["time"][-1])

min_virial = np.min(global_props["alpha_virial"]) 
max_virial = np.max(global_props["alpha_virial"])
Ly       =  (max_virial - min_virial ) 

#ax.set_ylim(min_virial - 0.1*Ly, max_virial + 0.1*Ly)
ax.set_ylim(1.0e-1, max_virial + Ly)

ax.set_yscale("log")

start, end = ax.get_xlim()
ax.xaxis.set_ticks(np.arange(start, end, 1))



ax1 = ax.twinx()
ax1.plot(global_props["time"], np.array(global_props["vel_disp_total"])/1.0e5,  ":k", linewidth=2)
ax1.set_ylabel("$\sigma_{tot}$ [km s$^{-1}$]", fontsize=15)

ax1.set_ylim(0.2, 1.5)
#ax1.set_yscale("log")

for tick in ax1.yaxis.get_major_ticks():
    tick.label.set_fontsize(14) 

ax1.tick_params(labelsize=14)

ax1.fill_between([global_props["time"][unresolved_index], global_props["time"][-1]], [1.0e5, 1.0e5], alpha=0.5, color="grey")
Lx =  global_props["time"][-1] - global_props["time"][0]
Ly =  (1.5 - 0.2 )
ax1.text(0.75*Lx, 0.2 + 0.2*Ly, "Unresolved\ncollapse", fontsize=15)


fig.tight_layout()

fig.show()

save_dir = "/home/jcibanezm/codes/StratBox/AccretingClouds_Paper/Plots/CloudEvolution_props/"
filename = Cloud_name + "_%s" %resolution_str + "_evol"

fig.savefig(save_dir+filename+".pdf", format='pdf')

print("Saving figure: %s.pdf" %(save_dir+filename))
Saving figure: /home/jcibanezm/codes/StratBox/AccretingClouds_Paper/Plots/CloudEvolution_props/M8e3_01_evol.pdf