Skip to main content
Solved

Differences Zemax - Code V refractive index vs temperature?


Hi all,

Does any one know why calculation of the refractive index vs the temperature is different between the two softwares?

I’m not asking for glasses that have different parameters, (the reason is obvious) but for glasses which have same parameters and ways of calculation. Results are the same across the spectrum but not when the temperature changes.

You can try almost any Schott glasses as parameters are given by the vendor for both softwares.

It’s a bit frustrating. 😀

Best answer by MichaelH

Hey John,

Are you also asking on CodeV’s forum?  I don’t really know how CodeV implements it, but Zemax is actually more than just the 3 equations listed in the Help File. 

And the steps are: 

  1. Scale the wavelength to air at the reference temperature of the glass and a pressure of 1.0 atmospheres.
  2. Compute the relative index of the glass at the reference temperature from the dispersion formula.
  3. Compute the index of air at the reference temperature of the glass.
  4. Compute the absolute index of the glass (relative to vacuum) at the reference temperature of the glass.
  5. Compute the change in absolute index of refraction of the glass at the surface temperature.
  6. Compute the index of air at the system temperature and pressure
  7. Compute the index of the glass relative to the air at the system temperature and pressure

It’s a pretty complex algorithm to convert from relative index (air = 1.0) to absolute index (air = 1.0003) in order to use Schott’s formula.  When you go through all the equations in detail, Zemax is correct.

 From my understanding with my colleagues who primarily design in CodeV, they always rely on the thermal analysis of Zemax.  It’s a small population sample, but from a handful of people who use both, Zemax is more trusted.  

View original
Did this topic help you find an answer to your question?

13 replies

Michael.Young
Ultraviolet
Forum|alt.badge.img+1

First, I’m not an expert user of CodeV; However, I checked the reported refractive index for N-BK7 in both Zemax and CodeV at the same wavelength with and without the environmental factors on at the reference temperature for N-BK7 (20 Deg). My assumption is that this value can be checked against the Sellmeier formula used for calculating the index, i.e, that the change in index will be 0 at the reference wavelength. Zemax reports the same index of refraction to arbitrary precision. CodeV deviates. If I change the evaluated temperature by 2 Deg up in CodeV (from 20 Deg to 22 Deg) I can recover the correct answer. I don’t know why CodeV does this or if it is a bug or something subtle in how to implement the reference temperature etc.; however, I do think that Zemax is reliable in this case.


  • Author
  • Monochrome
  • 5 replies
  • August 7, 2024

Hi Michael, thanks for having a look at it.

For N-BK7, Zemax is indeed exactly identical for the nominal temperature (20 °C). Code V shows a difference of ≃ 2·10⁻⁶ compared to the computation.

However, when the temperature changes, Zemax deviates much more. @-40 °C it shows a difference of more than 10⁻⁴! Code V is still in the 10⁻⁶ range.

N-BK7

n(2,1 µm/-40 °C) :

1.4929312 (equation)
1.4928285 (Zemax δ ≃ 103·10⁻⁶)
1.4929364 (Code V δ ≃ 5·10⁻⁶)

n(2,1 µm/80 °C) :

1.4930318 (equation)
1.4930981 (Zemax δ ≃ 66·10⁻⁶)
1.4930310 (Code V δ ≃ 1·10⁻⁶)

n(2,1 µm/20 °C) :

1.4929616 (equation)
1.4929616 (Zemax δ = 0)
1.4929640 (Code V δ ≃ 2·10⁻⁶)

Across the spectrum the computation from Zemax is OK, but when the temperature changes it starts to deviate.

Any clue from anyone ?

Thanks.


Michael.Young
Ultraviolet
Forum|alt.badge.img+1

Hi John,

I will try and take another look at this.

I assume you’re using the following equation from the Zemax manual,

For additional reference, here is Schott’s discussion of dn/dT.


  • Author
  • Monochrome
  • 5 replies
  • August 7, 2024

Thanks!

Indeed, you assume correctly.


  • Author
  • Monochrome
  • 5 replies
  • August 27, 2024

Anyone has found somehting?

Thanks.


