Docsity

coding practice in physics using Mathematica, Transcrições de Física para Ensino Médio

Toggle sidebar
bg1
In[32]:=
(*Import the data from the specified file*)
RbT55L20Data =Import["C:\\Users\\abuba\\OneDrive\\Desktop\\RbT55L20.txt", "Table"];
ListLinePlot[RbT55L20Data, Frame True, Axes None,
FrameLabel {"Frequency Detuning (Hz)", "Transmission"},
PlotStyle {Black, Thick}, Joined True]
(*Define the length of the Rb cell*)
L=0.020;
(*Calculate the absorption coefficient using the natural logarithm*)
absorptionList = -Log[RbT55L20Data〚All, 2〛]/L;
(*Extract the list of frequency detuning values*)
frequencyDetuning =RbT55L20Data〚All, 1〛;
(*Combine the frequency detuning and absorption coefficient into a list*)
absorptionData =Transpose[{frequencyDetuning, absorptionList}];
(*Plot the absorption coefficient*)
ListLinePlot[absorptionData, PlotRange All, Frame True,
Axes False, PlotStyle {Black, Thick}, Joined True,
FrameLabel {"Frequency Detuning (Hz)", "Absorption Coefficient (m⁻¹)"}]
(*Define constants*)
l0 =780.24 *10^-9;
(*Wavelength in meters*)c=3*10^8;
(*Speed of light in m/s*)w0 =2*Pi *c/l0;
(*Angular frequency*)(*Calculate the list of Im[c]values*)
ciList =absorptionList *c/w0;
(*Combine frequency detuning and Im[c]values into a list*)
ciData =Transpose[{frequencyDetuning, ciList}];
(*Interpolate for numerical integration*)
ciInterp =Interpolation[ciData];
(*Plot the interpolated Im[c]values*)
Plot[ciInterp[d],{d, -4*10^9, 6 *10 ^ 9}, PlotRange All, Frame True, Axes False,
PlotStyle {Black, Thick}, FrameLabel {"Frequency Detuning (Hz)", "Im[c]"}]
(*Define cr[d]function using the Kramers-Kronig relation*)
cr[d_] :=1/Pi NIntegrate[ciInterp[dp] / (dp -d),{dp, -4*10^9, 6 *10^9}, Method
"PrincipalValue", Exclusions {dp -d0}, AccuracyGoal 3, MaxRecursion 4];
(*Define a new set of data points with a larger step size*)
frequencyRange =Range[-4*10^9, 6 *10 ^9, 200 *10 ^ 6];
pf3
pf4

Pré-visualização parcial do texto

Baixe coding practice in physics using Mathematica e outras Transcrições em PDF para Física para Ensino Médio, somente na Docsity!

In[32]:=

(* Import the data from the specified file *) RbT55L20Data = Import [ "C:\Users\abuba\OneDrive\Desktop\RbT55L20.txt", "Table" ] ;

ListLinePlot [ RbT55L20Data, Frame True, Axes None, FrameLabel  { "Frequency Detuning ( Hz ) ", "Transmission" } , PlotStyle  { Black, Thick } , Joined True ]

(* Define the length of the Rb cell *) L = 0.020;

(* Calculate the absorption coefficient using the natural logarithm *) absorptionList = - Log [ RbT55L20Data 〚 All, 2 〛] / L;

(* Extract the list of frequency detuning values *) frequencyDetuning = RbT55L20Data 〚 All, 1 〛 ;

(* Combine the frequency detuning and absorption coefficient into a list *) absorptionData = Transpose [{ frequencyDetuning, absorptionList }] ;

(* Plot the absorption coefficient *) ListLinePlot [ absorptionData, PlotRange All, Frame True, Axes False, PlotStyle  { Black, Thick } , Joined True, FrameLabel  { "Frequency Detuning ( Hz ) ", "Absorption Coefficient ( m ⁻ ¹ ) " }]

