source: liacs/NC2010/laser-pulse-shaping/SHG.m@ 216

Last change on this file since 216 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
9function [SHG] = SHG(phi);
10
11%constant for consistency with the Fortran Calculation...
12c_fortran = 153.7687;
13
14% Generate the Gaussian and the phase function consistently.
15Np = length(phi(:,1));
16Nv = 4000;
17v = linspace(-300,300,Nv); %Linearly Spaced Vector
18G = 40;
19Ain = exp(-(v/G).^2); %The Gaussian of Frequencies
20
21%Distribute the phase function according to the desired resolution
22step = round((2600-1400)/Np);
23step = step + (step==1);
24phase = zeros(1,Nv);
25k = 1;
26for 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
33end
34 % *** The Core: SHG *** %
35
36%Fourier Transform with phase shift (phi) on the Gaussian *Ain*
37E_t = fftshift(ifft(fftshift(exp(i*phase).*Ain)));
38
39%plot(abs(E_t));
40%Integrate the result to yield the SHG
41SHG = sum(abs(E_t).^4)/c_fortran;
42
43
44%%%%%%%%%%%%%%%%%%%%%%%%%%% E O F %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
Note: See TracBrowser for help on using the repository browser.