MichaelH
Ansys Staff
Forum|alt.badge.img+2
  • Ansys Staff
  • 342 replies
  • Answer
  • August 27, 2024

Hey John,

Are you also asking on CodeV’s forum?  I don’t really know how CodeV implements it, but Zemax is actually more than just the 3 equations listed in the Help File. 

And the steps are: 

  1. Scale the wavelength to air at the reference temperature of the glass and a pressure of 1.0 atmospheres.
  2. Compute the relative index of the glass at the reference temperature from the dispersion formula.
  3. Compute the index of air at the reference temperature of the glass.
  4. Compute the absolute index of the glass (relative to vacuum) at the reference temperature of the glass.
  5. Compute the change in absolute index of refraction of the glass at the surface temperature.
  6. Compute the index of air at the system temperature and pressure
  7. Compute the index of the glass relative to the air at the system temperature and pressure

It’s a pretty complex algorithm to convert from relative index (air = 1.0) to absolute index (air = 1.0003) in order to use Schott’s formula.  When you go through all the equations in detail, Zemax is correct.

 From my understanding with my colleagues who primarily design in CodeV, they always rely on the thermal analysis of Zemax.  It’s a small population sample, but from a handful of people who use both, Zemax is more trusted.  


  • Author
  • Monochrome
  • 5 replies
  • September 3, 2024

Thanks Michael for your feedback.

You’re right, following the 7 steps gives the right numbers.

Then, Code V deviates more than Zemax.

 


mocquin
  • Visible
  • 19 replies
  • February 19, 2025

For reference, I tried to reimplement the model quickly and test the implementation based on the example for Schott/N-BK7 given here: How OpticStudio calculates refractive index at arbitrary temperatures and pressures – Knowledgebase.

The results seem to agree well, I feel this python snippet makes the steps clearer and easier to debug:


# Expected values taken from https://support.zemax.com/hc/en-us/articles/1500005576002-How-OpticStudio-calculates-refractive-index-at-arbitrary-temperatures-and-pressures
# and are suffixed with "_exp"

# inputs
lmbda_mum = .55
T0_degC = 20
P0_atm = 1
# S stands for System
TS_degC = 30
PS_atm = 2

def n_air_units(lmbda_mum, rel_P, T_degC):
    # from Zemax doc The Setup Tab > System Group (the Setup Tab) > System
    #  Explorer > Environment > Index of Refraction Computation 
    # and This formula for the index of air is from F. Kohlrausch, Praktische 
    # Physik, 1968, Vol 1, page 408
    # https://support.zemax.com/hc/en-us/articles/1500005576002-How-OpticStudio
    # -calculates-refractive-index-at-arbitrary-temperatures-and-pressures
    n_ref = (
        1 + (6432.8 + 2949810 * lmbda_mum**2 /(146*lmbda_mum**2-1) +
              25540*lmbda_mum**2/(41*lmbda_mum**2-1)) * 1e-8
    )

    n_air = 1 + (n_ref - 1) * rel_P / (1.0 + (T_degC-15)*3.4785e-3)
    return n_air

# Compute the index of air at the reference temperature of the glass. 
n_air_P0_T0_exp = 1.00027308
print(n_air_P0_T0_exp, n_air_units(lmbda_mum, P0_atm, T0_degC))

# Compute the index of air at the system temperature and pressure 
n_air_PS_TS_exp = 1.00052810
print(n_air_PS_TS_exp, n_air_units(lmbda_mum, PS_atm, TS_degC))

# Scale the wavelength to air at the reference temperature of the glass and a
# pressure of 1.0 atmospheres. 
lmbda_rel_exp = .55014022
print(lmbda_rel_exp, 
      lmbda_mum * n_air_units(lmbda_mum, PS_atm, TS_degC) / n_air_units(lmbda_mum, P0_atm, T0_degC))

# Compute the relative index of the glass at the reference temperature from
# the dispersion formula. dispersion coefficients/formula for Schott.AGF 
# catalog, for N-BK7 glass
K1=1.03961212
L1=6.00069867e-3
K2=2.31792344e-1
L2=2.00179144e-2
K3=1.01046945
L3=1.03560653e2

