Add analysis of errors based on ray-tracing

This commit is contained in:
2022-06-02 18:06:51 +02:00
parent f17ceca29d
commit f549fc5313
23 changed files with 1144 additions and 872 deletions

View File

@@ -34,25 +34,25 @@ pp = [0, 0, 0]; % [m]
np = [cos(pi/2-theta), 0, sin(pi/2-theta)];
%% Reflected beam
[p2, s2] = get_plane_reflection(p1, s1, pp, np);
[p2, s2] = getPlaneReflection(p1, s1, pp, np);
%% Secondary Mirror
ps = pp ...
+ 0.07*[cos(theta), 0, -sin(theta)] ... % x offset (does not matter a lot)
+ 0.032*[cos(theta), 0, -sin(theta)] ... % x offset (does not matter a lot)
- np*10e-3./(2*cos(theta)) ... % Theoretical offset
+ np*args.dz; % Add error in distance
ns = [Rdry*Rdrx*[cos(pi/2-theta), 0, sin(pi/2-theta)]']'; % Normal
%% Output Beam
[p3, s3] = get_plane_reflection(p2, s2, ps, ns);
[p3, s3] = getPlaneReflection(p2, s2, ps, ns);
%% Detector
pd = [1, 0, 0]; % [m]
nd = [-1, 0, 0];
%% Get beam position on the decector
p4 = get_plane_reflection(p3, s3, pd, nd);
p4 = getPlaneReflection(p3, s3, pd, nd);
results = struct();
% Beam position and orientations

View File

@@ -1,7 +1,7 @@
function [p_reflect, s_reflect] = get_plane_reflection(p_in, s_in, p_plane, n_plane)
% get_plane_reflection -
function [p_reflect, s_reflect] = getPlaneReflection(p_in, s_in, p_plane, n_plane)
% getPlaneReflection -
%
% Syntax: [p_reflect, s_reflect] = get_plane_reflection(p_in, s_in, p_plane, n_plane)
% Syntax: [p_reflect, s_reflect] = getPlaneReflection(p_in, s_in, p_plane, n_plane)
%
% Inputs:
% - p_in, s_in, p_plane, n_plane -

View File

@@ -9,6 +9,6 @@ function [] = plotBeamPath(results)
% Outputs:
% - in_data -
plot3([results.p1(1), results.p2(1)],[results.p1(2), results.p2(2)], [results.p1(3), results.p2(3)])
plot3([results.p2(1), results.p3(1)],[results.p2(2), results.p3(2)], [results.p2(3), results.p3(3)])
plot3([results.p3(1), results.p4(1)],[results.p3(2), results.p4(2)], [results.p3(3), results.p4(3)])
plot3(100*[results.p1(1), results.p2(1)],100*[results.p1(2), results.p2(2)], 100*[results.p1(3), results.p2(3)], 'linewidth', 0.5)
plot3(100*[results.p2(1), results.p3(1)],100*[results.p2(2), results.p3(2)], 100*[results.p2(3), results.p3(3)], 'linewidth', 0.5)
plot3(100*[results.p3(1), results.p4(1)],100*[results.p3(2), results.p4(2)], 100*[results.p3(3), results.p4(3)], 'linewidth', 0.5)

37
matlab/src/plotCrystals.m Normal file
View File

@@ -0,0 +1,37 @@
function [] = plotCrystals(results, args)
% plotCrystals -
%
% Syntax: [in_data] = plotCrystals(drx, dry, dz, theta, )
%
% Inputs:
% - drx, dry, dz, theta, -
%
% Outputs:
% - in_data -
arguments
results
args.color (3,1) double {mustBeNumeric} = [1;1;1]
args.alpha (1,1) double {mustBeNumeric} = 1
end
z = results.np;
y = [0,1,0];
x = cross(y,z);
xtal1_rectangle = [results.pp + 0.02/2*y + 0.035/2*x;
results.pp - 0.02/2*y + 0.035/2*x;
results.pp - 0.02/2*y - 0.035/2*x;
results.pp + 0.02/2*y - 0.035/2*x];
patch(100*xtal1_rectangle(:,1), 100*xtal1_rectangle(:,2), 100*xtal1_rectangle(:,3), 'k-')
z = results.ns;
% y = [0,cos(drx),sin(drx)];
y = [0,1,0];
x = cross(y,z);
xtal2_rectangle = [results.ps + 0.02/2*y + 0.07/2*x;
results.ps - 0.02/2*y + 0.07/2*x;
results.ps - 0.02/2*y - 0.07/2*x;
results.ps + 0.02/2*y - 0.07/2*x];
patch(100*xtal2_rectangle(:,1), 100*xtal2_rectangle(:,2), 100*xtal2_rectangle(:,3), 'k-')