Skip to content

Commit

Permalink
Merge pull request #359 from fusion-energy/animation_improvements
Browse files Browse the repository at this point in the history
Animation improvements
  • Loading branch information
shimwell authored Dec 12, 2024
2 parents fcdbd13 + 33f08cc commit 5c4db57
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 26 deletions.
Binary file modified docs/_static/spherical_tokamak_animation.mp4
Binary file not shown.
Binary file modified docs/_static/tokamak_animation.mp4
Binary file not shown.
27 changes: 16 additions & 11 deletions examples/spherical_tokamak_from_plasma_animation.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import os
import paramak
import cadquery_png_plugin.plugin
import numpy as np
Expand Down Expand Up @@ -123,6 +124,7 @@ def export_reactor_to_png(reactor, file_path):
"width": int(1280/2),
"height": int(1024/2),
"zoom": 1.4,
"background_color": (1.0, 1.0, 1.0),
},
file_path=file_path
)
Expand All @@ -140,17 +142,6 @@ def export_reactor_to_png(reactor, file_path):
export_reactor_to_png(reactor, f'spherical_tokamak_frame_{frame:03d}.png')
frame += 1

for factor in factors:
modified_elongation = original_elongation * factor
reactor = create_reactor(elongation=modified_elongation)
export_reactor_to_png(reactor, f'spherical_tokamak_frame_{frame:03d}.png')
frame += 1

for modified_triangularity in [0.55, 0.3667, 0.1833, 0.0, -0.1833, -0.3667, -0.55, -0.3667, -0.1833, 0.0, 0.1833, 0.3667, 0.55]:
reactor = create_reactor(triangularity=modified_triangularity)
export_reactor_to_png(reactor, f'spherical_tokamak_frame_{frame:03d}.png')
frame += 1

for modified_n_tf_coils in [original_n_tf_coils, original_n_tf_coils -1 , original_n_tf_coils -2, original_n_tf_coils-3, original_n_tf_coils-2, original_n_tf_coils-1,original_n_tf_coils]:
reactor = create_reactor(n_tf_coils=modified_n_tf_coils)
export_reactor_to_png(reactor, f'spherical_tokamak_frame_{frame:03d}.png')
Expand All @@ -166,3 +157,17 @@ def export_reactor_to_png(reactor, file_path):
reactor = create_reactor(divertor_thickness=modified_divertor_thickness)
export_reactor_to_png(reactor, f'spherical_tokamak_frame_{frame:03d}.png')
frame += 1

for factor in factors:
modified_elongation = original_elongation * factor
reactor = create_reactor(elongation=modified_elongation)
export_reactor_to_png(reactor, f'spherical_tokamak_frame_{frame:03d}.png')
frame += 1

for modified_triangularity in [0.55, 0.3667, 0.1833, 0.0, -0.1833, -0.3667, -0.55, -0.3667, -0.1833, 0.0, 0.1833, 0.3667, 0.55]:
reactor = create_reactor(triangularity=modified_triangularity)
export_reactor_to_png(reactor, f'spherical_tokamak_frame_{frame:03d}.png')
frame += 1


os.system('ffmpeg -r 10 -i spherical_tokamak_frame_%3d.png -c:v libx264 -r 30 -pix_fmt yuv420p spherical_tokamak_animation.mp4')
33 changes: 18 additions & 15 deletions examples/tokamak_from_plasma_animation.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import paramak
import imageio
import io
import cadquery_png_plugin.plugin
import numpy as np
import cadquery as cq
Expand Down Expand Up @@ -129,6 +129,7 @@ def export_reactor_to_png(reactor, file_path):
"width": int(1280/2),
"height": int(1024/2),
"zoom": 1.25,
"background_color": (1.0, 1.0, 1.0),
},
file_path=file_path
)
Expand All @@ -147,29 +148,31 @@ def export_reactor_to_png(reactor, file_path):
export_reactor_to_png(reactor, f'tokamak_frame_{frame:03d}.png')
frame += 1

for factor in factors:
modified_elongation = original_elongation * factor
reactor = create_reactor(elongation=modified_elongation)
export_reactor_to_png(reactor, f'spherical_tokamak_frame_{frame:03d}.png')
frame += 1

for modified_triangularity in [0.55, 0.3667, 0.1833, 0.0, -0.1833, -0.3667, -0.55, -0.3667, -0.1833, 0.0, 0.1833, 0.3667, 0.55]:
reactor = create_reactor(triangularity=modified_triangularity)
export_reactor_to_png(reactor, f'spherical_tokamak_frame_{frame:03d}.png')
frame += 1

for modified_n_tf_coils in [original_n_tf_coils, original_n_tf_coils -1 , original_n_tf_coils -2, original_n_tf_coils-3, original_n_tf_coils-2, original_n_tf_coils-1,original_n_tf_coils]:
reactor = create_reactor(n_tf_coils=modified_n_tf_coils)
export_reactor_to_png(reactor, f'spherical_tokamak_frame_{frame:03d}.png')
export_reactor_to_png(reactor, f'tokamak_frame_{frame:03d}.png')
frame += 1

for modified_coil_height_factor in [1, 1.1, 1.2, 1.3, 1.4, 1.5, 1.4, 1.3, 1.2, 1.1, 1]:
reactor = create_reactor(coil_height_factor=modified_coil_height_factor)
export_reactor_to_png(reactor, f'spherical_tokamak_frame_{frame:03d}.png')
export_reactor_to_png(reactor, f'tokamak_frame_{frame:03d}.png')
frame += 1

for factor in factors:
modified_divertor_thickness = original_divertor_thickness * factor
reactor = create_reactor(divertor_thickness=modified_divertor_thickness)
export_reactor_to_png(reactor, f'spherical_tokamak_frame_{frame:03d}.png')
export_reactor_to_png(reactor, f'tokamak_frame_{frame:03d}.png')
frame += 1

for factor in factors:
modified_elongation = original_elongation * factor[:-2]
reactor = create_reactor(elongation=modified_elongation)
export_reactor_to_png(reactor, f'tokamak_frame_{frame:03d}.png')
frame += 1

for modified_triangularity in [0.55, 0.3667, 0.1833, 0.0, -0.1833, -0.3667, -0.55, -0.3667, -0.1833, 0.0, 0.1833, 0.3667, 0.55]:
reactor = create_reactor(triangularity=modified_triangularity)
export_reactor_to_png(reactor, f'tokamak_frame_{frame:03d}.png')
frame += 1

os.system('ffmpeg -r 10 -i tokamak_frame_%3d.png -c:v libx264 -r 30 -pix_fmt yuv420p tokamak_animation.mp4')

0 comments on commit 5c4db57

Please sign in to comment.