def sellmeier1(lmbda, K1, K2, K3, L1, L2, L3):
    # from Zemax's doc at
    # The Libraries Tab > Optical Materials Group > Using Material Catalogs
    # > The Glass Dispersion Formulas > The Sellmeier 1 Formula 
    n2m1 = K1*lmbda**2/(lmbda**2-L1) + K2*lmbda**2/(lmbda**2-L2) + K3*lmbda**2/(lmbda**2-L3)
    return (n2m1+1)**0.5

n_BK7_at_lmbda_rel_exp = 1.51851533
print(n_BK7_at_lmbda_rel_exp, sellmeier1(lmbda_rel_exp, K1, K2, K3, L1, L2, L3))

# Compute the absolute index of the glass (relative to vacuum) at the reference
# temperature of the glass. 
n_BK7_abs_T0_P0_exp = 1.51893001
print(n_BK7_abs_T0_P0_exp, n_BK7_at_lmbda_rel_exp * n_air_P0_T0_exp)

# Compute the change in absolute index of refraction of the glass at the 
# surface temperature. 
D0=1.86e-6
D1=1.31e-8
D2=-1.37e-11
E0=4.34e-7
E1=6.27e-10
Ltk=1.7e-1
Temp=20
DT = TS_degC - Temp
S_tk = np.sign(Ltk)
Delta_n_abs = (
    (n_BK7_at_lmbda_rel_exp**2-1)/(2*n_BK7_at_lmbda_rel_exp) * 
    (D0*DT + D1 * DT**2 +D2 * DT**3 + (E0*DT+E1*DT**2)/(lmbda_rel_exp**2 - S_tk*Ltk**2))
)
Delta_n_abs_exp = 0.00001547
print(Delta_n_abs_exp, Delta_n_abs)

# The absolute index of the glass at the glass temperature and “pressure”
# (= system pressure) is determined from:
n_abs_= n_BK7_abs_T0_P0_exp + Delta_n_abs
n_abs_exp = 1.51894548
print(n_abs_exp, n_abs_)

# The relative index at T and P is then calculated by dividing the absolute 
# index by nair(Ps,Ts)
n_rel = n_abs_exp / n_air_PS_TS_exp
n_rel_exp = 1.51814375
print(n_rel_exp, n_rel)

 


David.Nguyen
Luminary
Forum|alt.badge.img+2

Hi all,

 

When reading the help file section: Index of Refraction Computation, I found this part confusing:

Is P really dimensionless, in which case how is it calculated? My understanding was that relative pressure is the pressure minus the ambient pressure (units are still [pressure] units). From ​@mocquin’s script, I gather it is more like the absolute pressure. At the same time, if P=0 we get n_air=1, which is the refractive index of air at a relative pressure of 0atm (whatever the absolute pressure might be). Can someone clarify this aspect for me please?

Take care,

 

David


mocquin
  • Visible
  • 19 replies
  • March 4, 2025

+1 on the lack of clarity in the definition of P in the doc’s equation :)

My understanding is that P in the equation of the doc is actually:

P_system / 1 atm

where P_system is the absolute system pressure.

Hence the example in the KB is at P=2atm, which gives rel_P=2 and is coherent in terms of value and units. As a consequence, if you specify the value in atmosphere unit, P is both the pressure, and the relative pressure, because

2atm/(1atm) = 2/1=2

 


David.Nguyen
Luminary
Forum|alt.badge.img+2

Thanks ​@mocquin, it kind of makes sense. I didn’t expect those calculations to be so involved. It was an interesting read, and you code helps a lot.

Take care,


David


mocquin
  • Visible
  • 19 replies
  • March 4, 2025

Agrre

I guess some simple ZPL macro could confirm those computations (I do not know ZPL for now)


mocquin
  • Visible
  • 19 replies
  • March 4, 2025

Agree

Some ZPL macro could probably confirms those computations (I do not know how to use ZPL for now..)


Reply


Cookie policy

We use cookies to enhance and personalize your experience. If you accept you agree to our full cookie policy. Learn more about our cookies.

 
Cookie settings