diff --git a/1_SP-11_Test.csv b/1_SP-11_Test.csv new file mode 100644 index 0000000..9496268 --- /dev/null +++ b/1_SP-11_Test.csv @@ -0,0 +1,125 @@ +Time,Settle,Surcharge +0,0,1.5 +5,17.4,1.5 +7,23.9,1.5 +11,32.2,1.5 +14,41.7,1.5 +21,64.1,1.5 +28,72.5,1.5 +35,78.8,1.5 +42,93.3,1.5 +48,102.5,1.5 +53,108,3.002 +54,109.2,3.002 +55,110.4,3.002 +56,111.6,3.002 +59,117.3,3.002 +60,119.2,3.002 +61,121.1,3.002 +62,122.7,3.002 +67,130.2,3.002 +68,131.9,3.002 +69,133.6,3.002 +70,135.4,3.002 +74,141.4,3.002 +75,142.9,3.002 +76,144.4,3.002 +77,146.2,3.002 +80,149.2,3.002 +81,150.2,3.002 +82,151.2,3.002 +83,152.2,3.002 +91,162.8,3.002 +98,170,3.002 +105,177,3.002 +112,182.4,3.002 +115,185,3.002 +117,186.5,3.002 +118,187.3,3.002 +122,202.9,4.095 +124,210.5,4.095 +125,214.5,4.095 +126,218.6,4.095 +129,222.4,4.095 +130,223.7,4.095 +131,225,4.095 +132,226.3,4.095 +133,227.5,4.095 +136,231.7,4.095 +137,233.1,4.095 +138,234.5,4.095 +139,235.9,4.095 +140,237.3,4.095 +143,240.7,4.095 +147,245.5,4.095 +151,249.7,4.095 +154,252.8,4.095 +158,257.8,4.095 +161,261.1,4.095 +164,264.1,4.095 +168,268,4.095 +172,272.2,4.095 +175,275.5,4.095 +181,283.5,4.095 +192,293.5,4.095 +195,296.2,4.095 +199,301.3,4.095 +202,304.6,4.095 +209,311.1,4.095 +216,316,4.095 +223,322.3,4.095 +230,326.5,4.095 +237,331.6,4.095 +244,336.5,4.095 +251,341.2,4.095 +258,346.1,4.095 +266,350.9,4.095 +273,354,4.095 +280,356,4.095 +286,358,4.095 +294,360.9,4.095 +300,363,5.256 +301,363.4,5.256 +304,365.8,5.256 +305,366.5,5.256 +306,367.2,5.256 +307,367.9,5.256 +308,368.5,5.256 +311,369.5,5.256 +312,369.8,5.256 +313,370.1,5.256 +314,370.4,5.256 +327,377.4,5.256 +329,378.5,5.256 +336,381.8,5.256 +343,385.5,5.256 +350,388.4,5.256 +357,391.1,5.256 +364,394.1,5.256 +371,397.1,5.256 +377,399.5,5.256 +385,401.4,5.256 +388,402.3,5.256 +389,402.6,5.256 +390,402.9,5.256 +391,403.2,5.256 +392,403.5,5.256 +395,404.4,5.256 +397,405,5.256 +398,405.3,5.256 +402,406.5,5.256 +404,407.1,5.256 +405,407.4,5.256 +406,407.6,5.256 +409,408.2,5.256 +411,408.6,5.256 +419,410.2,5.256 +420,410.5,5.256 +425,411.5,5.256 +426,411.7,5.256 +434,413.3,5.256 +440,414.5,5.256 +447,415.9,5.256 +455,417.5,5.256 +461,418.7,5.256 +468,420,5.256 diff --git a/3_SP-68_Rev.4_Test.svg b/3_SP-68_Rev.4_Test.svg new file mode 100644 index 0000000..9701c30 --- /dev/null +++ b/3_SP-68_Rev.4_Test.svg @@ -0,0 +1,2091 @@ + + + + + + + + 2022-08-12T11:11:04.263402 + image/svg+xml + + + Matplotlib v3.5.2, https://matplotlib.org/ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/3_SP-68_Test.csv b/3_SP-68_Test.csv new file mode 100644 index 0000000..b08d947 --- /dev/null +++ b/3_SP-68_Test.csv @@ -0,0 +1,128 @@ +Time,Settle,Surcharge +0,0,1.887 +3,41,1.887 +6,61.5,1.887 +10,73.1,1.887 +13,81.6,1.887 +17,86.9,1.887 +20,91.9,1.887 +23,96.7,1.887 +26,101.6,1.887 +30,107.7,2.94 +33,113,2.94 +37,119.4,2.94 +40,122.8,2.94 +44,128.4,2.94 +47,131.9,2.94 +52,139.5,2.94 +54,140.5,2.94 +59,148,2.94 +62,151,2.94 +65,153.8,2.94 +68,156.6,2.94 +72,160,2.94 +75,162.5,2.94 +79,166,2.94 +83,169.1,2.94 +86,172,2.94 +89,174.7,2.94 +94,180.3,2.94 +96,182.1,2.94 +100,185.5,2.94 +103,188.4,2.94 +110,195.8,2.94 +114,198.7,2.94 +118,201.1,2.94 +122,205,2.94 +125,206.9,2.94 +128,209.3,2.94 +131,211.8,2.94 +135,214.2,2.94 +138,216.2,2.94 +143,217.4,2.94 +146,218.3,2.94 +150,219.1,2.94 +153,219.9,2.94 +156,220.9,2.94 +159,222,2.94 +164,227.7,2.94 +167,230.7,2.94 +171,234.8,3.48 +173,236.5,3.48 +177,239.7,3.48 +180,241.8,3.48 +184,243.9,3.48 +187,246.3,3.48 +191,249.6,3.48 +194,252.1,3.48 +198,255.5,3.48 +201,258.9,3.48 +205,261.2,3.48 +208,263.4,3.48 +212,265.8,3.48 +215,267.1,3.48 +219,268.9,3.48 +222,270.2,3.48 +227,273.4,3.48 +229,275,3.48 +234,277.3,3.48 +237,278.1,3.48 +241,280,3.48 +244,281.2,3.48 +248,283.2,3.48 +251,284.6,3.48 +254,286.1,3.48 +257,287.5,3.48 +262,289.5,3.48 +265,290.7,3.48 +268,292,3.48 +271,293.2,3.48 +275,294.7,3.48 +278,295.3,3.48 +282,296.3,3.48 +285,296.7,3.48 +289,297.6,3.48 +292,298.5,3.48 +296,299.8,3.48 +299,300.6,3.48 +303,302.2,3.48 +306,303.5,3.48 +310,312.8,5.608 +313,318.1,5.608 +317,322.8,6.794 +320,328.9,6.794 +324,335.3,6.794 +328,340.5,6.794 +331,342.9,6.794 +334,345.5,6.794 +339,348,6.794 +342,350.6,6.794 +345,353.1,6.794 +348,355.6,6.794 +352,358.9,6.794 +355,361,6.794 +362,365.6,6.794 +367,369,6.794 +370,370.5,6.794 +373,372.2,6.794 +376,373.8,6.794 +381,376.4,6.794 +384,378.5,6.794 +387,380.4,6.794 +390,382.4,6.794 +394,385.8,6.794 +397,388,6.794 +402,389.9,6.794 +405,390.9,6.794 +409,392.6,6.794 +412,394,6.794 +415,396.7,6.794 +418,397.5,6.794 +422,398.7,6.794 +425,399.1,6.794 +429,399.8,6.794 +432,400.9,6.794 +436,403.6,6.794 +439,405.6,6.794 +443,408.2,6.794 +446,409.4,6.794 diff --git a/main_Rev.4.py b/main_Rev.4.py new file mode 100644 index 0000000..93456ab --- /dev/null +++ b/main_Rev.4.py @@ -0,0 +1,184 @@ +# ================= +# Import 섹션 +# ================= + +import numpy as np +from scipy.optimize import least_squares +import matplotlib.pyplot as plt +from matplotlib import rcParams +import pandas as pd + +# ================= +# Function 섹션 +# ================= + +# 주어진 계수를 이용하여 쌍곡선 시간-침하 곡선 반환 +def generate_data_hyper(px, pt): + return pt / (px[0] * pt + px[1]) + +# 회귀식과 측정치와의 잔차 반환 (비선형 쌍곡선) +def fun_hyper_nonlinear(px, pt, py): + return pt / (px[0] * pt + px[1]) - py + +# ================= +# Step별 활용 Function +# ================= + +# i단계 보정 침하량 산정 +def fun_step_measured_correction(m, p): + return m - p + +# i단계 t-ti 산정 +def fun_step_time_correction(t, ti): + return t - ti + +# i단계 침하곡선 작성 +def settlement_prediction_curve(m1, p1): + return m1 + p1 + +# i단계 보정 예측 침하량 산정 +def fun_step_prediction_correction(m2, p2): + return p2 + (m2[0] - p2[0]) + + + +# ================= +# 입력값 설정 +# ================= + +# CSV 파일 읽기 +data = pd.read_csv("3_SP-68_Test.csv") + +# 시간, 침하량, 성토고 배열 생성 +time = data['Time'].to_numpy() +settle = data['Settle'].to_numpy() +surcharge = data['Surcharge'].to_numpy() + +# ================= +# 성토 단계 구분 +# ================= + +step_start_index = [0, 9, 49, 90] # 단계별 성토 시작 지점 입력(4단계 이므로 4개) +step_end_index = [8, 48, 89, 129] # 단계별 성토 종료 지점 입력(4단계 이므로 4개) +x0 = np.ones(2) +num_step = 4 + +for i in range(0, num_step): # 성토 단계에 따라 수정(4단계 이므로 0~4) + + # i단계 실측 기간 및 침하량 + globals()['tm_{}'.format(i)] = time[step_start_index[i]:step_end_index[i]] + globals()['ym_{}'.format(i)] = settle[step_start_index[i]:step_end_index[i]] + + if i == 0 : # 1단계 + + res_lsq_hyper_nonlinear_0 = least_squares(fun_hyper_nonlinear, x0, args=(tm_0, ym_0)) + print(res_lsq_hyper_nonlinear_0.x) + + globals()['settle_predicted_{}'.format(i)] = generate_data_hyper(res_lsq_hyper_nonlinear_0.x, time) + + elif 0 < i < (num_step - 1): + + # i단계~최종 실측 기간 및 침하량 + globals()['tmm_{}'.format(i)] = time[step_start_index[i]:step_end_index[-1]] + globals()['ymm_{}'.format(i)] = settle[step_start_index[i]:step_end_index[-1]] + + # i-1단계 예측 침하량(i단계 기간에 해당하는) + globals()['yp_{}'.format(i)] = globals()['settle_predicted_{}'.format(i - 1)][(step_start_index[i]-step_start_index[i-1]):(step_end_index[i]-step_start_index[i-1])] + # i-1 단계 예측 침하량 (i단계~최종) + globals()['ypp_{}'.format(i)] = globals()['settle_predicted_{}'.format(i - 1)][(step_start_index[i]-step_start_index[i-1]):(step_end_index[-1]-step_start_index[i-1])] + + # i단계 실측 보정 침하량 산정 + globals()['step_{}_measured_correction'.format(i)] = fun_step_measured_correction(globals()['ym_{}'.format(i)],globals()['yp_{}'.format(i)]) + # i단계 t-ti 산정 + globals()['step_{}_time_correction'.format(i)] = fun_step_time_correction(globals()['tmm_{}'.format(i)], + globals()['tm_{}'.format(i)][0]) + + # i 단계 보정 침하량에 대한 예측 침하량 산정 + globals()['res_lsq_hyper_nonlinear_{}'.format(i)] = least_squares(fun_hyper_nonlinear, x0, + args=(globals()['step_{}_time_correction'.format(i)][0:(step_end_index[i]-step_start_index[i])], + globals()['step_{}_measured_correction'.format(i)])) + + + print(globals()['res_lsq_hyper_nonlinear_{}'.format(i)].x) + + globals()['settle_hyper_nonlinear_{}'.format(i)] = generate_data_hyper(globals()['res_lsq_hyper_nonlinear_{}'.format(i)].x, + globals()['step_{}_time_correction'.format(i)]) + + # i단계 침하곡선 작성 + globals()['step_{}_prediction_curve'.format(i)] = settlement_prediction_curve(globals()['settle_hyper_nonlinear_{}'.format(i)], + globals()['ypp_{}'.format(i)]) + + # i단계 보정 예측 침하량 산정 + globals()['settle_predicted_{}'.format(i)] = fun_step_prediction_correction(globals()['ymm_{}'.format(i)], + globals()['step_{}_prediction_curve'.format(i)]) + + + else: # 최종 성토 단계 + + # i-1 단계 예측 침하량 (최종 단계에 해당하는) + globals()['yp_{}'.format(i)] = globals()['settle_predicted_{}'.format(i - 1)][(step_start_index[i]-step_start_index[i-1]):step_end_index[i]] + + # 최종 단계 실측 보정 침하량 산정 + globals()['step_{}_measured_correction'.format(i)] = fun_step_measured_correction(globals()['ym_{}'.format(i)], + globals()['yp_{}'.format(i)]) + + # 최종 단계 t-ti 산정 + globals()['step_{}_time_correction'.format(i)] = fun_step_time_correction(globals()['tm_{}'.format(i)], + globals()['tm_{}'.format(i)][0]) + + # 최종 단계 보정 침하량에 대한 예측 침하량 산정 + globals()['res_lsq_hyper_nonlinear_{}'.format(i)] = least_squares(fun_hyper_nonlinear, x0, + args=(globals()['step_{}_time_correction'.format(i)], + globals()['step_{}_measured_correction'.format(i)])) + + print(globals()['res_lsq_hyper_nonlinear_{}'.format(i)].x) + + globals()['settle_hyper_nonlinear_{}'.format(i)] = generate_data_hyper(globals()['res_lsq_hyper_nonlinear_{}'.format(i)].x, + globals()['step_{}_time_correction'.format(i)]) + + # 최종 단계 침하곡선 작성 + globals()['step_{}_prediction_curve'.format(i)] = settlement_prediction_curve(globals()['settle_hyper_nonlinear_{}'.format(i)], + globals()['yp_{}'.format(i)]) + + # 최종단계 보정 예측 침하량 산정 + globals()['settle_predicted_{}'.format(i)] = fun_step_prediction_correction(globals()['ym_{}'.format(i)], + globals()['step_{}_prediction_curve'.format(i)]) + +''' +나중에: 그래프 작성 +''' + +# 그래프 크기, 서브 그래프 개수 및 비율 설정 +f, axes = plt.subplots(2,1, figsize=(10, 10), + gridspec_kw={'height_ratios':[1,2]}) + +# 성토고 그래프 표시 +axes[0].plot(time, surcharge, color='black', label='surcharge height') + +axes[0].set_ylabel("Surcharge height (m)", fontsize = 17) +axes[0].set_xlim(left = 0) +axes[0].grid(color="gray", alpha=.5, linestyle='--') +axes[0].tick_params(direction='in') + +# 계측 침하량 표시 +axes[1].scatter(time, -settle, s = 50, facecolors='white', edgecolors='black', label = 'measured data') + +# 예측 침하량 표시 +axes[1].plot(time, -settle_predicted_0, linestyle='--', color='red', label='Predicted Curve_Step 1') +axes[1].plot(tmm_1, -settle_predicted_1, linestyle='--', color='blue', label='Predicted Curve_Step 2') +axes[1].plot(tmm_2, -settle_predicted_2, linestyle='--', color='green', label='Predicted Curve_Step 3') +axes[1].plot(tm_3, -settle_predicted_3, linestyle='--', color='orange', label='Predicted Curve_Step 4') + +# 예측 침하량 그래프 설정 +axes[1].set_xlabel("Time (day)", fontsize = 17) +axes[1].set_ylabel("Settlement (mm)", fontsize = 17) +axes[1].set_ylim(top = 0) +axes[1].set_ylim(bottom = -1.5 * settle.max()) +axes[1].set_xlim(left = 0) + +# 범례 표시 +axes[1].legend(loc=1, ncol=2, frameon=True, fontsize=12) + +# 그래프 저장 및 출력 +plt.savefig('3_SP-68_Rev.4_Test.svg', dpi=300) +plt.show() \ No newline at end of file diff --git a/main_Rev.4.svg b/main_Rev.4.svg new file mode 100644 index 0000000..c96c296 --- /dev/null +++ b/main_Rev.4.svg @@ -0,0 +1,2042 @@ + + + + + + + + 2022-08-12T10:35:52.611400 + image/svg+xml + + + Matplotlib v3.5.2, https://matplotlib.org/ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +