Commit d79c1294 authored by Matteo Vallar's avatar Matteo Vallar
Browse files

added backbone script to produce markers. So far it starts from (R,z,E,pitch)...

added backbone script to produce markers. So far it starts from (R,z,E,pitch) and computes (x,y) assuming phi=0. Computes also vpara, vperp, vtot."
parent e873daa8
Pipeline #100311 passed with stages
in 1 minute and 59 seconds
function [ids_distributions] = ids_fill_markers(markers_in)
%
% [ids_distributions, varargout] = ids_fill_markers(markers_in);
%
% Function to fill the distributions.distribution.markers fields
% So far the input markers_in must contain at least (E,pitch,R,z) fields
%
% M. Vallar - 03/2022
ids_distributions = ids_empty_distributions();
allowed_fields = {'E', 'pitch','R','z'};
%% Checking if all the fields needed are present
for i=1:numel(allowed_fields)
if ~isfield(markers_in, allowed_fields{i})
error('Cannot continue without field %s \nExit \n', allowed_fields{i})
end
end
fprintf('All needed quantities present in input structure \n');
markers2ids = markers_in;
%% if no mass can be detected, assume mass is the one of deuterium
mass = 2*1.6e-27;
%% Making names compliant to ids names
if isfield(markers_in, 'E')
markers2ids.energy_kinetic = markers2ids.E;
markers2ids = rmfield(markers2ids, 'E');
end
if isfield(markers_in, 'R')
markers2ids.r = markers2ids.R;
markers2ids = rmfield(markers2ids, 'R');
end
%% Computing x,y,z coordinates giving phi=0
markers2ids.phi = zeros(size(markers2ids.energy_kinetic));
markers2ids.x = markers2ids.r.*cos(markers2ids.phi);
markers2ids.y = markers2ids.r.*sin(markers2ids.phi);
%% Computing vpara, vperp
%Converting energy to J, if needed
if any(markers2ids.energy_kinetic)>1000
markers2ids.energy_kinetic = markers2ids.energy_kinetic*1.602e-19;
end
markers2ids.velocity = sqrt(2.*markers2ids.energy_kinetic./mass);
markers2ids.velocity_parallel = markers2ids.velocity.*markers2ids.pitch;
markers2ids.velocity_perpendicular = sqrt(markers2ids.velocity.^2-markers2ids.velocity_parallel.^2);
markers2ids.pitch_angle = acos(markers2ids.pitch);
%% Assigning markers into ids structure
ids_distributions.distribution{1}.markers{1} = markers2ids;
end
\ No newline at end of file
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment