Commit 09a38e82 authored by Matthias Steffen's avatar Matthias Steffen
Browse files

Auxiliary routines added:

ff2_inv.pro is an alternative to the (less accurate) fitting function ff3
ff1_extra.pro allows extrapolation in Teff or log g using ff1.pro
parent 5ce92d32
function ff1_extra, Teff, glog, FeH, ALi, qiso
;
; Purpose: call ff1 several times to achieve a decent extrapolation
;
if (FeH lt -3.2 or FeH gt 0.2) then begin
print, '% FF1_extra: [Fe/H] out of range: ' + string(FeH,format='(F5.2)')
print, '% FF1_extra: must be in the range -3.0 .. 0.0'
ff1_extra_out = [-99.9,-99.9]
return, ff1_extra_out
endif
if (ALi gt 3.0) then begin
print, '% FF1_extra: A(Li) out of range: ' + string(Ali,format='(F5.2)')
print, '% FF1_extra: must be less than 3.0'
ff1_extra_out = [-99.9,-99.9]
return, ff1_extra_out
endif
if (qiso lt 0.0 or qiso gt 0.1) then begin
print, '% FF1_extra: 6Li/7Li out of range: ' + string(qiso,format='(F5.2)')
print, '% FF1_extra: must be in the range 0.0 .. 0.082'
ff1_extra_out = [-99.9,-99.9]
return, ff1_extra_out
endif
if (Teff lt 5000.0 or Teff gt 6500.0) then textra_flag=1 else textra_flag=0
if (glog lt 3.5 or glog gt 4.5) then gextra_flag=1 else gextra_flag=0
;
; --- no extrapolation required ---
if (textra_flag eq 0 and gextra_flag eq 0) then begin
ff1_extra_out=ff1(Teff, glog, FeH, Ali, qiso)
return, ff1_extra_out
endif
; --- extrapolation in log g ---
if (textra_flag eq 0 and gextra_flag eq 1) then begin
print, '% FF1_extra: log g out of range: ' + string(glog,format='(F5.2)')
print, '% FF1_extra: Extrapolation at fixed Teff=' + $
string(Teff,format='(F8.2)') + ' K'
if (glog lt 3.5) then begin
ginp1=3.5
ginp2=4.0
f1=ff1(Teff, ginp1, FeH, Ali, qiso)
f2=ff1(Teff, ginp2, FeH, Ali, qiso)
ff1_extra_out=(f1*(ginp2-glog)-f2*(ginp1-glog))/(ginp2-ginp1)
endif
if (glog gt 4.5) then begin
ginp1=4.0
ginp2=4.5
f1=ff1(Teff, ginp1, FeH, Ali, qiso)
f2=ff1(Teff, ginp2, FeH, Ali, qiso)
ff1_extra_out=(f1*(ginp2-glog)-f2*(ginp1-glog))/(ginp2-ginp1)
endif
return, ff1_extra_out
endif
; --- extrapolation in Teff ---
if (textra_flag eq 1 and gextra_flag eq 0) then begin
print, '% FF1_extra: Teff out of range: ' + $
string(Teff,format='(F8.2)') + ' K'
print, '% FF1_extra: Extrapolation at fixed log g=' + $
string(glog,format='(F5.2)')
if (Teff lt 5000.0) then begin
tinp1=5000.0
tinp2=5100.0
f1=ff1(tinp1, glog, FeH, Ali, qiso)
f2=ff1(tinp2, glog, FeH, Ali, qiso)
ff1_extra_out=(f1*(tinp2-Teff)-f2*(tinp1-Teff))/(tinp2-tinp1)
endif
if (Teff gt 6500.0) then begin
tinp1=6400.0
tinp2=6500.0
f1=ff1(tinp1, glog, FeH, Ali, qiso)
f2=ff1(tinp2, glog, FeH, Ali, qiso)
ff1_extra_out=(f1*(tinp2-Teff)-f2*(tinp1-Teff))/(tinp2-tinp1)
endif
return, ff1_extra_out
endif
; --- no extrapolation attempted ---
if (textra_flag eq 1 and gextra_flag eq 1) then begin
print, '% FF1_extra: Teff out of range: ' + $
string(Teff,format='(F8.2)') + ' K'
print, '% FF1_extra: must be in the range 5000 .. 6500 K'
print, '% FF1_extra: log g out of range: ' + string(glog,format='(F5.2)')
print, '% FF1_extra: must be in the range 3.5 .. 4.5'
ff1_out = [-99.9,-99.9]
return, ff1_out
endif
;
end ; ff1_extra
function ff2_inv, t, glog, z, EW, qiso, ALi0
;
; Find A(Li) given the stellar parameters and EW, using
; fitting function ff2 in a simple iterative procedure. Ali0
; is a two-elements array [ALi_1DNLTE, ALI_3DNLTE]] with the
; initial guess for the lithium abundances that produce the
; equivalent width EW in 1D NLTE and 3D NLTE, respectively.
; ff2_inv is an alternative to the less accurate fitting function ff3
;
itmax = 20
atol = 1.0D-5
aa1=ALi0[0]
aa3=ALi0[1]
for it=0,itmax do begin
ff2_out1=ff2(t, glog, z, aa1, qiso)
ff2_out3=ff2(t, glog, z, aa3, qiso)
if (ff2_out1[0] lt -99.0 or ff2_out3[1] lt -99.0) then begin
aa1=-99.9
aa3=-99.9
break
endif else begin
err1=ew-ff2_out1[0]
err3=ew-ff2_out3[1]
aa1=aa1+err1
aa3=aa3+err3
print, it, ew, FLOAT(ff2_out1[0]), FLOAT(ff2_out3[1]), $
FLOAT(aa1), FLOAT(aa3)
endelse
if (ABS(err1) lt atol and ABS(err3) lt atol) then break
endfor
return, [aa1,aa3]
;
end
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment