%function to assign boundary constraints in Opensees
%fix $nodeTag (ndf $constrValues)
function []=assign_boundary_constraints(n_storeys,n_baysX,n_baysY)
fid1=fopen('boundary_constraints.tcl','wt');

%fix all nodes at ground floor
fprintf(fid1, '%s\n', '# ground floor nodes --------------------------------------------------');
for fixed_node_list=1:(n_baysX+1)*(n_baysY+1);
    fprintf(fid1, '%s ', 'fix');
    fprintf(fid1, '%u ',  fixed_node_list);
    fprintf(fid1, '%s ',  '1 1 1 1 1 1');
    fprintf(fid1, '\n');
end
%fix all master nodes
fprintf(fid1, '%s\n', '# master nodes --------------------------------------------------');
for i_storey=1:n_storeys
    master_node=i_storey*100000;
    fprintf(fid1, '%s ', 'fix');
    fprintf(fid1, '%u ',  master_node);
    fprintf(fid1, '%s ',  '0 0 1 1 1 0');
    fprintf(fid1, '\n');
end

fprintf(fid1, '%s\n', '# --------------------------------------------------');

fclose(fid1);
