Last change
on this file since 94 was 33, checked in by Rick van der Zwet, 15 years ago |
Restored acc. version
|
File size:
1.3 KB
|
Line | |
---|
1 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
---|
2 | % This function calculates the Second Harmonic Generation
|
---|
3 | % of a Gaussian of frequencies with a given phase function.
|
---|
4 | %
|
---|
5 | % phi - an input COLUMN vector, containing the phase function.
|
---|
6 | % SHG - the output of the calculation; scalar.
|
---|
7 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
---|
8 |
|
---|
9 | function [SHG] = SHG(phi);
|
---|
10 |
|
---|
11 | %constant for consistency with the Fortran Calculation...
|
---|
12 | c_fortran = 153.7687;
|
---|
13 |
|
---|
14 | % Generate the Gaussian and the phase function consistently.
|
---|
15 | Np = length(phi(:,1));
|
---|
16 | Nv = 4000;
|
---|
17 | v = linspace(-300,300,Nv); %Linearly Spaced Vector
|
---|
18 | G = 40;
|
---|
19 | Ain = exp(-(v/G).^2); %The Gaussian of Frequencies
|
---|
20 |
|
---|
21 | %Distribute the phase function according to the desired resolution
|
---|
22 | step = round((2600-1400)/Np);
|
---|
23 | step = step + (step==1);
|
---|
24 | phase = zeros(1,Nv);
|
---|
25 | k = 1;
|
---|
26 | for j = 1400:step:2600-step+1,
|
---|
27 | phase([j:j+step-1]) = phi(k);
|
---|
28 | if (k < Np)
|
---|
29 | k = k+1;
|
---|
30 | else
|
---|
31 | k = Np;
|
---|
32 | end
|
---|
33 | end
|
---|
34 | % *** The Core: SHG *** %
|
---|
35 |
|
---|
36 | %Fourier Transform with phase shift (phi) on the Gaussian *Ain*
|
---|
37 | E_t = fftshift(ifft(fftshift(exp(i*phase).*Ain)));
|
---|
38 |
|
---|
39 | %plot(abs(E_t));
|
---|
40 | %Integrate the result to yield the SHG
|
---|
41 | SHG = sum(abs(E_t).^4)/c_fortran;
|
---|
42 |
|
---|
43 |
|
---|
44 | %%%%%%%%%%%%%%%%%%%%%%%%%%% E O F %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
---|
Note:
See
TracBrowser
for help on using the repository browser.