An artificial accelerogram generator code written in Matlab

Artificial accelerograms are a very useful tool for designing structures against seismic hazards; in particular, when structures exhibit nonlinear behavior. This paper presents a Matlab code for generating artificial accelerograms to match code‐defined spectra based on the modification of actual earthquake ground motions. In this case, while the code is written to generate Eurocode 8‐compatible accelerograms, it can be easily adapted to any other code in the world. The proposed code determines the earthquake spectra and Fourier Transform using the Fast Fourier Transform algorithm and then modifies the Fourier Transform in order to match the predefined spectra. The code also includes instructions for outlining different actual ground motions, soil, and earthquake type. The code is geared to students and researchers in the field of Structural and Earthquake Engineering. The objective of this work is to provide a Matlab code that can be integrated in other research programs such as seismic structural analysis, structural control software, or other codes.

To this date, several methods have been proposed in literature to generate spectrum-compatible accelerograms. [5][6][7][8] Most of the methods use a combination of two distinct approaches, in particular the modification of actual ground motions to match the design spectrum and the generation of synthetic artificial accelerograms. The deterministic method uses a superposition of different harmonic signals resulting in a nonstationary signal. 23 Wavelet-based methods modify the recorded motions to compatible response ground motions. 32,34,40,48,[51][52][53]58,62 The stochastic approach considers the accelerogram as a Gaussian process, and was first proposed by Vanmarcke and Gaparini 56 who illustrated the relation between the response spectrum and the power density function. From this relationship, several authors proposed power spectral density modification algorithms to generate spectrum-compatible ground motions. 24,25,29,36,[41][42][43]53,55 Artificial intelligence methods such as neural networks have also been employed. 31,37 Publication of codes can be considered an important step. The sharing of tools with the research community allows different authors to change, test, and learn from a particular code. For example, Andreassen et al. (2011) have shared a Matlab topology optimization code. 65 This step has allowed multiple types of research to learn the basis of topology optimization, test and compare the code and also implement in their own programs.
To generate artificial accelerograms, there are also other available programs, such as SIMQKE, but most require a payment and they are not directly integrated in Matlab.
In this paper, a simple code to generate spectrum-compatible accelerogram is presented, based on the modification of actual ground motions. The objective of this work is to provide the research community with an efficient tool that can easily be integrated in Matlab and other software programs and routines, such as seismic response of nonlinear, active, and semi-active controlled structures. The proposed code determines the initial response spectrum and Fourier transform and changes the Fourier transform based on the difference between the response spectra and the code-defined spectra.
The Matlab code presented in this work is available in the following repository: https://github.com/FLSFerreira/ Artificial-Accelerogram-Generator.

Differential equation solver
The response spectrum is defined as the peak response of a single degree-of-freedom structure with different natural frequencies for a specified damping coefficient subject to a given ground accelerogramü g (t). The response spectra are computed using the auxiliary function [S] = ARS(accelerogram,z,T,dt) for each individual accelerogram (Matlab code lines 168-206). To determine the response spectra, the following steps need to be performed: • Specify the natural period range P to be analyzed and determine the corresponding natural angular frequencies ( = 2 /P); • For all frequencies within the range, solve the dynamic differential equation (Equation 1) in the time domain (t).
• The acceleration response spectra are then defined as the maximum structural response for the given accelerogram and for each period S a (P) = Max|ü(t)| (Matlab code line 204).
The acceleration response spectra are the most commonly used for structural design and, for this reason, will be used in this work.
Other types of response spectra could also be used, such as (line 204): • The displacement response spectra S d (P) = Max[abs(u(t))]; • The velocity response spectra S v (P) = Max[abs(u(t))].
where u(t) is the time-dependent structural displacement.
Considering the state space formulation using the vector x defined as x = , the second-order equation (Equation (1)) is replaced with a first order:̇x The matrices A and B are defined by (lines 186-189): .
where I is the identity matrix.
The dynamic equation has an analytical solution for a given time step t.

