Bilin

[1]:
import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
import seaborn as sns
sns.set_style("whitegrid")
import ipywidgets as widgets
from ipywidgets import interact, interactive, fixed, interact_manual

from streng.tools.bilin import Bilin
[2]:
bl = Bilin(xtarget=0.35)

bl.curve_ini.load_delimited(r'D:/Programming/PyMyPackages/pystreng/tests/bilin/Example4', ' ')
# bl.load_space_delimited(r'D:/MyBooks/TEI/RepairsExample/sapfiles/fema/PushoverCurve_modal.txt', ' ')
bl.calc()

f, ax = plt.subplots(figsize=(8, 5))
ax.plot(bl.curve_ini.x, bl.curve_ini.y, label="Initial Curve", lw=2)
ax.plot(bl.bilinear_curve.d_array, bl.bilinear_curve.a_array, label="Bilinear Curve", lw=2)
ax.set_title('Διγραμμικοποίηση καμπύλης αντίστασης')
ax.set_ylabel('V (kN)')
ax.set_xlabel('δ (m)')
ax.legend()
fig = (f, ax)
plt.show()
../../_images/jupyters_tools_bilin_2_0.png
[3]:
print(bl.bilinear_curve.all_quantities)
| quantity   |     value |
|:-----------|----------:|
| x_0        | 2.140E-02 |
| x_y        | 7.275E-02 |
| x_u        | 3.500E-01 |
| y_0        | 0.000E+00 |
| y_y        | 1.279E+03 |
| y_u        | 1.434E+03 |
| kel        | 2.490E+04 |
| kinel      | 5.618E+02 |
| μ          | 6.400E+00 |
| α          | 2.256E-02 |
[4]:
bl.bilinear_curve.all_quantities.retrieve('quantity', 'x_u', 'value')
[4]:
0.35
[5]:
def f(x):
    bl = Bilin(xtarget=x/1000., dropstrength=0.6)

    bl.curve_ini.load_delimited(r'D:/Programming/PyMyPackages/pystreng/tests/bilin/Example4', ' ')
    bl.calc()

    plt.plot(bl.curve_ini.x, bl.curve_ini.y)
    plt.plot(bl.bilinear_curve.d_array, bl.bilinear_curve.a_array)
    plt.show()
    return x

interact(f, x=widgets.IntSlider(min=50,max=600,step=1,value=200));
[6]:
def f_str(x):
    if len(x)>0:
        bl = Bilin()
        bl.curve_ini.load_space_delimited_string(x)
        bl.calc()

        plt.plot(bl.curve_ini.x, bl.curve_ini.y)
        plt.plot(bl.bilinear_curve.d_array, bl.bilinear_curve.a_array)
        plt.show()

interact(f_str, x=widgets.Textarea(
    placeholder='Paste space delimited x-y values:',
    description='Initial curve',
    disabled=False));
[7]:
print(bl)
Bilin main output

Αρχική μετατόπιση: 0.0214

Έλεγχος στο 20% του ymax
x(02)=0.009792445820433439, y(02)=303.416. Οπότε k(02)=30984.70040721349

Εμβαδό καμπύλης: 408.94865204545454
[8]:
print(bl.output.outputStrings['main'])
# print(bl.output)
Bilin main output

Αρχική μετατόπιση: 0.0214

Έλεγχος στο 20% του ymax
x(02)=0.009792445820433439, y(02)=303.416. Οπότε k(02)=30984.70040721349

Εμβαδό καμπύλης: 408.94865204545454
[9]:
bl.output.outputTables['InitialCurve'].to_panda_dataframe.head(20)

[9]:
x y
0 0.0214 0.00
1 0.0237 71.07
2 0.0260 142.14
3 0.0283 213.21
4 0.0306 284.28
5 0.0328 355.34
6 0.0351 426.41
7 0.0356 440.66
8 0.0379 501.46
9 0.0409 566.15
10 0.0446 633.82
11 0.0482 699.08
12 0.0517 758.74
13 0.0540 797.21
14 0.0563 833.29
15 0.0586 869.36
16 0.0609 905.44
17 0.0648 966.95
18 0.0679 1015.03
19 0.0711 1062.08
[10]:
print(bl.output.outputStrings['main'])
Bilin main output

Αρχική μετατόπιση: 0.0214

Έλεγχος στο 20% του ymax
x(02)=0.009792445820433439, y(02)=303.416. Οπότε k(02)=30984.70040721349

Εμβαδό καμπύλης: 408.94865204545454
[11]:
print(bl.output.outputTables['Iterations'].to_markdown)
|   __iteration |       x_y |       y_y |       x_u |       y_u |     kinel |       kel |      k_06 |     error |
|--------------:|----------:|----------:|----------:|----------:|----------:|----------:|----------:|----------:|
|             1 | 3.962E-02 | 1.228E+03 | 3.286E-01 | 1.434E+03 | 7.162E+02 | 3.098E+04 | 2.540E+04 | 2.198E-01 |
|             2 | 5.013E-02 | 1.273E+03 | 3.286E-01 | 1.434E+03 | 5.784E+02 | 2.540E+04 | 2.495E+04 | 1.787E-02 |
|             3 | 5.122E-02 | 1.278E+03 | 3.286E-01 | 1.434E+03 | 5.635E+02 | 2.495E+04 | 2.491E+04 | 1.824E-03 |
|             4 | 5.133E-02 | 1.279E+03 | 3.286E-01 | 1.434E+03 | 5.620E+02 | 2.491E+04 | 2.490E+04 | 1.892E-04 |
|             5 | 5.134E-02 | 1.279E+03 | 3.286E-01 | 1.434E+03 | 5.618E+02 | 2.490E+04 | 2.490E+04 | 1.966E-05 |
|             6 | 5.135E-02 | 1.279E+03 | 3.286E-01 | 1.434E+03 | 5.618E+02 | 2.490E+04 | 2.490E+04 | 2.043E-06 |
|             7 | 5.135E-02 | 1.279E+03 | 3.286E-01 | 1.434E+03 | 5.618E+02 | 2.490E+04 | 2.490E+04 | 2.123E-07 |
[12]:
print(bl.output.outputTables['BilinearCurve'].to_markdown)
|         x |         y |
|----------:|----------:|
| 2.140E-02 | 0.000E+00 |
| 7.275E-02 | 1.279E+03 |
| 3.500E-01 | 1.434E+03 |
[13]:
print(bl.bilinear_curve.all_quantities)
| quantity   |     value |
|:-----------|----------:|
| x_0        | 2.140E-02 |
| x_y        | 7.275E-02 |
| x_u        | 3.500E-01 |
| y_0        | 0.000E+00 |
| y_y        | 1.279E+03 |
| y_u        | 1.434E+03 |
| kel        | 2.490E+04 |
| kinel      | 5.618E+02 |
| μ          | 6.400E+00 |
| α          | 2.256E-02 |