Example 8: RVT SRA with simulated profiles

Use RVT with simulated profiles to compute the surface response spectrum and surface spectral ratio.


In [1]:
import matplotlib.pyplot as plt
import numpy as np

import pysra

%matplotlib inline

In [2]:
# Increased figure sizes
plt.rcParams['figure.dpi'] = 120

Create a point source theory RVT motion


In [3]:
m = pysra.motion.SourceTheoryRvtMotion(6.0, 30, 'wna')
m.calc_fourier_amps()

Create site profile

This is about the simplest profile that we can create. Linear-elastic soil and rock.


In [4]:
profile = pysra.site.Profile([
    pysra.site.Layer(
        pysra.site.DarendeliSoilType(
            18., plas_index=0, ocr=1, stress_mean=100), 10, 400),
    pysra.site.Layer(
        pysra.site.DarendeliSoilType(
            18., plas_index=0, ocr=1, stress_mean=200), 10, 450),
    pysra.site.Layer(
        pysra.site.DarendeliSoilType(
            18., plas_index=0, ocr=1, stress_mean=400), 30, 600),
    pysra.site.Layer(
        pysra.site.SoilType('Rock', 24., None, 0.01), 0, 1200),
])

Create the site response calculator


In [5]:
calc = pysra.propagation.EquivalentLinearCalculator()

Initialize the variations


In [6]:
var_thickness = pysra.variation.ToroThicknessVariation()
var_velocity = pysra.variation.ToroVelocityVariation.generic_model(
    'USGS C')
var_soiltypes = pysra.variation.SpidVariation(
    -0.5, std_mod_reduc=0.15, std_damping=0.30)

Specify the output


In [7]:
freqs = np.logspace(-1, 2, num=500)

outputs = pysra.output.OutputCollection([
    pysra.output.ResponseSpectrumOutput(
        # Frequency
        freqs,
        # Location of the output
        pysra.output.OutputLocation('outcrop', index=0),
        # Damping
        0.05),
    pysra.output.ResponseSpectrumRatioOutput(
        # Frequency
        freqs,
        # Location in (denominator),
        pysra.output.OutputLocation('outcrop', index=-1),
        # Location out (numerator)
        pysra.output.OutputLocation('outcrop', index=0),
        # Damping
        0.05),
    pysra.output.InitialVelProfile(),
])

Perform the calculation


In [8]:
count = 100
for p in pysra.variation.iter_varied_profiles(
        profile,
        count,
        var_thickness=var_thickness,
        var_velocity=var_velocity,
        var_soiltypes=var_soiltypes
):
    # Here we auto-descretize the profile for wave propagation purposes
    calc(m, p.auto_discretize(), p.location('outcrop', index=-1))
    outputs(calc)

Plot the outputs

Create a few plots of the output.


In [9]:
for o in outputs[:-1]:
    fig, ax = o.plot()
    fig;



In [10]:
fig, ax = outputs[-1].plot()


The statistics of the output can be also retrieved and returned as either a dict or pandas.DataFrame.


In [11]:
outputs[-1].calc_stats()


Out[11]:
{'ref': array([ 0.        ,  1.07142857,  2.14285714,  3.21428571,  4.28571429,
         5.35714286,  6.42857143,  7.5       ,  8.57142857,  9.64285714,
        10.71428571, 11.78571429, 12.85714286, 13.92857143, 15.        ,
        16.07142857, 17.14285714, 18.21428571, 19.28571429, 20.35714286,
        21.42857143, 22.5       , 23.57142857, 24.64285714, 25.71428571,
        26.78571429, 27.85714286, 28.92857143, 30.        , 31.07142857,
        32.14285714, 33.21428571, 34.28571429, 35.35714286, 36.42857143,
        37.5       , 38.57142857, 39.64285714, 40.71428571, 41.78571429,
        42.85714286, 43.92857143, 45.        , 46.07142857, 47.14285714,
        48.21428571, 49.28571429, 50.35714286, 51.42857143, 52.5       ]),
 'median': array([417.9310817 , 414.27052043, 412.32399419, 405.25051412,
        410.73823098, 423.58051114, 442.29454284, 444.54657675,
        448.54922019, 448.07340295, 455.16748021, 465.75606651,
        466.2669632 , 463.57456193, 472.03148223, 478.21860403,
        483.21798312, 478.86765281, 477.61330731, 485.68884479,
        500.66073807, 513.52729768, 525.21571098, 535.94823578,
        548.34140884, 560.29304868, 565.61987409, 577.41451312,
        583.52002023, 594.50858518, 594.52710291, 585.64369543,
        597.8357957 , 599.26342455, 608.93607414, 613.92975771,
        616.34235034, 615.94760612, 620.1784423 , 628.44837076,
        639.69597714, 641.22619431, 632.34049722, 628.2232154 ,
        631.41759556, 637.42307538, 625.34530655, 638.85739641,
        638.85739641, 638.85739641]),
 'ln_std': array([0.37510992, 0.38520561, 0.37959912, 0.35724687, 0.34933644,
        0.36036144, 0.32624444, 0.3136515 , 0.32342713, 0.32283142,
        0.30814987, 0.31768373, 0.31824017, 0.30026949, 0.30294925,
        0.30959605, 0.31350893, 0.33258522, 0.33771357, 0.34795791,
        0.33410469, 0.32988551, 0.33634861, 0.33287508, 0.34330597,
        0.34654965, 0.35772176, 0.36294413, 0.36347814, 0.35484969,
        0.36726454, 0.35682444, 0.36260775, 0.36157457, 0.34882536,
        0.34321398, 0.33412641, 0.33543477, 0.33859174, 0.3407841 ,
        0.3432658 , 0.33358834, 0.33302963, 0.33969815, 0.35203934,
        0.35197619, 0.36512466, 0.35983386, 0.35983386, 0.35983386])}

