function Basal_StepLim = StepLimBasal(ScriptVar, x, y, particle_index)
    % Outputs basal StepLim value determined from init_final_StepLim
    % Output -
    %    Basal_StepLim - basal StepLim value free of sensing-induced
    %                    effects, viscous zone-induced effects etc.
    % 
    % Inputs - 
    %    ScriptVar - Parameters container map
    %    x - x-coordinate of the particle
    %    y - y-coordinate of the particle (not used here as viscous gradient 
    %        generated only along x for simplicity
    %    particle_index - particle index (ranging from 1 to total number of
    %        particles)
    
    Total_Particles = size(x,1);
    number_of_cusps = ScriptVar('number_of_cusps');
    init_final_StepLim = ScriptVar('init_final_StepLim');
    
    if number_of_cusps == 0 && init_final_StepLim(1) ~= init_final_StepLim(2)
        error('Error. The number of cusps is zero but init_final_StepLim(1) is not equal to init_final_StepLim(2). A gradient is requested without specifying the number of cusps in the transition from low StepLim to high StepLim.')
    end
    if (number_of_cusps == 0 || init_final_StepLim(1) == init_final_StepLim(2))...
            && strcmpi(ScriptVar('StepLim_functional_form'),'stepwise')
        error('Error. Set StepLim_functional_form to "default" if no gradient is desired.but init_final_StepLim(1) is not equal to init_final_StepLim(2).')
    end
    
    if init_final_StepLim(1) ~= init_final_StepLim(2) % Viscosity gradient case
        Basal_StepLim = StepLimFunction(x, number_of_cusps,...
            init_final_StepLim, ScriptVar('xLimit'),...
            ScriptVar('StepLim_functional_form'));
    else % Uniform basal viscosity (but there may exist explicitly defined viscous zones)
        Basal_StepLim = init_final_StepLim(1)*ones(Total_Particles,1);
    end
    
    ParticleType = ParticleTypeCalculator(ScriptVar, particle_index);
    MobilityForEachParticleType = ScriptVar('MobilityForEachParticleType'); 
    Basal_StepLim = Basal_StepLim.*MobilityForEachParticleType(ParticleType)';
end
