Generating Data

RHEOS has several convenience functions for generating arbitrarily complex loading patterns. These may be particularly useful for investigating the responses of viscoelastic models that users may be unfamiliar with.

using RHEOS
using Plots

Step 1: Generate Timeline

The first step requires the generation of a RheoTimeData struct with only the time data. This is achieved with the timeline function. If no parameter is specified, it generates a time data from t_start = 0 to t_end = 10, with a default time step of (t_start-t_end)/250 = 0.04.

datat = timeline(t_start = 0, t_end = 20.0, step = 0.02)
rheotimedatatype(datat)
time_only::TimeDataType = 0
Note

The same functionality is provided to generate a frequency spectrum by using frequencyspec (see an example of its usage in the Fitting and Predicting - Frequency data section).

Step 2: Generate Stress or Strain Data

The user can decide either to generate strain data (strainfunction) or stress data (stressfunction). Both functions require a RheoTimeData with time data defined and a function that takes the time as an input to generate the desired set of data. Both function return a new RheoTimeData struct with time data and either stress or strain data. Below is an example.

# calculates strain data by applying a function of time
dsin = strainfunction(datat, t -> sin(2*t))
# Plot the dsin strain vs time
p = plot(dsin.t, dsin.ϵ,
    size = (800, 200), linewidth=4, framestyle = :box)
# Optional: check the data type or metadata
rheotimedatatype(dsin)
Example block output

Pre-defined Functions

RHEOS provides some functions that can be directly applied to a timeline. Below is the complete list with examples. Note that if the keyword arguments for the functions are not defined, default parameters are used (see the API section). In the examples below the strain data is generated, the same can be applied to the stress by replacing strainfunction with stressfunction.

using Plots

# 2x3 layout
l = @layout [a b c; d e f]
# Initialize the figure
p = plot(layout = l, size = (1400, 700))

# Step generation
dstep = strainfunction(datat, hstep(offset = 5.0, amp = 5))
plot!(p, dstep.t, dstep.ϵ,
      subplot = 1,
      ylim = (-0.1, 5.4),
      title = "Step",
      label = "", linewidth=4, framestyle = :box)

# Ramp generation
dramp = strainfunction(datat, ramp(offset = 2.0, gradient = 0.8))
plot!(p, dramp.t, dramp.ϵ,
      subplot = 2,
      ylim = (-0.1, :auto),
      title = "Ramp",
      label = "", linewidth=4, framestyle = :box)

# Stairs generation
dstairs = strainfunction(datat, stairs(offset = 5.0, amp = 0.1, width = 1))
plot!(p, dstairs.t, dstairs.ϵ,
      subplot = 3,
      ylim = (-0.1, :auto),
      title = "Stairs",
      label = "", linewidth=4, framestyle = :box)

# Square generation
dsquare = strainfunction(datat, square(offset = 5.0, amp = 0.5, period = 4, width = 1))
plot!(p, dsquare.t, dsquare.ϵ,
      subplot = 4,
      ylim = (-0.05, 0.6),
      title = "Square",
      label = "", linewidth=4, framestyle = :box)

# Sawtooth generation
dsawtooth = strainfunction(datat, sawtooth(offset = 5.0, amp = 2, period = 5))
plot!(p, dsawtooth.t, dsawtooth.ϵ,
      subplot = 5,
      ylim = (-0.1, 2.2),
      title = "Sawtooth",
      label = "", linewidth=4, framestyle = :box)

# Triangle generation
dtriangle = strainfunction(datat, triangle(offset = 4.0, amp = 1, period = 4))
plot!(p, dtriangle.t, dtriangle.ϵ,
      subplot = 6,
      ylim = (-0.1, 1.2),
      title = "Triangle",
      label = "", linewidth=4, framestyle = :box)
Example block output

More Complex Patterns

More complicated patterns can be generated by making use of the possibility to add, subtract, multiply RheoTimeData structs. Note that addition and subtraction can be performed only if the data have the same sample rate.

# 1x3 layout
l = @layout [a b c]
# Initialize figure
p = plot(layout = l, size = (1400, 400))

# Ramp & hold
dhold = dramp - strainfunction(datat, ramp(offset = 5.0, gradient = 0.8))
plot!(p, dhold.t, dhold.ϵ,
      subplot = 2,
      ylim = (-0.1, 2.8),
      title = "Ramp & hold",
      label = "", linewidth=4, framestyle = :box)

# Step with oscillatory loading
doscil = dstep + dsquare
plot!(p, doscil.t, doscil.ϵ,
      subplot = 1,
      ylim = (-0.5, 6),
      title = "Oscillations",
      label = "", linewidth=4, framestyle = :box)

# Ramp & hold & oscillation
dcomplex = dhold + dsquare
plot!(p, dcomplex.t, dcomplex.ϵ,
      subplot = 3,
      ylim = (-0.1, 3.2),
      title = "Ramp & hold & oscillations",
      label = "", linewidth=4, framestyle = :box)
Example block output

This page was generated using Literate.jl.