1
+ import numpy as np
2
+ import pandas as pd
3
+ import matplotlib .pyplot as plt
4
+ import matplotlib .animation as animation
5
+ import mpld3
6
+ from mpld3 import plugins
7
+ from IPython .display import HTML
8
+ import os
9
+
10
+
11
+ # def fun_Nec(n, z, I, fads, r, R, fip, fie, TR):
12
+
13
+ # Define input parameters
14
+ # Ratio entre ordenadas espectrales Sa(T = 0.1 s) y el PGA para el periodo de retorno seleccionado
15
+ n = 2.48
16
+ # Aceleración máxima esperada en el estrato competente para el evento sísmico de diseño, expresada como fracción de la aceleración de la gravedad
17
+ z = 0.4
18
+ I = 1 # Coeficiente de Importancia
19
+ # fa, fd, fs = Coeficiente de amplificación de suelo. Amplifica las ordenadas del espectro elástico de respuesta considerando los efectos de sitio
20
+ fads = [1.2 , 1.11 , 1.11 ]
21
+ r = 1 # Amplificación según ubicación geografica
22
+ R = 6 # Factor de Reducción de respuesta sísmica
23
+ # Coeficiente de castigo por irregularidad en planta
24
+ fip = 1
25
+ # Coeficiente de castigo por irregularidad en elevación
26
+ fie = 1
27
+
28
+ To = 0.10 * fads [2 ] * fads [1 ] / fads [0 ]
29
+ Tc = 0.55 * fads [2 ] * fads [1 ] / fads [0 ]
30
+
31
+ Sae = []
32
+ Sai = []
33
+ Tie = []
34
+
35
+ for T in np .arange (0 , 4 , 0.005 ):
36
+ if T <= To :
37
+ Sae .append ([z * fads [0 ] * (1 + (n - 1 ) * T / To ) * I ])
38
+ Sai .append ([n * z * fads [0 ] / (R * fip * fie ) * I ])
39
+ Tie .append ([T ])
40
+ else :
41
+ if T <= Tc :
42
+ Sae .append ([n * z * fads [0 ] * I ])
43
+ Sai .append ([n * z * fads [0 ] / (R * fip * fie ) * I ])
44
+ Tie .append ([T ])
45
+ else :
46
+ Sae .append ([I * n * z * fads [0 ] * (Tc / T ) ** r ])
47
+ Sai .append ([I * n * z * fads [0 ] * (Tc / T ) ** r / (R * fip * fie )])
48
+ Tie .append ([T ])
49
+
50
+ Resul = pd .DataFrame ({ 'Period [s]' : Tie ,'Sae [g]' : Sae ,'Sai [g]' : Sai })
51
+
52
+ Tie = np .array (Tie )
53
+ Sae = np .array (Sae )
54
+ Sai = np .array (Sai )
55
+ Tie = Tie [:, 0 ]
56
+ Sae = Sae [:, 0 ]
57
+ Sai = Sai [:, 0 ]
58
+
59
+
60
+ fig1 , ax1 = plt .subplots (figsize = (16 / 1.5 , 9 / 1.5 ))
61
+
62
+ ax1 .plot (Tie , Sae , color = (0 , 0 , 1 ), marker = '+' , markersize = 0 , markerfacecolor = 'w' ,
63
+ markeredgewidth = 0 , linewidth = 1.0 , alpha = 0.5 ,linestyle = '-' ,label = f'Sa_elastic' )
64
+ ax1 .plot (Tie , Sai , color = (0 , 0 , 0 ), marker = '+' , markersize = 0 , markerfacecolor = 'w' ,
65
+ markeredgewidth = 0 , linewidth = 1.5 , alpha = 0.7 ,linestyle = '--' ,label = f'Sa_inelastic' )
66
+ ax1 .set_xlim ([Tie [0 ], (max (Tie ))])
67
+ ax1 .set_ylim ([0 , (max (Sae )* 1.05 )])
68
+ plt .title ('UHS [NEC-SE-DS-2015]' , fontsize = 10 , color = (0 , 0 , 1 ))
69
+ plt .xlabel ('Period (T) [s]' , rotation = 0 , fontsize = 10 , color = (0 , 0 , 0 ))
70
+ plt .ylabel ('Max Response Acceleration (Sa) [g]' , rotation = 90 , fontsize = 10 , color = (0 , 0 , 0 ))
71
+ legend = plt .legend (fontsize = 10 )
72
+ legend .get_frame ().set_edgecolor ('none' )
73
+ ax1 .grid (which = 'both' , axis = 'x' , alpha = 0.5 )
74
+ plt .show ()
75
+
76
+
77
+ # UHS_E = np.column_stack((Tie,Sae))
78
+ # UHS_I = np.column_stack((Tie,Sai))
79
+
80
+ # current_directory = os.getcwd()
81
+ # folder_name = 'Results_NEC_UHS_TR_' + TR
82
+ # folder_path = os.path.join(current_directory, folder_name)
83
+
84
+ # if not os.path.exists(folder_path):
85
+ # os.makedirs(folder_path)
86
+
87
+ # file_path1 = os.path.join(folder_path, 'NEC_UHS_E_' + '.AT2')
88
+ # file_path2 = os.path.join(folder_path, 'NEC_UHS_I_' + '.AT2')
89
+
90
+ # np.savetxt(file_path1, UHS_E, delimiter='\t', fmt='%.6f')
91
+ # np.savetxt(file_path2, UHS_I, delimiter='\t', fmt='%.6f')
92
+
93
+ # fig_path1 = os.path.join(folder_name, 'fig1_UHS_E_I_TR_' + TR + '.png')
94
+ # fig1.savefig(fig_path1)
95
+
96
+ # print('\x1b[1;34m Folder Path =', folder_path)
97
+
98
+
99
+ # return Resul, fig1, folder_path
0 commit comments