Energy Injection in 1D Brown Dwarf Climate Models
In this tutorial you will learn how you can add in an arbitrary amount of energy into your climate model. This could be because you want to build an intuition on the impact of temperature inversions or see if there are hot spots in your object causing variability in the observations for example. For a more in depth look at the climate-cloud code check out Mang et al. 2026 (note this should also be cited if using this code/tutorial).
You should be comfortable with running climate models by now, the minimum requirement for this tutorial is One-Dimensional Climate Models: The Basics of Brown Dwarfs.
[1]:
from virga import justplotit as vpi
from virga import justdoit as vdi
from picaso import justplotit as jpi
from picaso import justdoit as jdi
import os
import warnings
warnings.filterwarnings('ignore')
jpi.output_notebook()
import astropy.units as u
import numpy as np
import matplotlib.pyplot as plt
%matplotlib inline
import xarray as xr
from bokeh.plotting import show, figure
import pandas as pd
WARNING: Failed to load Vega spectrum from /data/reference_data/picaso/ref4/stellar_grids/calspec/alpha_lyr_stis_011.fits; Functionality involving Vega will be severely limited: FileNotFoundError(2, 'No such file or directory') [stsynphot.spectrum]
Analytical Energy Injection
In this part of the tutorial we are going to be comparing our climate models with those from Morley et al. 2014. We are going to test the case for a 600 K brown dwarf. To inject the energy into the atmosphere we are going to use the Chapman function to describe the profile of the energy deposition. The Chapman function is selected because it is often used to represent heating by incident flux within molecular bands.
We are going to initiate our profile just like any other basic climate model first
[2]:
# #1 ck tables from roxana
mh = '0.0'#'+0.0' #log metallicity
CtoO = '0.46'# # CtoO absolute ratio
ck_db = os.path.join(os.getenv('picaso_refdata'),'opacities', 'preweighted', f'sonora_2121grid_feh{mh}_co{CtoO}.hdf5')
#sonora bobcat cloud free structures file
sonora_profile_db = os.path.join(os.getenv('picaso_refdata'),'sonora_grids','bobcat')
[3]:
cl_run = jdi.inputs(calculation="browndwarf", climate = True) # start a calculation
#note you need to put the climate keyword to be True in order to do so
# now you need to add these parameters to your calculation
teff= 600 # Effective Temperature of your Brown Dwarf in K
grav = 1000 # Gravity of your brown dwarf in m/s/s
cl_run.gravity(gravity=grav, gravity_unit=u.Unit('m/(s**2)')) # input gravity
cl_run.effective_temp(teff) # input effective temperature
opacity_ck = jdi.opannection(ck_db=ck_db,method='preweighted') # grab your opacities
[4]:
nlevel = 91 # number of plane-parallel levels in your code
pressure_bobcat,temp_bobcat = np.loadtxt(jdi.os.path.join(
sonora_profile_db,f"t{teff}g{grav}nc_m0.0.cmp.gz"),
usecols=[1,2],unpack=True, skiprows = 1)
[5]:
rcb_guess = 87 # top most level of guessed convective zone
# Here are some other parameters needed for the code.
rfacv = 0.0 #we are focused on a brown dwarf so let's keep this as is
[6]:
cl_run.inputs_climate(temp_guess= temp_bobcat, pressure= pressure_bobcat,
rcb_guess=rcb_guess, rfacv = rfacv)
New PICASO code parameters:
inject_energy: (True/False) Turns on energy injection. Default = Falsetotal_energy_injection: (float) Desired total amount of energy to be deposited in units of ergs/cm^2/spress_max_energy: (float) Pressure for maximum energy injection in units of bars for chapman functioninjection_scaleheight: (float) Scalar specifying the number of scale heights over which energy is deposited
[7]:
cl_run.energy_injection(inject_energy = True, total_energy_injection= 3.67e6,
press_max_energy = 1, injection_scalehight= 1)
[8]:
out = cl_run.climate(opacity_ck, save_all_profiles=True,with_spec=True)
Tidal Injection is Turned on. This is your new energy profile. Pressure, tidal (erg/cm3)/s:
0.00017783 -11016635.2
0.00020869 -11016635.2
0.0002449 -11016635.16479053
0.00028739 -11016635.116308352
0.00033726 -11016635.049534524
0.00039579 -11016634.95757007
0.00046447 -11016634.830940602
0.00054506 -11016634.656584442
0.00063964 -11016634.41647697
0.00075064 -11016634.085820347
0.00088089 -11016633.630554166
0.0010337 -11016633.003874063
0.0012131 -11016632.140615804
0.0014236 -11016630.952194683
0.0016707 -11016629.315400075
0.0019606 -11016627.062539682
0.0023008 -11016623.961106015
0.0027 -11016619.692065805
0.0031685 -11016613.815335125
0.0037184 -11016605.724870019
0.0043636 -11016594.592368882
0.0051208 -11016579.271865748
0.0060094 -11016558.191598322
0.0070521 -11016529.193889063
0.0082758 -11016489.306155879
0.0097119 -11016434.450728461
0.011397 -11016359.043128863
0.013375 -11016255.371497408
0.015696 -11016112.943296656
0.018419 -11015917.390981082
0.021616 -11015648.80780688
0.025366 -11015280.496131798
0.029768 -11014775.346360369
0.034933 -11014083.382290576
0.040995 -11013136.073725007
0.048109 -11011840.699471062
0.056457 -11010071.691387154
0.066254 -11007659.120912667
0.07775 -11004374.923152417
0.091242 -10999912.263406597
0.10707 -10993865.228468958
0.12565 -10985688.348085674
0.14746 -10974666.93260457
0.17305 -10959874.630320594
0.20307 -10940113.452780463
0.23831 -10913833.172533013
0.27967 -10879102.29005384
0.3282 -10833544.571971513
0.38515 -10774278.83972285
0.45198 -10697939.780643143
0.53041 -10600734.843009515
0.62245 -10478638.396416951
0.73046 -10327708.872721534
0.85721 -10144603.044652209
1.006 -9927222.826918539
1.1805 -9675961.684222143
1.3854 -9393867.51457997
1.6258 -9088463.910700906
1.9079 -8771275.87613382
2.2389 -8457608.523625622
2.6274 -8164653.843385482
3.0834 -7908889.705858232
3.6184 -7702652.1528543
4.2463 -7551050.114021437
4.9831 -7451127.2368137855
5.8478 -7393165.78670052
6.8625 -7364230.840480819
8.0533 -7352117.679296072
9.4508 -7347993.48950058
11.091 -7346891.808251239
13.015 -7346670.368746274
15.274 -7346638.49716256
17.924 -7346635.397352671
21.034 -7346635.206946654
24.684 -7346635.200130616
28.968 -7346635.200001175
33.994 -7346635.200000005
39.893 -7346635.2
46.816 -7346635.2
54.939 -7346635.2
64.473 -7346635.2
75.66 -7346635.2
88.789 -7346635.2
104.2 -7346635.2
122.28 -7346635.2
143.49 -7346635.2
168.39 -7346635.2
197.62 -7346635.2
231.91 -7346635.2
272.15 -7346635.2
319.37 -7346635.2
SUMMARY
-------
Clouds: False
quench False
cold_trap False
vol_rainout False
no_ph3 False
Moist Adiabat: False
Iteration number 0 , min , max temp 178.05440326184774 2258.01935102453 , flux balance -0.36371640839484026
Iteration number 1 , min , max temp 182.23219867974717 2266.962509990343 , flux balance -0.3500369843859732
Iteration number 2 , min , max temp 186.25457418962415 2276.1607755996133 , flux balance -0.3357375793822119
Iteration number 3 , min , max temp 190.13982735717403 2285.607725955654 , flux balance -0.32080704185131004
Iteration number 4 , min , max temp 193.90372294349388 2295.2968448107345 , flux balance -0.3052341877904854
Iteration number 5 , min , max temp 197.55983134884804 2305.2215879008195 , flux balance -0.2890077388408398
Iteration number 6 , min , max temp 201.1198855343269 2315.3754268434377 , flux balance -0.27211628714697234
Iteration number 7 , min , max temp 204.59405443610072 2325.751883092252 , flux balance -0.2545482682715949
Iteration number 8 , min , max temp 207.99123041083956 2336.315826246886 , flux balance -0.2362919459393604
Iteration number 9 , min , max temp 211.31923340950496 2347.0738962653277 , flux balance -0.2173353978394921
Iterations exceeded max_inner_iterations ! sorry
Big iteration is 211.31923340950496 0
Iteration number 0 , min , max temp 214.58499933911236 2358.0345879172914 , flux balance -0.19766650718359915
Iteration number 1 , min , max temp 217.79474184499009 2369.1917866492145 , flux balance -0.17727295695767448
Iteration number 2 , min , max temp 220.95408098523635 2380.5394570193116 , flux balance -0.15614222869689676
Iteration number 3 , min , max temp 224.0681484145246 2392.07160929132 , flux balance -0.13426160580359808
Iteration number 4 , min , max temp 227.1417468825321 2403.7822264751467 , flux balance -0.11161819635683135
Iteration number 5 , min , max temp 230.17950179133055 2415.6651206779834 , flux balance -0.0881989775002811
Iteration number 6 , min , max temp 233.18612527951302 2427.6887698868104 , flux balance -0.06399090650972268
Iteration number 7 , min , max temp 236.16700627545913 2439.8408710852314 , flux balance -0.03898122121090535
Iteration number 8 , min , max temp 239.1303286387749 2452.13716532128 , flux balance -0.013158576362375572
Iteration number 9 , min , max temp 240.6074930177224 2458.2904865210044 , flux balance -1.7570441376894604e-05
Iterations exceeded max_inner_iterations ! sorry
Big iteration is 240.6074930177224 1
Iteration number 0 , min , max temp 240.6265521417385 2458.277158877199 , flux balance -1.3253268439665553e-07
In t_start: Converged Solution in iterations 0
Profile converged before max_outer_iterations
Iteration number 0 , min , max temp 241.42120164192607 2493.4823704718106 , flux balance -0.07477209342767703
Iteration number 1 , min , max temp 242.2564257588249 2528.3352571007244 , flux balance -0.06060806763396156
Iteration number 2 , min , max temp 243.1335915079278 2562.7773112848836 , flux balance -0.04580810063211896
Iteration number 3 , min , max temp 244.0550383809508 2596.908850587526 , flux balance -0.030349695632351285
Iteration number 4 , min , max temp 245.02579119216608 2630.550480279093 , flux balance -0.01418978455159858
Iteration number 5 , min , max temp 245.89221275232055 2658.1738727139336 , flux balance -1.6034103792100256e-05
Iteration number 6 , min , max temp 245.90525427186097 2657.773456862984 , flux balance -1.285071583553056e-07
In t_start: Converged Solution in iterations 6
Big iteration is 245.90525427186097 0
We are already at a root, tolf , test = 5e-05 , 2.0395427072540126e-06
Profile converged before max_outer_iterations
Move up two levels
Iteration number 0 , min , max temp 246.86089837310382 2370.235486100191 , flux balance -2.6570557145221656e-05
Iteration number 1 , min , max temp 246.87503808926112 2370.210261689973 , flux balance -2.020825729511743e-07
In t_start: Converged Solution in iterations 1
Big iteration is 246.87503808926112 0
We are already at a root, tolf , test = 5e-05 , 5.059718140823494e-07
Profile converged before max_outer_iterations
Iteration number 0 , min , max temp 247.05782979106266 2328.595061259507 , flux balance -1.113893360395449e-05
In t_start: Converged Solution in iterations 0
Big iteration is 247.05782979106266 0
We are already at a root, tolf , test = 5e-05 , 1.4687060967086001e-05
Profile converged before max_outer_iterations
Iteration number 0 , min , max temp 247.09059932354563 2315.207937441767 , flux balance -1.8449651798759383e-06
In t_start: Converged Solution in iterations 0
Big iteration is 247.09059932354563 0
We are already at a root, tolf , test = 5e-05 , 1.5865465009334767e-05
Profile converged before max_outer_iterations
Iteration number 0 , min , max temp 247.09609310654784 2315.7873986962745 , flux balance -2.6413844871284214e-07
In t_start: Converged Solution in iterations 0
Big iteration is 247.09609310654784 0
We are already at a root, tolf , test = 5e-05 , 1.5516350549823215e-06
Profile converged before max_outer_iterations
final [0, 82, 89, 0, 0, 0]
We are already at a root, tolf , test = 5e-05 , 1.182409052181469e-05
Big iteration is 247.09609310654784 0
We are already at a root, tolf , test = 5e-05 , 1.182409052181469e-05
Profile converged before max_outer_iterations
YAY ! ENDING WITH CONVERGENCE
[9]:
# Now let's read in our benchmark profile from Morley et. al 2014
benchmark = pd.read_csv('t600g1000nc-3.67e6-h1-1bar.dat',skiprows=1, sep=r'\s+')
#we only want to compare the P-T profile so we don't care about the other columns
benchmark.columns = ['level', 'pressure', 'temperature', 'x1', 'x2', 'x3', 'x4', 'x5', 'x6']
[10]:
pressure_bobcat,temp_bobcat = np.loadtxt(jdi.os.path.join(
sonora_profile_db,f"t{teff}g{grav}nc_m0.0.cmp.gz"),
usecols=[1,2],unpack=True, skiprows = 1)
plt.figure(figsize=(8,6))
plt.ylabel("Pressure [Bars]")
plt.xlabel('Temperature [K]')
plt.xlim(0,max(out['temperature'])+50)
plt.ylim(3e3,1e-3)
plt.semilogy(temp_bobcat,pressure_bobcat,color="k",linestyle="--",label="Sonora Bobcat")
plt.semilogy(benchmark['temperature'],benchmark['pressure'],color="r",linestyle="--",label="Morley 2014")
plt.semilogy(out['temperature'],out['pressure'],label="Our PICASO Run")
plt.legend()
plt.tight_layout()
plt.show()
When you generate these models, remember that because you artificially injected energy into the atmosphere, the profile will be warmer than the desired effective temperature that you set for the object. You might also notice here that there are the slightest difference in the PT profile between our model and the Morley 2014 model, we’re not worried about this since we ran a 91 level model compared to their 60 level model.
Numerical Energy Injection
Let’s say you don’t want to use something like the Chapman function because you have an actual profile of energy deposition you’d like to include in your model. We can add a couple of other inputs to do this.
[11]:
cl_run = jdi.inputs(calculation="browndwarf", climate = True) # start a calculation
#note you need to put the climate keyword to be True in order to do so
# now you need to add these parameters to your calculation
teff= 600 # Effective Temperature of your Brown Dwarf in K
grav = 1000 # Gravity of your brown dwarf in m/s/s
cl_run.gravity(gravity=grav, gravity_unit=u.Unit('m/(s**2)')) # input gravity
cl_run.effective_temp(teff) # input effective temperature
opacity_ck = jdi.opannection(ck_db=ck_db,method='preweighted') # grab your opacities
[12]:
nlevel = 91 # number of plane-parallel levels in your code
pressure_bobcat,temp_bobcat = np.loadtxt(jdi.os.path.join(
sonora_profile_db,f"t{teff}g{grav}nc_m0.0.cmp.gz"),
usecols=[1,2],unpack=True, skiprows = 1)
[13]:
rcb_guess = 87 # top most level of guessed convective zone
# Here are some other parameters needed for the code.
rfacv = 0.0 #we are focused on a brown dwarf so let's keep this as is
Here we’re going to generate a Gaussian distribution of energy that will be injected into the upper atmosphere of this climate model just as an example how you can use any energy profile you’d like
[14]:
from scipy.stats import norm
# Define the center and width of the Gaussian
center = 45 # Index for the peak of the Gaussian
width = 10 # Standard deviation of the Gaussian
# Create a Gaussian profile
beam_profile = norm.pdf(np.arange(len(pressure_bobcat)), loc=center, scale=width)
# Normalize the Gaussian to match the desired energy range
beam_profile = beam_profile / beam_profile.max() * 6e5 # Scale to the desired range
[15]:
plt.semilogy(beam_profile, pressure_bobcat, label='Gaussian Energy Beam Profile')
plt.gca().invert_yaxis()
plt.xlabel('Energy [ergs/cm^2/s]')
plt.ylabel('Pressure [Bars]')
plt.show()
New PICASO code parameters:
inject_beam: (bool) Turns on using your own energy profile instead of the Chapman functionbeam_profile: (array) Array of the energy profile. The shape of this array needs to be the same as the pressure grid.
[16]:
cl_run.inputs_climate(temp_guess= temp_bobcat, pressure= pressure_bobcat,
rcb_guess=rcb_guess, rfacv = rfacv)
mh=1
cto_relative=1
cl_run.atmosphere(mh=mh, cto_relative=cto_relative, chem_method='visscher_1060')
cl_run.energy_injection(inject_energy = True, inject_beam = True, beam_profile = beam_profile)
[17]:
out = cl_run.climate(opacity_ck, save_all_profiles=True,with_spec=True)
Tidal Injection is Turned on. This is your new energy profile. Pressure, tidal (erg/cm3)/s:
0.00017783 -22386324.888751347
0.00020869 -22386324.888751347
0.0002449 -22386266.93246592
0.00028739 -22386178.28308697
0.00033726 -22386044.035061307
0.00039579 -22385842.756660804
0.00046447 -22385543.982185125
0.00054506 -22385104.898936786
0.00063964 -22384466.03658015
0.00075064 -22383545.746406138
0.00088089 -22382233.246363632
0.0010337 -22380380.009534054
0.0012131 -22377789.294926602
0.0014236 -22374203.666514903
0.0016707 -22369290.42579814
0.0019606 -22362625.000595987
0.0023008 -22353672.49231513
0.0027 -22341767.786746792
0.0031685 -22326094.87669082
0.0037184 -22305666.32024327
0.0043636 -22279304.052177873
0.0051208 -22245623.056633104
0.0060094 -22203019.67002887
0.0070521 -22149666.48119768
0.0082758 -22083515.895284258
0.0097119 -22002314.39301353
0.011397 -21903629.315184444
0.013375 -21784889.60977505
0.015696 -21643441.384944446
0.018419 -21476618.32192529
0.021616 -21281826.044295028
0.025366 -21056638.463371813
0.029768 -20798902.993626103
0.034933 -20506850.4447833
0.040995 -20179204.44786138
0.048109 -19815284.56263963
0.056457 -19415096.83829906
0.066254 -18979405.63292628
0.07775 -18509780.987975147
0.091242 -18008616.810042318
0.10707 -17479116.50143583
0.12565 -16925244.426803183
0.14746 -16351643.590159874
0.17305 -15763521.979204029
0.20307 -15166512.048339903
0.23831 -14566509.592744056
0.27967 -13969499.661879934
0.3282 -13381378.050924085
0.38515 -12807777.214280777
0.45198 -12253905.139648128
0.53041 -11724404.831041642
0.62245 -11223240.653108813
0.73046 -10753616.008157678
0.85721 -10317924.802784901
1.006 -9917737.078444332
1.1805 -9553817.193222579
1.3854 -9226171.19630066
1.6258 -8934118.647457857
1.9079 -8676383.177712146
2.2389 -8451195.596788932
2.6274 -8256403.3191586705
3.0834 -8089580.256139514
3.6184 -7948132.031308907
4.2463 -7829392.325899516
4.9831 -7730707.248070429
5.8478 -7649505.745799703
6.8625 -7583355.159886279
8.0533 -7530001.971055091
9.4508 -7487398.584450857
11.091 -7453717.588906088
13.015 -7427355.320840691
15.274 -7406926.764393142
17.924 -7391253.854337166
21.034 -7379349.148768836
24.684 -7370396.640487975
28.968 -7363731.215285824
33.994 -7358817.974569059
39.893 -7355232.346157358
46.816 -7352641.631549907
54.939 -7350788.39472033
64.473 -7349475.894677824
75.66 -7348555.604503811
88.789 -7347916.7421471765
104.2 -7347477.658898835
122.28 -7347178.884423156
143.49 -7346977.606022653
168.39 -7346843.357996992
197.62 -7346754.70861804
231.91 -7346696.752332614
272.15 -7346659.239276822
319.37 -7346635.2
SUMMARY
-------
Clouds: False
quench False
cold_trap False
vol_rainout False
no_ph3 False
Moist Adiabat: False
Iteration number 0 , min , max temp 180.0227813180463 2249.448947530315 , flux balance -0.6929809234356967
Iteration number 1 , min , max temp 186.3482142474253 2249.583907417895 , flux balance -0.6926120011782949
Iteration number 2 , min , max temp 192.62878572523684 2249.7355121303635 , flux balance -0.692197293060115
Iteration number 3 , min , max temp 198.83465763111005 2249.905080204765 , flux balance -0.6917331163873927
Iteration number 4 , min , max temp 204.94926354285218 2250.0938828645963 , flux balance -0.6912159081085559
Iteration number 5 , min , max temp 210.96503649971592 2250.3031483815093 , flux balance -0.6906422125488481
Iteration number 6 , min , max temp 216.88014638784637 2250.5340652003747 , flux balance -0.6900086723795043
Iteration number 7 , min , max temp 222.69624637412454 2250.7877840828564 , flux balance -0.6893120221473251
Iteration number 8 , min , max temp 228.41700836124156 2251.065419608574 , flux balance -0.6885490834550909
Iteration number 9 , min , max temp 234.04719429147164 2251.368051380544 , flux balance -0.6877167608591576
Iterations exceeded max_inner_iterations ! sorry
Big iteration is 234.04719429147164 0
Iteration number 0 , min , max temp 239.5920704320243 2251.6967251879632 , flux balance -0.6868120378019611
Iteration number 1 , min , max temp 245.0570682624376 2252.0524541762757 , flux balance -0.685831972456666
Iteration number 2 , min , max temp 250.44757327717264 2252.436220164449 , flux balance -0.6847736931067289
Iteration number 3 , min , max temp 255.76881853988036 2252.848975052292 , flux balance -0.6836343932287019
Iteration number 4 , min , max temp 261.0258101619204 2253.291251948332 , flux balance -0.6824113259507102
Iteration number 5 , min , max temp 266.2233022275558 2253.763693123748 , flux balance -0.6811017982981732
Iteration number 6 , min , max temp 271.365795978959 2254.2677463471696 , flux balance -0.6797031651994875
Iteration number 7 , min , max temp 276.4575323141965 2254.804258869649 , flux balance -0.6782128230456476
Iteration number 8 , min , max temp 281.50250786596575 2255.3740569146667 , flux balance -0.6766282032708233
Iteration number 9 , min , max temp 286.50448405371367 2255.977947639444 , flux balance -0.6749467656897375
Iterations exceeded max_inner_iterations ! sorry
Big iteration is 286.50448405371367 1
Iteration number 0 , min , max temp 291.4670052327075 2256.6167210758117 , flux balance -0.6731659918629505
Iteration number 1 , min , max temp 296.3934105584556 2257.291152103556 , flux balance -0.671283378339786
Iteration number 2 , min , max temp 301.2868533612722 2258.0020023586158 , flux balance -0.6692964300500504
Iteration number 3 , min , max temp 306.1503085365928 2258.7500221854552 , flux balance -0.6672026535334262
Iteration number 4 , min , max temp 310.9865907005936 2259.5359524779565 , flux balance -0.6649995504408946
Iteration number 5 , min , max temp 315.7983618522729 2260.3605265302135 , flux balance -0.6626846109622215
Iteration number 6 , min , max temp 320.58814403502925 2261.2244717955064 , flux balance -0.6602553074609243
Iteration number 7 , min , max temp 325.35832807405365 2262.1285115987935 , flux balance -0.6577090881849731
Iteration number 8 , min , max temp 330.1111828623008 2263.0733667694303 , flux balance -0.6550433711425517
Iteration number 9 , min , max temp 334.84886108461427 2264.059757217867 , flux balance -0.6522555380698846
Iterations exceeded max_inner_iterations ! sorry
Big iteration is 334.84886108461427 2
Iteration number 0 , min , max temp 339.5734077608703 2265.088403409314 , flux balance -0.6493429286208066
Iteration number 1 , min , max temp 344.28676577395447 2266.1600277627585 , flux balance -0.6463028346929197
Iteration number 2 , min , max temp 348.9907799196916 2267.2753559803914 , flux balance -0.6431324948712119
Iteration number 3 , min , max temp 353.687203601392 2268.435118244499 , flux balance -0.6398290891647358
Iteration number 4 , min , max temp 358.3777008287331 2269.6400503755335 , flux balance -0.6363897337650041
Iteration number 5 , min , max temp 363.0638514988197 2270.890894846674 , flux balance -0.6328114761219181
Iteration number 6 , min , max temp 367.74715403533634 2272.188401730473 , flux balance -0.6290912901185818
Iteration number 7 , min , max temp 372.4290286850481 2273.5333295385108 , flux balance -0.6252260714532734
Iteration number 8 , min , max temp 377.11082068628997 2274.9264459560954 , flux balance -0.6212126332214278
Iteration number 9 , min , max temp 381.7938017236254 2276.3685285016045 , flux balance -0.6170477016099192
Iterations exceeded max_inner_iterations ! sorry
Big iteration is 381.7938017236254 3
Iteration number 0 , min , max temp 386.47917267033745 2277.860365067597 , flux balance -0.612727911826178
Iteration number 1 , min , max temp 391.1680655391107 2279.4027543752113 , flux balance -0.6082498041708794
Iteration number 2 , min , max temp 395.8615463156062 2280.9965063138206 , flux balance -0.6036098203342364
Iteration number 3 , min , max temp 400.56061480017627 2282.6424422321184 , flux balance -0.5988042997234606
Iteration number 4 , min , max temp 405.2662097081381 2284.341395053452 , flux balance -0.5938294761947146
Iteration number 5 , min , max temp 409.97920737746466 2286.094209395883 , flux balance -0.5886814746604407
Iteration number 6 , min , max temp 414.7004240967917 2287.901741546128 , flux balance -0.5833563080169233
Iteration number 7 , min , max temp 419.43061985747664 2289.764859325946 , flux balance -0.5778498742820058
Iteration number 8 , min , max temp 424.1704977245226 2291.68444193837 , flux balance -0.5721579536865304
Iteration number 9 , min , max temp 428.9207058119808 2293.661379692582 , flux balance -0.5662762060223784
Iterations exceeded max_inner_iterations ! sorry
Big iteration is 428.9207058119808 4
Iteration number 0 , min , max temp 433.68184052252224 2295.696573632385 , flux balance -0.5602001681775571
Iteration number 1 , min , max temp 438.454446257557 2297.7909351394796 , flux balance -0.5539252516502408
Iteration number 2 , min , max temp 443.23901934534615 2299.945385399349 , flux balance -0.5474467403822633
Iteration number 3 , min , max temp 448.0360080096695 2302.1608548644763 , flux balance -0.5407597885122672
Iteration number 4 , min , max temp 452.845814793638 2304.438282610318 , flux balance -0.533859418370191
Iteration number 5 , min , max temp 457.6687983425412 2306.778615642412 , flux balance -0.5267405185436823
Iteration number 6 , min , max temp 462.5052751508716 2309.1828081476015 , flux balance -0.5193978420449609
Iteration number 7 , min , max temp 467.3555223294937 2311.6518206695946 , flux balance -0.5118260046446932
Iteration number 8 , min , max temp 472.21977768843084 2314.1866192976604 , flux balance -0.5040194831112628
Iteration number 9 , min , max temp 477.09824355830114 2316.788174728599 , flux balance -0.49597261379114965
Iterations exceeded max_inner_iterations ! sorry
Big iteration is 477.09824355830114 5
Iteration number 0 , min , max temp 481.9910873646295 2319.4574613646223 , flux balance -0.48767959104355196
Iteration number 1 , min , max temp 486.8984446011414 2322.195456325376 , flux balance -0.4791344659091681
Iteration number 2 , min , max temp 491.82041954579233 2325.0031384843096 , flux balance -0.47033114468781717
Iteration number 3 , min , max temp 496.7570877399153 2327.881487443017 , flux balance -0.4612633876974937
Iteration number 4 , min , max temp 501.7084990389639 2330.825385162882 , flux balance -0.45192480813011937
Iteration number 5 , min , max temp 506.67467686108887 2333.835605593399 , flux balance -0.4423088706495706
Iteration number 6 , min , max temp 511.6556229039051 2336.9191072084664 , flux balance -0.43240889045334946
Iteration number 7 , min , max temp 516.6513176077966 2340.076857032077 , flux balance -0.42221803201939784
Iteration number 8 , min , max temp 521.6617222694048 2343.3098176541425 , flux balance -0.41172930798749474
Iteration number 9 , min , max temp 526.6867802232046 2346.618946260269 , flux balance -0.40093557797746004
Iterations exceeded max_inner_iterations ! sorry
Big iteration is 526.6867802232046 6
Not converged
Iteration number 0 , min , max temp 531.8553097452692 2365.448401664252 , flux balance -0.3735390105174015
Iteration number 1 , min , max temp 584.7895894989357 2555.1336415928754 , flux balance 0.11710412015360458
Iteration number 2 , min , max temp 579.85645346116 2533.0993032658225 , flux balance 0.00664810154037673
Iteration number 3 , min , max temp 579.8474819122774 2532.71561059881 , flux balance 6.695543501186285e-05
In t_start: Converged Solution in iterations 3
Big iteration is 579.8474819122774 0
Iteration number 0 , min , max temp 579.8484012556214 2532.714668291507 , flux balance 3.911303486711585e-07
In t_start: Converged Solution in iterations 0
Profile converged before max_outer_iterations
Move up two levels
Iteration number 0 , min , max temp 577.5749351621138 2366.149418718457 , flux balance 0.00011184666429153462
Iteration number 1 , min , max temp 577.3464847648592 2367.531764136286 , flux balance 8.899168768579645e-06
In t_start: Converged Solution in iterations 1
Big iteration is 577.3464847648592 0
We are already at a root, tolf , test = 5e-05 , 2.3890709141473912e-05
Profile converged before max_outer_iterations
Iteration number 0 , min , max temp 580.783245780647 2330.283618032098 , flux balance 2.1083036908633903e-05
We are already at a root, tolf , test = 5e-05 , 2.3188675010853652e-05
Big iteration is 580.783245780647 0
We are already at a root, tolf , test = 5e-05 , 2.3188675010853652e-05
Profile converged before max_outer_iterations
Iteration number 0 , min , max temp 578.9123836135166 2317.3050748227342 , flux balance 1.2388013048473164e-07
In t_start: Converged Solution in iterations 0
Big iteration is 578.9123836135166 0
We are already at a root, tolf , test = 5e-05 , 7.79508649636673e-06
Profile converged before max_outer_iterations
Iteration number 0 , min , max temp 579.7517760668592 2318.132170551254 , flux balance -1.6041578489725762e-07
In t_start: Converged Solution in iterations 0
Big iteration is 579.7517760668592 0
We are already at a root, tolf , test = 5e-05 , 1.0185425759547084e-06
Profile converged before max_outer_iterations
final [0, 82, 89, 0, 0, 0]
We are already at a root, tolf , test = 5e-05 , 3.666060351024816e-05
Big iteration is 579.7517760668592 0
We are already at a root, tolf , test = 5e-05 , 3.666060351024816e-05
Profile converged before max_outer_iterations
YAY ! ENDING WITH CONVERGENCE
[18]:
pressure_bobcat,temp_bobcat = np.loadtxt(jdi.os.path.join(
sonora_profile_db,f"t{teff}g{grav}nc_m0.0.cmp.gz"),
usecols=[1,2],unpack=True, skiprows = 1)
plt.figure(figsize=(8,6))
plt.ylabel("Pressure [Bars]")
plt.xlabel('Temperature [K]')
plt.xlim(0,max(out['temperature'])+50)
plt.ylim(3e3,1e-3)
plt.semilogy(temp_bobcat,pressure_bobcat,color="k",linestyle="--",label="Sonora Bobcat")
plt.semilogy(out['temperature'],out['pressure'],label="Our PICASO Run")
plt.legend()
plt.tight_layout()
plt.show()
[ ]: