My Project
demo_bk_bkp_animation.py
Go to the documentation of this file.
1 import sys
2 from matplotlib import pyplot as plt
3 from demo_pos_pos_spr_friction import pos_pos_spr_friction
4 
5 plt.rcParams["svg.fonttype"] = "none"
6 plt.rcParams["font.size"] = 10
7 plt.rcParams["text.usetex"] = False
8 plt.rcParams["savefig.directory"] = "../../Figures/Master"
9 plt.rcParams["savefig.format"] = "svg"
10 
11 
12 def run_demo(
13  demo_number
14 ):
15  velocity_index = 40 # what slider velocity the animation starts on
16  flags = {"no_pad": "--nopad"}
17  live_plotting = True
18  if(demo_number == 1):
19  shown_indexes = [0, 100]
20  run_name = "demo/bk_decrease_seed_106"
21  sys.argv.append(flags["no_pad"])
22  print("\n\nYou have chosen to run a demo of the Burridge-Knopoff model.",
23  "\nThis data for this run starts at a velocity og 1.49 and down ",
24  "to 0.0. Only a sample is plotted."
25  "\nHit \"Enter\" amd the run will start in approximately",
26  "5-10 seconds.")
27  input("\nHit \"Enter\" to start animation: ")
28 
29  if(demo_number == 2):
30  shown_indexes = [0, 100]
31  run_name = "demo/bk_pad_increase_seed_116"
32  velocity_index = 12
33  print("\n\nYou have chosen to run a demo of the Burridge-Knopoff-Pad model.",
34  "\nThis data for this run starts at a velocity og 0.12 and up",
35  "to 1.49. Only a sample is plotted."
36  "\nHit \"Enter\" amd the run will start in approximately",
37  "5-10 seconds.")
38  input("\nHit \"Enter\" to start animation: ")
39 
40  pos_pos_spr_friction(run_name, shown_indexes, live_plotting=live_plotting,
41  velocity_index=velocity_index)
42 
43 
44 if __name__ == "__main__":
45  valid_demo_numbers = ["1", "2"]
46  if(len(sys.argv) == 2):
47  if(sys.argv[1] in valid_demo_numbers):
48  run_demo(int(sys.argv[1]))
49  else:
50  print("1: BK model, decreasing velocity")
51  print("2: BKP model, increasing velocity")
52  demo_number = input("Please enter 1 or 2 for a demo and anything else to quit: ")
53  if(demo_number in valid_demo_numbers):
54  run_demo(int(demo_number))
def pos_pos_spr_friction(run_name, shown_indexes, shift_amount_per_frame=1, frames=800, live_plotting=True, sample_range=[0, velocity_index=40)