Code-defined response spectra
In this work, the Eurocode 8 1 (EC8) horizontal elastic spectra for different soil and earthquake types are considered, as defined in section 3.2.2.2. The elastic spectra are computed using the auxiliary function [S_elastic] = EC8elasticspectra(soil,type,z,ag) (lines .
In this case, the elastic spectra depend on: • The variable soil, which assigns the number 1 to 5 to the ground type A to E according to EC8- Table 3.1: ⚬ Ground type A corresponds to rock or other rock-type geological formation; ⚬ Ground type B corresponds to deposits of very dense sand, gravel, or very stiff clay; ⚬ Ground type C corresponds to deep deposits of dense or medium-dense sand, gravel, or stiff clay; ⚬ Ground type D corresponds to deposits of loose-to-medium cohesionless soil; ⚬ Ground type E corresponds to a soil profile consisting of a surface alluvium layer.
• The Earthquake type, which is divided in type 1 for far-field Earthquake and type 2 for near-field Earthquake.
• The variable z, which is equal to the structural damping . The EC8 defines as a usual practice to generate artificial earthquakes to match the 5% viscous damping elastic response spectra ( = 5%).
• The design ground acceleration on type A ground a g .
Nonetheless, the code can be easily adapted to use a different design spectrum. In order to do that, it is necessary to change line 22 to a different user-defined function or a manually defined spectrum. This means that the code can be easily adapted to any other national or user-defined standard.

Original ground motions accelerogram and response spectra
The original ground motions used are the El Centro (California, 1940), Gebze (Turkey, 1999) and Mexico City (Mexico, 1985) earthquakes ( Figure 1). These events are substantially different and they are very often used in Earthquake Engineering, for example, in benchmark studies for controlling the seismic response of structures. 3 Figure 2 represents the response spectra of the different original ground motions. In order to better compare the results, the motions were scaled so that the peak ground acceleration (PGA) = 3 m/s 2 .

Algorithm fundamentals
The generation of an artificial accelerogram to match code-defined spectra (either based on the modification of real or synthetic accelerograms) can be stated as an optimization problem in which the response spectra are to be matched as close as possible to the defined spectra. In order to solve the problem, it is representative to use the Fourier Transform in order to have the frequency content of the signal. The Fourier TransformÜ g ( ) of the time history functionü g (t) is defined as: The response spectra in a given frequency (or period P) can be stated as being proportional to the power a of the Fourier Transform value at the same frequency. The value of k and are heavily dependent on the type of earthquake: For very high frequencies, the response spectra converge to the value of the PGA: The transformation of the original ground motion into a response spectra-matched motion is described in the following lines and is performed using function[Final_accelerogram,Sa] = F_AAG(original_accel,N_iter,Sa_elastic,T,z,ag) (lines 74- 166). This function uses the following steps: 1. The original motion to be matched, the number of iterations, the intended response spectra and the damping are defined as input variables; 2. The original motion is scaled so that the PGA matches the product of the intended response spectra to a user-defined scale factor sfac (lines 92-93). This is an important step to have a good initial approximation of the matched spectra, as the actual motion intensity can be quite different than the code-defined spectra and would, thus, require a higher number of iterations to converge. A scale factor sfac = 1 is predefined, but in some cases the user may need to change this value in order to influence the matched motion peak ground acceleration; 3. The scaled original response spectra (line [105][106][107][108][109][110]  The Arias Intensity 66 of the accelerograms can also be computed using the following lines: 208 %IA=pi()/(2*9.8)*(sum(art_sign(2:end,:)'.^2)')*art_sign(1,2); In the next section, the effect of one iteration of the proposed algorithm will be determined and analyzed.

One iteration example
In this section, a single iteration example is shown for soil type A and earthquake type for a 3 m/s 2 PGA. To achieve this, it is necessary to make the change in variable N_it in line 17 to N_it = 1 in order to obtain the original scaled motion and then N_it = 2 to obtain the one iteration matched motion. The program can then be run by typing [art_sign,art_spec,Sa] = AAG(1,1,1,3). The change in the response spectra is shown in Figure 3 and the modification of the accelerograms is shown in Figures 4-6: The results show that the algorithm is efficient in matching the ground motion to the code response spectra while maintaining the earthquake shape. This was considered to be a very important aspect, as the objective of this code was to obtain earthquake-like artificial accelerograms. It is considered that such type of accelerograms can better simulate the effect of an actual event while simultaneously respecting the design response spectra than other types of synthetic accelerograms.

RESULTS
In this section, the results will be shown for a soil A type 1 (A-1) and 2 (A-2) matched accelerograms.     iterations, the spectra are close to the design spectra. It can also be seen that the algorithm can be used to generate both far-and near-field-matched spectra.
For long periods, the Gebze accelerogram does not converge to the design spectra. This means that, for long-period structures (typically high-rise buildings and long-span bridges), this event should not be used as an original input. This happens because of the existence of a high-period pulse near the 5 seconds instant. Both the El Centro and the Mexico City converge to the design spectra using the proposed algorithm.
The results show that the algorithm reaches a matched accelerogram while simultaneously maintaining the similarity to a real event. This is considered to be an important issue for earthquake structural design.

CONCLUSIONS AND FINAL REMARKS
In this paper; an artificial accelerogram generator code written in Matlab is presented. This code is published in order to provide a user-friendly tool for research and educational purposes. The proposed code is made in such a way as to allow users to perform changes to match their needs, and to be easily integrated in other Matlab programs.
While the code was prepared to generate European code (Eurocode 8) design spectra, it can be easily adapted to any match any other intended design spectra.
The original motions were considered to be the El Centro, Gebze, and Mexico City Earthquakes; nonetheless, the program is prepared to allow the user to define any other accelerograms.
The objective of this work was to arrive at a simple tool for artificial accelerogram generation. The results show that the matched accelerograms are very close to the design spectra, with the exception of the "Gebze" accelerogram in the long-period range. It can be seen that the code works well for both near-and far-field (types 1 and 2) earthquakes.
The program needs less than 1 minute in a home computer with an "Intel i7" processor to generate a set of three artificial accelerograms.

DATA AVAILABILITY
The MATLAB code used in this study is openly available in the Data S1 and S2 and also in the following repository: https:// github.com/FLSFerreira/Artificial-Accelerogram-Generator.

CONFLICT OF INTEREST
Authors have no conflict of interest relevant to this article.

AUTHOR CONTRIBUTIONS
C.M. contributed to supervision. Á.C. contributed to supervision. E.C. contributed to supervision.