function []=SDOFDynamicAnalysis(OSpath,ACCdata)

% function []=SDOFDynamicAnalysis(OSpath,ACCdata)
% function SDOFDynamicAnalysis creates an input code for SDOF dynamic analyses of the SDOF model,
% which has to be previously created 
% 
%
% INPUT:
%   - OSPath=is a path and exe file of OpenSees
%            for example: 'D:\opensees162\opensees.exe'
%  - ACCdata is a structure containing following field
%    name= {'acc file name'}
%    path= {'acc path'}, e.g. 'D:/SDOF/acc/' (!!! tcl notation)
%    dt  = time step in the acc file
%    sf  = scale factor for accelerogram
%    tFinal = time of the acc signal
%
%  !!!OpenSees runs through RunSDOFDA.bat, which employes RunSDOFDA.tcl
%
% OUTPUT:
%    - files: TDsdof.out ...global result for SDOF dynamic analysis
%             EFsdof.out EDsdof.out - envelopes
%             Fsdof.out Dsdof.out   - time history
%
%
% Referenced manuscripts:
%
% Dolsek M. (2010). Development of computing environment for the seismic
% performance assessment of reinforced concrete frames by using simplified
% nonlinear models. Bulletin of Earthquake Engineering (Published online
% 16 May 2010), DOI: 10.1007/s10518-010-9184-8. 
%
% Contact: mdolsek@ikpir.fgg.uni-lj.si
%
% Copyright (C) 2010 Matjaz Dolsek
%
% This program is free software; you can redistribute it and/or
% modify it under the terms of the GNU General Public License
% as published by the Free Software Foundation, version 2.
% This program is distributed in the hope that it will be useful,
% but WITHOUT ANY WARRANTY; without even the implied warranty of
% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
% GNU General Public License for more details.


accName=ACCdata.name;
accdt=ACCdata.dt;
sf=ACCdata.sf;
tFinal=ACCdata.tFinal;

file=fopen('SDOFdynamic.tcl', 'w+');
   fprintf(file,'set tFinal %15.6e \n',tFinal);
   fprintf(file,'set accX "Path -filePath %s -dt %15.3e -factor %15.3e" \n', accName, accdt, sf);
   fprintf(file,'# Define the ground motion excitation \n');
   %                                      tag dir   accel series 
   fprintf(file,'pattern UniformExcitation  1   1  -accel $accX \n');
   
fclose(file);
   
    
file = fopen('RunSDOFDA.tcl', 'w+');
    fprintf(file,'source SDOF.tcl \n');
    fprintf(file,'source SDOFdynamic.tcl \n');
    fprintf(file,'source DynamicAnalysis1.tcl \n');
    fprintf(file,'wipe \n');
fclose(file);
        
file = fopen('RunSDOFDA.bat', 'w+');
    fprintf(file,'"%s"  RunSDOFDA.tcl',OSpath);
fclose(file);
    
%disp(' ------------------------------------------')
%disp([' ---- Performing Dynamic analysis ' num2str(a(i)) ' ----'])
%disp(' ------------------------------------------')
eval('!RunSDOFDA.bat');
%pause(0.1);
    

        
        