In [12]:
outputs[-1].calc_stats(as_dataframe=True)


Out[12]:
median ln_std
depth
0.000000 417.931082 0.375110
1.071429 414.270520 0.385206
2.142857 412.323994 0.379599
3.214286 405.250514 0.357247
4.285714 410.738231 0.349336
5.357143 423.580511 0.360361
6.428571 442.294543 0.326244
7.500000 444.546577 0.313651
8.571429 448.549220 0.323427
9.642857 448.073403 0.322831
10.714286 455.167480 0.308150
11.785714 465.756067 0.317684
12.857143 466.266963 0.318240
13.928571 463.574562 0.300269
15.000000 472.031482 0.302949
16.071429 478.218604 0.309596
17.142857 483.217983 0.313509
18.214286 478.867653 0.332585
19.285714 477.613307 0.337714
20.357143 485.688845 0.347958
21.428571 500.660738 0.334105
22.500000 513.527298 0.329886
23.571429 525.215711 0.336349
24.642857 535.948236 0.332875
25.714286 548.341409 0.343306
26.785714 560.293049 0.346550
27.857143 565.619874 0.357722
28.928571 577.414513 0.362944
30.000000 583.520020 0.363478
31.071429 594.508585 0.354850
32.142857 594.527103 0.367265
33.214286 585.643695 0.356824
34.285714 597.835796 0.362608
35.357143 599.263425 0.361575
36.428571 608.936074 0.348825
37.500000 613.929758 0.343214
38.571429 616.342350 0.334126
39.642857 615.947606 0.335435
40.714286 620.178442 0.338592
41.785714 628.448371 0.340784
42.857143 639.695977 0.343266
43.928571 641.226194 0.333588
45.000000 632.340497 0.333030
46.071429 628.223215 0.339698
47.142857 631.417596 0.352039
48.214286 637.423075 0.351976
49.285714 625.345307 0.365125
50.357143 638.857396 0.359834
51.428571 638.857396 0.359834
52.500000 638.857396 0.359834

Repeat using a Generic Depth-Dependent Model

The generic DepthDependToroVelVariation follows the SPID guidance.


In [13]:
var_velocity_dd = pysra.variation\
    .DepthDependToroVelVariation.generic_model('USGS C')

In [14]:
outputs.reset()
count = 100
for p in pysra.variation.iter_varied_profiles(
        profile,
        count,
        var_thickness=var_thickness,
        var_velocity=var_velocity_dd,
        var_soiltypes=var_soiltypes
):
    calc(m, p.auto_discretize(), p.location('outcrop', index=-1))
    outputs(calc)

In [15]:
for o in outputs[:-1]:
    fig, ax = o.plot()
    fig;



In [16]:
fig, ax = outputs[-1].plot()



In [17]:
outputs[-1].calc_stats(as_dataframe=True)


