%**************************************************************************
%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_x_nom_pos(1 : num_blocks)  %Nominal x positions of the blocks (m)
%   pm_y_nom_pos(1 : num_blocks)  %Nominal y positions of the blocks (m)
%   pm_z_nom_pos(1 : num_blocks)  %Nominal z positions of the blocks (m)
%   pm_m_dir(1 : num_blocks)      %Magnetization direction of the blocks, Convention: +x = 1, -x = 2, +y = 3, -y = 4, +z = 5, -z = 6
%   pm_div_size         %Permanent magnet segmentation size along each axis for equivalent charges (m)
%   shim_x_shift(1 : num_blocks)  %Virtual shim x shift (m)
%   shim_y_shift(1 : num_blocks)  %Virtual shim y shift (m)
%   shim_z_shift(1 : num_blocks)  %Virtual shim z shift (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, 2/4/11

function [param] = virtual_shim_sim_param()

%Specify the parameter values-----

%Output file information
OUTPUT_FILE_DIR = 'C:\Magdata\Virtual Shim Sim\';

%Parameters for internal use
PM_V_GAP = .0068;  %(m)

%PM block parameters
PM_BR = 1.2;  %(T)
PM_DIM = [.030000, .050000, .007000];  %(m)
PM_X_NOM_POS = [0, 0];  %(m)
PM_Y_NOM_POS = [PM_V_GAP / 2 + PM_DIM(2) / 2, -PM_V_GAP / 2 - PM_DIM(2) / 2];  %(m)
PM_Z_NOM_POS = [0, 0];  %(m)
PM_M_DIR = [3, 3];  %Convention: +x = 1, -x = 2, +y = 3, -y = 4, +z = 5, -z = 6
PM_DIV_SIZE = .0005;  %(m)

%Virtual shim motion
%SHIM_X_SHIFT = [0, 0];  %(m)
SHIM_X_SHIFT = [.0005, -.0005];  %(m)
SHIM_Y_SHIFT = [0, 0];  %(m)
%SHIM_Y_SHIFT = [.0005, -.0005];  %(m)
SHIM_Z_SHIFT = [0, 0];  %(m)

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

%Positions where field integrals are calculated
FIELD_INT_POS_X = 0;
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_x_nom_pos = PM_X_NOM_POS;
param.pm_y_nom_pos = PM_Y_NOM_POS;
param.pm_z_nom_pos = PM_Z_NOM_POS;
param.pm_m_dir = PM_M_DIR;
param.pm_div_size = PM_DIV_SIZE;
param.shim_x_shift = SHIM_X_SHIFT;
param.shim_y_shift = SHIM_Y_SHIFT;
param.shim_z_shift = SHIM_Z_SHIFT;
param.field_pos = FIELD_POS;
param.field_int_pos = FIELD_INT_POS;

%Done
end

