# Wave spectrum input file

It is possible in Ashes to import a custome wave spectrum (see Wave spectrum file). The file defining the wave spectrum contains a table with several wave components. Each component is defined by 4 values:
• the wave period
$$T$$
in seconds
• the wave height
$$H$$
in meters
• the phase angle
$$\epsilon$$
in degrees
• the wave direction
$$\alpha$$
in degrees

If a wave spectrum is composed of
$$N$$
components each noted
$$i$$
, the wave elevation at the origin at time
$$t$$
coming from the North and East directions (see Coordinate systems) will be respectively
$$w_N=\cos(\alpha)\sum\limits_{i=1}^N \frac{H_i}{2}\cos\left(2\pi t/T_i -(\epsilon_i + 90)\right)$$

and
$$w_E=\sin(\alpha)\sum\limits_{i=1}^N \frac{H_i}{2}\cos\left(2\pi t/T_i -(\epsilon_i + 90)\right)$$

To find the wave elevation at different locations, the above equations can be modified by introducing the Wave number as done for Regular waves

## 1 From wave elevation to spectrum file

In the situation where the input is a wave elevation time series rather than a spectrum, this wave elevation must be converted to a spectrum to be read by Ashes. In this example, we assume that the wave direction is always 0 (i.e. the wave always comes from the North).

If the wave elevation is given as a function of time as
$$w(t)$$
with a time step
$$dt$$
and a total number of time steps
$$N+1$$
, a Fourier transform must be applied to obtain the spectrum.
The vector containing the periods for each component will be
$$T=1/f$$

where the components of
$$f$$
are defined as
$$f_i= \frac{i}{N\cdot dt}$$
for
$$i\in\mathbb{N}^*$$

Note that here,
$$T$$
will have
$$N$$
components (because we don't consider the element
$$f_i=0$$
)

The components of the wave height vector
$$H$$
are defined as
$$H_i=\frac{4\cdot \lvert X_i\rvert}{N}$$
for
$$i\in\mathbb{N}^*$$
where
$$X_i$$
is the
$$i^{th}$$
component of the disctrete Fourier transform of
$$w(t)$$
.

The components of the phase angle vector
$$\epsilon$$
are defined as
$$\epsilon_i=-\left(\text{arg}(X_i)\cdot 360/2\pi+90\right)$$

where
$$\text{arg}(z)$$
is the angle of the complex number
$$z$$
.

Note: the above procedure will create as many components as there are time steps in the wave elevation time series (minus one). Often, this will create so many components that the simulation in Ashes will be impractically slow. To solve this isue, it is recommended to remove components that have a very high or very low period. In addition, the resolution of the periods can be decreased to decrease the number of components.