(* Define constants ) l0 = 780.24 ***** 10 ^ - 9; ( Wavelength in meters ) c = 3 ***** 10 ^ 8; ( Speed of light in m / s ) w0 = 2 ***** Pi ***** c / l0; ( Angular frequency )( Calculate the list of Im [ c ] values *) ciList = absorptionList ***** c / w0;

(* Combine frequency detuning and Im [ c ] values into a list *) ciData = Transpose [{ frequencyDetuning, ciList }] ;

(* Interpolate for numerical integration *) ciInterp = Interpolation [ ciData ] ;

(* Plot the interpolated Im [ c ] values *) Plot [ ciInterp [ d ] , { d, - 4 ***** 10 ^ 9, 6 ***** 10 ^ 9 } , PlotRange All, Frame True, Axes False, PlotStyle  { Black, Thick } , FrameLabel  { "Frequency Detuning ( Hz ) ", "Im [ c ] " }]

(* Define cr [ d ] function using the Kramers - Kronig relation *) cr [ d _] : = 1 / Pi NIntegrate [ ciInterp [ dp ] / ( dp - d ) , { dp, - 4 ***** 10 ^ 9, 6 ***** 10 ^ 9 } , Method "PrincipalValue", Exclusions  { dp - d 0 } , AccuracyGoal 3, MaxRecursion 4 ] ;

(* Define a new set of data points with a larger step size *) frequencyRange = Range [- 4 ***** 10 ^ 9, 6 ***** 10 ^ 9, 200 ***** 10 ^ 6 ] ;

(* Calculate cr using parallel computation for faster execution *) crList = ParallelTable [ cr [ d ] , { d, frequencyRange }] ;

(* Calculate the refractive index n *) nListT55L20 = 1. + crList / 2.;

(* Combine the frequency detuning and refractive index into a list *) nDataT55L20 = Transpose [{ frequencyRange, nListT55L20 }] ;

(* Plot the refractive index *) ListLinePlot [ nDataT55L20, PlotRange All, Frame True, Axes False, FrameLabel  { "Frequency Detuning ( Hz ) ", "Refractive Index, n" } , PlotStyle  { Black, Thick } , Joined True ]

(* Export the refractive index data *) Export [ "C:\Users\abuba\OneDrive\Desktop\Refractive _ Index _ nT55L20.txt", nDataT55L20, "Table" ] ;

(* Load the refractive index data *) data = Import [ "C:\Users\abuba\OneDrive\Desktop\Refractive _ Index _ nT55L20.txt", "Table" ] ;

(* Extract frequency and refractive index *) frequencies = data 〚 All, 1 〛 ; refractiveIndices = data 〚 All, 2 〛 ;

(* Calculate the angular frequencies *) angularFrequencies = 2 Pi frequencies;

(* Calculate the derivative of refractive index with respect to angular frequency *) derivative = Differences [ refractiveIndices ] / Differences [ angularFrequencies ] ;

(* Append the last derivative value for matching lengths *) derivative = Join [ derivative, { derivative 〚- 1 〛}] ;

(* Calculate the group index using ng = n + w ***** dn / dw *) groupIndex = refractiveIndices + Abs [ angularFrequencies **] *** derivative;

(* Combine results into a table without normalization *) results = Transpose [{ frequencies, groupIndex }] ;

(* Export the group index results *) Export [ "group _ index _ results _ nT55L20.txt", results, "Table" ] ;

(* Find minimum and maximum values of groupIndex for better scaling *) minGroupIndex = Min [ groupIndex ] ; maxGroupIndex = Max [ groupIndex ] ;

(* Adjust the y - axis range to zoom into the behavior ) yRange = { minGroupIndex - 0.05 *** (* maxGroupIndex - minGroupIndex ) ,

Out[48]=

  • 4 × 10 9 - 2 × 10 9 0 2 × 10 9 4 × 10 9 6 × 10 9

Frequency Detuning (Hz)

Refractive Index, n

Out[62]=

  • 4 × 10 9 - 2 × 10 9 0 2 × 10 9 4 × 10 9 6 × 10 9 Frequency (Hz)

Group Index

Group Index vs. Frequency