36 lines
1.4 KiB
Matlab
36 lines
1.4 KiB
Matlab
function run_hybrid_worker_wrapper(batchIdx)
|
|
a_s_list = parse_environmental_variable('SCATTERING_LENGTH_RANGE', 85); % Scattering length
|
|
theta_list = parse_environmental_variable('POLAR_ANGLE_RANGE', 0); % Polar angle
|
|
phi_list = parse_environmental_variable('AZIMUTHAL_ANGLE_RANGE', 0); % Azimuthal angle
|
|
N_atoms_list = parse_environmental_variable('NUM_ATOMS_LIST', 90000); % Atom number
|
|
chunkSize = str2double(getenv('CHUNK_SIZE'));
|
|
|
|
% Create full parameter grid (extendable)
|
|
[A, T, P, N] = ndgrid(a_s_list, theta_list, phi_list, N_atoms_list);
|
|
paramGrid = [A(:), T(:), P(:), N(:)];
|
|
totalJobs = size(paramGrid, 1);
|
|
totalBatches = ceil(totalJobs / chunkSize);
|
|
|
|
if batchIdx > totalBatches
|
|
error('Batch index %d exceeds total batches (%d)', batchIdx, totalBatches);
|
|
end
|
|
|
|
firstIdx = (batchIdx - 1) * chunkSize + 1;
|
|
lastIdx = min(batchIdx * chunkSize, totalJobs);
|
|
|
|
% Call worker with this batch of parameters
|
|
batchParams = paramGrid(firstIdx:lastIdx, :);
|
|
Scripts.run_hybrid_worker(batchParams, batchIdx);
|
|
end
|
|
|
|
function vals = parse_environmental_variable(varName, default)
|
|
str = getenv(varName);
|
|
if isempty(str)
|
|
vals = default;
|
|
elseif startsWith(str, '[')
|
|
vals = str2num(str); %#ok<ST2NM>
|
|
else
|
|
vals = eval(str); % Trust only controlled environments
|
|
end
|
|
end
|