Out[17]:
median ln_std
depth
0.000000 418.575749 0.252607
1.071429 418.026180 0.253072
2.142857 409.008632 0.253055
3.214286 410.803292 0.233577
4.285714 413.188743 0.253766
5.357143 407.465185 0.252817
6.428571 406.840064 0.238472
7.500000 402.977114 0.243989
8.571429 403.376441 0.236609
9.642857 408.858823 0.230865
10.714286 415.999906 0.236244
11.785714 429.631509 0.239082
12.857143 440.409691 0.233621
13.928571 442.761726 0.227753
15.000000 442.971772 0.227625
16.071429 450.530683 0.231272
17.142857 461.354735 0.235841
18.214286 472.772855 0.225270
19.285714 478.488322 0.229755
20.357143 492.814764 0.227189
21.428571 513.943558 0.223589
22.500000 527.998956 0.224955
23.571429 539.411543 0.221632
24.642857 549.003561 0.207502
25.714286 560.329790 0.202284
26.785714 564.664216 0.197745
27.857143 573.630796 0.189688
28.928571 577.270493 0.189856
30.000000 583.110321 0.171864
31.071429 584.848488 0.173711
32.142857 588.793574 0.178256
33.214286 593.794454 0.168932
34.285714 598.162055 0.166938
35.357143 597.087938 0.164521
36.428571 600.476092 0.163454
37.500000 599.010367 0.164143
38.571429 599.484698 0.164669
39.642857 600.770605 0.158790
40.714286 596.361306 0.163009
41.785714 597.399244 0.163927
42.857143 597.932611 0.163175
43.928571 594.077391 0.162832
45.000000 594.677547 0.166859
46.071429 597.985008 0.169849
47.142857 599.178930 0.169171
48.214286 598.545731 0.169751
49.285714 595.887030 0.166950
50.357143 594.784471 0.163392
51.428571 594.784471 0.163392
52.500000 594.784471 0.163392

Repeat using a Specific Depth-Dependent Model


In [18]:
var_velocity_dd = pysra.variation\
    .DepthDependToroVelVariation.generic_model(
    'USGS C',
    depth=[0, 10, 20],
    ln_std=[0.25, 0.15, 0.10]
)

In [19]:
outputs.reset()
count = 100
for p in pysra.variation.iter_varied_profiles(
        profile,
        count,
        var_thickness=var_thickness,
        var_velocity=var_velocity_dd,
        var_soiltypes=var_soiltypes
):
    calc(m, p.auto_discretize(), p.location('outcrop', index=-1))
    outputs(calc)

In [20]:
for o in outputs[:-1]:
    fig, ax = o.plot()
    fig;



In [21]:
fig, ax = outputs[-1].plot()



In [22]:
outputs[-1].calc_stats(as_dataframe=True)


Out[22]:
median ln_std
depth
0.000000 402.755645 0.247651
1.071429 405.005702 0.245355
2.142857 404.266704 0.245877
3.214286 412.673325 0.239067
4.285714 411.889352 0.225014
5.357143 411.497989 0.216826
6.428571 415.271640 0.205612
7.500000 416.639421 0.210335
8.571429 422.622216 0.203270
9.642857 427.877025 0.207474
10.714286 430.736013 0.194814
11.785714 441.252448 0.196724
12.857143 449.568435 0.201093
13.928571 454.738947 0.202623
15.000000 466.237969 0.203880
16.071429 481.122132 0.197062
17.142857 488.374615 0.201764
18.214286 505.954800 0.201137
19.285714 510.140598 0.198288
20.357143 526.399638 0.185648
21.428571 542.739414 0.180373
22.500000 557.202602 0.175129
23.571429 564.719575 0.164998
24.642857 574.151842 0.150044
25.714286 573.682182 0.147964
26.785714 580.728189 0.147209
27.857143 584.428080 0.138950
28.928571 592.880195 0.129523
30.000000 597.293825 0.120936
31.071429 601.729702 0.112477
32.142857 603.807699 0.110132
33.214286 602.725161 0.112093
34.285714 600.750016 0.109508
35.357143 604.443491 0.106085
36.428571 602.155250 0.105335
37.500000 606.820384 0.110143
38.571429 606.278637 0.110388
39.642857 606.998626 0.110880
40.714286 608.399624 0.108368
41.785714 607.539875 0.110765
42.857143 607.319562 0.112058
43.928571 607.620255 0.114491
45.000000 605.822008 0.117062
46.071429 609.084631 0.116223
47.142857 607.674355 0.116180
48.214286 607.447928 0.113537
49.285714 607.849956 0.110272
50.357143 608.943772 0.113264
51.428571 608.943772 0.113264
52.500000 608.943772 0.113264

In [ ]: