%**************************************************************************
%This function sets the program parameters.
%
%Output:
%param, structure containing program parameters
%   output_file_dir     %Directory for output files
%   pm_br               %Remnant field in the blocks (T)
%   pm_dim(3)           %Magnet block dimensions for each block in coordinate system tied to block [w_x, w_y, w_z] (m) 
%   pm_num_x_pos        %Number of x positions (ie. upper blocks) in the magic finger array
%   pm_x_dis            %X distance between the centers of the magnet blocks (m)
%   pm_y_dis(1 : pm_num_x_pos)  %Y distance from each magnet block surface to the midplane (m)
%   pm_z_pos            %Z position of the magnet array (m)
%   pm_m_dir_up(1 : pm_num_x_pos)  %Magnetization direction of the upper blocks, Convention: +x = 1, -x = 2, +y = 3, -y = 4
%   pm_m_dir_lo(1 : pm_num_x_pos)  %Magnetization direction of the lower blocks, Convention: +x = 1, -x = 2, +y = 3, -y = 4
%   pm_div_size         %Permanent magnet segmentation size along each axis for equivalent charges (m)
%   field_pos(n, 3)     %Positions where field is calculated, [x(n), y(n), z(n)] coordinates (m)
%   field_int_pos(n, 2) %Positions where field integrals are calculated, [x(n), y(n)] coordinates (m)
%
%Zachary Wolf, 9/14/10

function [param] = magic_fingers_sim_param()

%Specify the parameter values-----

%Output file information
OUTPUT_FILE_DIR = 'C:\Magdata\Magic Fingers Sim\';

%PM block parameters
PM_BR = 1.2;  %(T)
PM_DIM = [.011000, .017000, .004000];  %(m)
PM_NUM_X_POS = 9; 
PM_X_DIS = .011000;  %(m)
%PM_Y_DIS = [ .009,  .009,  .009,  .009, .009, .009, .009, .009, .009];  %(m)
PM_Y_DIS = [ .005,  .006,  .007,  .008, .009, .010, .011, .012, .013];  %(m)
PM_Z_POS = 0;  %(m)
PM_M_DIR_UP = [3, 3, 3, 3, 3, 3, 3, 3, 3];  %Convention: +x = 1, -x = 2, +y = 3, -y = 4
PM_M_DIR_LO = [3, 3, 3, 3, 3, 3, 3, 3, 3];  %Convention: +x = 1, -x = 2, +y = 3, -y = 4
PM_DIV_SIZE = .0005;  %(m)

%Positions where field is calculated
%FIELD_POS_X = 0;
FIELD_POS_X = -0.06 : .002 : 0.06;
FIELD_POS_Y = 0;
FIELD_POS_Z = -.1 : .0002 : .1;

%Positions where field integrals are calculated
FIELD_INT_POS_X = -0.04 : .001 : 0.04;
FIELD_INT_POS_Y = 0;

%Put the field points into an array
FIELD_POS = zeros(length(FIELD_POS_X) * length(FIELD_POS_Y) * length(FIELD_POS_Z), 3);
index = 0;
for ii = 1 : length(FIELD_POS_X)
    for jj = 1 : length(FIELD_POS_Y)
        for kk = 1 : length(FIELD_POS_Z)
            index = index + 1;
            FIELD_POS(index, :) = [FIELD_POS_X(ii), FIELD_POS_Y(jj), FIELD_POS_Z(kk)];
        end
    end
end

%Put the field integral points into an array
FIELD_INT_POS = zeros(length(FIELD_INT_POS_X) * length(FIELD_INT_POS_Y), 2);
index = 0;
for ii = 1 : length(FIELD_INT_POS_X)
    for jj = 1 : length(FIELD_INT_POS_Y)
        index = index + 1;
        FIELD_INT_POS(index, :) = [FIELD_INT_POS_X(ii), FIELD_INT_POS_Y(jj)];
    end
end

%Put the parameters in the param structure-----

%Program parameters
param.output_file_dir = OUTPUT_FILE_DIR;
param.pm_br = PM_BR;
param.pm_dim = PM_DIM;
param.pm_num_x_pos = PM_NUM_X_POS;
param.pm_x_dis = PM_X_DIS;
param.pm_y_dis = PM_Y_DIS;
param.pm_z_pos = PM_Z_POS;
param.pm_m_dir_up = PM_M_DIR_UP;
param.pm_m_dir_lo = PM_M_DIR_LO;
param.pm_div_size = PM_DIV_SIZE;
param.field_pos = FIELD_POS;
param.field_int_pos = FIELD_INT_POS;

%Done
end

