from UQuant.SemilinearSystem import SemiLinSystem # build a pipe pipe = SemiLinSystem(1.0, 5.0, 0.0, 1.0, 0.005, 7, 0.05) # get the info of the pipe pipe.info() # check how pressure drop behaves when the friction coefficient is # updated. Theoretically we have continuous dependence which can # be seen also numerically. coef = 0.0 for i in range(0, 100): vec_c = [0.05 + coef, 0.01, 0.0, 0.04, 0.0, 0.005, 0.005] pipe.run(vec_c) pipe.get_lambda_average(vec_c) pipe.get_presure_drop(time_instance=13) if i % 10 == 1: plt.plot(pipe.timeslices, pipe.pressure_drop, "-o", label="cf = " + str(0.05 + coef)) coef += 0.001 print ">> Computation Done" plt.legend(loc=2, borderaxespad=0.0) plt.xticks([round(tn, 2) for tn in pipe.timeslices]) plt.xlabel("$t_n$", fontsize=24) plt.ylabel("$\delta p_h(t_n)$", fontsize=24) plt.tight_layout() plt.show(block=True)
c_sound = 1.0 t_final = 5.0 x_l, x_r = [0.0, 1.0] dx = 0.005 boundary_eps = 0.05 # true friction coefficient true_friction = [0.075, 0.015, 0.035, 0.025, 0.035, 0.001, 0.03] time_ins = 20 # construct and run the true pipe pipe_true = SemiLinSystem(c_sound, t_final, x_l, x_r, dx, expan_coef, boundary_eps) pipe_true.run(true_friction) y_obs = normal(0.0, 0.1, time_ins) + \ pipe_true.get_presure_drop(time_instance=time_ins, inplace=False) # construct a pipe for computation pipe = SemiLinSystem(c_sound, t_final, x_l, x_r, dx, expan_coef, boundary_eps) def uni_prior(x): ''' uniform prior Parameters ---------- x: float * len(x) '''
ax.set_aspect(aspect=6) ax.legend(loc='upper left', bbox_to_anchor=(0.05, 1.275), fontsize=12) if cluster != 0: ax.tick_params(axis='y', labelleft=False) plt.tight_layout() plt.savefig("results/cluster_13.pgf") plt.show(block=False) # plot pressure drop fig = plt.figure(figsize=(12, 6)) pipe_true.run(true_friction) pipe_true.get_presure_drop(time_instance=time_ins) markers = ['x', '^', 'P', 'o', '*', 'p'] for cluster in range(n_clusters): ax = fig.add_subplot(1, n_clusters, cluster + 1) plt.yticks(fontsize=18) plt.xticks(fontsize=18) plt.xlabel("$t$", fontsize=24) mean_cluster.append(df.iloc[pred == cluster, :].mean().values) pipe.run(mean_cluster[cluster]) pipe.get_presure_drop(time_instance=time_ins) ax.plot(pipe.timeslices, pipe.pressure_drop, markers[cluster % len(markers)],