Coryab/code #10
@ -1,5 +1,19 @@
|
||||
import matplotlib.pyplot as plt
|
||||
import numpy as np
|
||||
import seaborn as sns
|
||||
|
||||
sns.set_theme()
|
||||
params = {
|
||||
"font.family": "Serif",
|
||||
"font.serif": "Roman",
|
||||
"text.usetex": True,
|
||||
"axes.titlesize": "large",
|
||||
"axes.labelsize": "large",
|
||||
"xtick.labelsize": "large",
|
||||
"ytick.labelsize": "large",
|
||||
"legend.fontsize": "medium"
|
||||
}
|
||||
plt.rcParams.update(params)
|
||||
|
||||
def main():
|
||||
files = [
|
||||
@ -29,10 +43,10 @@ def main():
|
||||
|
||||
plt.xlabel(r"x $(\mu m)$")
|
||||
plt.ylabel(r"y $(\mu m)$")
|
||||
plt.title(r"2 particles with and without interactions.")
|
||||
# plt.legend()
|
||||
# plt.show()
|
||||
# plt.title(r"2 particles with and without interactions.")
|
||||
plt.legend(loc="upper right")
|
||||
plt.savefig("../latex/images/plot_2_particles_xy.pdf")
|
||||
plt.show()
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
|
||||
@ -1,5 +1,19 @@
|
||||
import matplotlib.pyplot as plt
|
||||
import numpy as np
|
||||
import seaborn as sns
|
||||
|
||||
sns.set_theme()
|
||||
params = {
|
||||
"font.family": "Serif",
|
||||
"font.serif": "Roman",
|
||||
"text.usetex": True,
|
||||
"axes.titlesize": "large",
|
||||
"axes.labelsize": "large",
|
||||
"xtick.labelsize": "large",
|
||||
"ytick.labelsize": "large",
|
||||
"legend.fontsize": "medium"
|
||||
}
|
||||
plt.rcParams.update(params)
|
||||
|
||||
def main():
|
||||
files = [
|
||||
|
||||
@ -1,4 +1,18 @@
|
||||
import matplotlib.pyplot as plt
|
||||
import seaborn as sns
|
||||
|
||||
sns.set_theme()
|
||||
params = {
|
||||
"font.family": "Serif",
|
||||
"font.serif": "Roman",
|
||||
"text.usetex": True,
|
||||
"axes.titlesize": "large",
|
||||
"axes.labelsize": "large",
|
||||
"xtick.labelsize": "large",
|
||||
"ytick.labelsize": "large",
|
||||
"legend.fontsize": "medium"
|
||||
}
|
||||
plt.rcParams.update(params)
|
||||
|
||||
def main():
|
||||
with open("output/time_dependent_potential/res.txt") as f:
|
||||
|
||||
@ -1,5 +1,19 @@
|
||||
import matplotlib.pyplot as plt
|
||||
import numpy as np
|
||||
import seaborn as sns
|
||||
|
||||
sns.set_theme()
|
||||
params = {
|
||||
"font.family": "Serif",
|
||||
"font.serif": "Roman",
|
||||
"text.usetex": True,
|
||||
"axes.titlesize": "large",
|
||||
"axes.labelsize": "large",
|
||||
"xtick.labelsize": "large",
|
||||
"ytick.labelsize": "large",
|
||||
"legend.fontsize": "medium"
|
||||
}
|
||||
plt.rcParams.update(params)
|
||||
|
||||
def main():
|
||||
directories = {
|
||||
@ -21,7 +35,7 @@ def main():
|
||||
r"particle 1 v",
|
||||
r"particle 2 r",
|
||||
r"particle 2 v",
|
||||
]
|
||||
]
|
||||
colors = [
|
||||
"lightskyblue",
|
||||
"deepskyblue",
|
||||
@ -44,9 +58,9 @@ def main():
|
||||
axs1[i].legend()
|
||||
axs1[i].set_title(title)
|
||||
|
||||
# plt.show()
|
||||
fig1.savefig("../latex/images/phase_space_2_particles_x.pdf")
|
||||
fig2.savefig("../latex/images/phase_space_2_particles_z.pdf")
|
||||
plt.show()
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
|
||||
@ -1,5 +1,19 @@
|
||||
import matplotlib.pyplot as plt
|
||||
import numpy as np
|
||||
import seaborn as sns
|
||||
|
||||
sns.set_theme()
|
||||
params = {
|
||||
"font.family": "Serif",
|
||||
"font.serif": "Roman",
|
||||
"text.usetex": True,
|
||||
"axes.titlesize": "large",
|
||||
"axes.labelsize": "large",
|
||||
"xtick.labelsize": "large",
|
||||
"ytick.labelsize": "large",
|
||||
"legend.fontsize": "medium"
|
||||
}
|
||||
plt.rcParams.update(params)
|
||||
|
||||
def main():
|
||||
directories = {
|
||||
@ -22,7 +36,7 @@ def main():
|
||||
"Relative error for the RK4 method",
|
||||
"Relative error for the forward Euler method"
|
||||
]
|
||||
fig1, axs1 = plt.subplots(2,1)
|
||||
fig1, axs1 = plt.subplots(2,1, sharex=True)
|
||||
for i, (dir, title) in enumerate(zip(directories, titles)):
|
||||
max_err = []
|
||||
for label, file in zip(labels, files):
|
||||
@ -33,17 +47,17 @@ def main():
|
||||
max_err.append(max(r))
|
||||
axs1[i].plot(t, r, label=label)
|
||||
|
||||
axs1[i].set(xlabel=r"t $(\mu s)$", ylabel = r"relative_error $(\mu m)$")
|
||||
axs1[i].set(ylabel = r"relative_error $(\mu m)$") # xlabel=r"t $(\mu s)$",
|
||||
|
||||
|
||||
axs1[1].set_xlabel(r"t $(\mu s)$")
|
||||
axs1[i].legend()
|
||||
axs1[i].set_title(title)
|
||||
# axs1[i].set_title(title)
|
||||
|
||||
conv_rate = 1/3 * sum([np.log10(max_err[i+1]/max_err[i])/np.log10(.5) for i in range(3)])
|
||||
print(conv_rate)
|
||||
|
||||
plt.show()
|
||||
# fig1.savefig("../latex/images/phase_space_2_particles_x.pdf")
|
||||
plt.show()
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
|
||||
@ -1,5 +1,19 @@
|
||||
import matplotlib.pyplot as plt
|
||||
import numpy as np
|
||||
import seaborn as sns
|
||||
|
||||
sns.set_theme()
|
||||
params = {
|
||||
"font.family": "Serif",
|
||||
"font.serif": "Roman",
|
||||
"text.usetex": True,
|
||||
"axes.titlesize": "large",
|
||||
"axes.labelsize": "large",
|
||||
"xtick.labelsize": "large",
|
||||
"ytick.labelsize": "large",
|
||||
"legend.fontsize": "medium"
|
||||
}
|
||||
plt.rcParams.update(params)
|
||||
|
||||
def z(t):
|
||||
V_0 = 25.*9.64852558 * 10**4
|
||||
@ -9,20 +23,25 @@ def z(t):
|
||||
return 20.*np.cos(w_z*t)
|
||||
|
||||
def main():
|
||||
colors = [
|
||||
"lightskyblue",
|
||||
"deepskyblue",
|
||||
"salmon",
|
||||
"tomato",
|
||||
]
|
||||
filename = "output/simulate_single_particle/particle_0_r.txt"
|
||||
r = t = []
|
||||
with open(filename) as f:
|
||||
lines = f.readlines()
|
||||
t = np.linspace(0, 50, len(lines))
|
||||
r = np.array([list(map(float, line.strip().split(","))) for line in lines])
|
||||
|
||||
plt.plot(t, r[:, 2], label="approximation")
|
||||
plt.plot(t, z(t), label="analytical")
|
||||
plt.plot(t, r[:, 2], label="approximation", color=colors[1])
|
||||
plt.plot(t, z(t), label="analytical", color=colors[2], linestyle="dotted")
|
||||
plt.xlabel(r"time $(\mu s)$")
|
||||
plt.ylabel(r"z $(\mu m)$")
|
||||
plt.title(r"Movement of a single particle in the x direction")
|
||||
plt.legend()
|
||||
# plt.savefig("../latex/images/single_particle.pdf")
|
||||
# plt.title(r"Movement of a single particle in the x direction")
|
||||
plt.legend(loc="lower right")
|
||||
plt.savefig("../latex/images/single_particle.pdf")
|
||||
plt.show()
|
||||
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user