-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathhhgmax_pulse.m
102 lines (93 loc) · 3.79 KB
/
hhgmax_pulse.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
% Calculates the Fourier coefficients of a pulse with given shape, as needed by
% the *_driving_field.m functions.
%
% Arguments:
% t - time axis, equally spaced, in scaled atomic units
% config - struct() of the following fields:
% config.wavelength - wavelength in millimeters
% config.pulse_duration - duration of pulse (FWHM w.r.t. intensity) in
% femtoseconds (only necessary if pulse shape is
% not constant)
% config.pulse_shape (optional) - one of 'constant' (default),
% 'gaussian', 'super-gaussian', or
% 'cos_sqr'
% config.carrier (optional) - can be 'cos' (default) or 'exp'
% config.ellipticity (optional) - if given, an elliptically polarized
% field is computed, and coefficients for
% both components are returned (amplitude
% is corrected so that total pulse power
% is the same as for linear polarization)
% config.ce_phase (optional) - allows to specify a CE phase
%
% Return values:
% omega - the angular frequency axis corresponding to the coefficients, from
% -pi/N/dt to pi/N/dt in non-monotonic order (value 0 comes first)
% coefficients - the Fourier coefficients of the pulse (dimensionality:
% C*length(omega) where C is the number of components (1 for
% linear polarization, 2 for elliptical polarization)
%
% Example:
% > t=-30*2*pi:.01:30*2*pi;
% > config = struct();
% > config.wavelength = 1e-3;
% > config.pulse_duration = 70;
% > config.pulse_shape = 'cos_sqr';
% > [omega, coefficients]=hhgmax_pulse(t, config);
% > plot(t, real(ifft(conj(coefficients))));
%
function [omega, coefficients] = hhgmax_pulse(t, config)
% convert pulse duration from femtoseconds to scaled atomic units
if isfield(config, 'pulse_shape') && ~strcmpi(config.pulse_shape, 'constant')
fwhm = hhgmax_sau_convert(config.pulse_duration*1e-15, 't', 'SAU', config);
if t(1)/(fwhm/2) > -2.5
warning('lower limit of t interval might cut pulse')
end
if t(end)/(fwhm/2) < 2.5
warning('upper limit of t interval might cut pulse')
end
end
% construct envelope
if ~isfield(config, 'pulse_shape') || strcmpi(config.pulse_shape, 'constant')
envelope = 1;
elseif strcmpi(config.pulse_shape, 'gaussian')
tau = fwhm/2/sqrt(log(sqrt(2)));
envelope = exp(-(t/tau).^2);
elseif strcmpi(config.pulse_shape, 'super-gaussian')
tau = fwhm/2/sqrt(sqrt(log(sqrt(2))));
envelope = exp(-(t/tau).^4);
elseif strcmpi(config.pulse_shape, 'cos_sqr')
tau = fwhm/2/acos(1/sqrt(sqrt(2)));
envelope = cos(t/tau) .^ 2;
envelope(t/tau<=-pi/2) = 0;
envelope(t/tau>=pi/2) = 0;
else
error('unknown pulse shape');
end
% parse carrier option
if ~isfield(config, 'carrier') || strcmpi(config.carrier, 'cos')
carrier = @cos;
elseif strcmpi(config.carrier, 'exp')
carrier = @(x) exp(1i*x);
else
error('invalid carrier: must be ''cos'' or ''exp''');
end
% compute time-dependent amplitude
if isfield(config,'ce_phase')
ce_phase = config.ce_phase;
else
ce_phase = 0;
end
amplitude(1,:) = envelope .* carrier(t+ce_phase);
% add polarization
if isfield(config,'ellipticity')
ellipticity = config.ellipticity;
amplitude(2,:) = (1-ellipticity) * envelope .* carrier(t+ce_phase-pi/2);
amplitude = amplitude / sqrt( 1 + (1-ellipticity)^2 );
end
% setup frequency axis
domega = 2*pi/(t(2)-t(1))/length(t);
temp = (0:length(t)-1);
temp(temp>=ceil(length(temp)/2)) = temp(temp>=ceil(length(temp)/2)) - length(temp);
omega = temp * domega;
% fourier transform
coefficients = conj(fft(conj(amplitude),[],2));