-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Implementing gradient in different directions
- Loading branch information
1 parent
34f6b43
commit 81eb823
Showing
22 changed files
with
3,487 additions
and
50 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
"""Config file to simulate a membrane with a staggered lattice of rectangular slits""" | ||
|
||
import numpy as np | ||
|
||
|
||
# General parameters: | ||
OUTPUT_FOLDER_NAME = 'Anisotropy study horizontal' | ||
NUMBER_OF_PHONONS = 1000 | ||
NUMBER_OF_TIMESTEPS = 30000 | ||
NUMBER_OF_NODES = 400 | ||
TIMESTEP = 1e-12 | ||
T = 4.0 | ||
|
||
# Map & profiles parameters: | ||
NUMBER_OF_PIXELS_X = 100 | ||
NUMBER_OF_PIXELS_Y = 100 | ||
NUMBER_OF_TIMEFRAMES = 6 | ||
|
||
# Material parameters: | ||
MEDIA = 'Si' | ||
SPECIFIC_HEAT_CAPACITY = 0.0176 # [J/kg/K] for Si at 4 K | ||
|
||
|
||
# System dimensions [m]: | ||
THICKNESS = 150e-9 | ||
WIDTH = 1300e-9 | ||
LENGTH = 1300e-9 | ||
|
||
# STRUCTURE: | ||
|
||
# ----> | ||
#------------------- | ||
# | ||
# H C | ||
# | ||
#------------------- | ||
|
||
INCLUDE_RIGHT_SIDEWALL = False | ||
INCLUDE_LEFT_SIDEWALL = False | ||
INCLUDE_TOP_SIDEWALL = True | ||
INCLUDE_BOTTOM_SIDEWALL = True | ||
|
||
# Hot and cold sides [m]: | ||
COLD_SIDE_POSITION = 'right' | ||
HOT_SIDE_POSITION = 'left' | ||
HOT_SIDE_X = -WIDTH/2 | ||
HOT_SIDE_Y = LENGTH/2 | ||
HOT_SIDE_WIDTH_X = 0 | ||
HOT_SIDE_WIDTH_Y = LENGTH | ||
HOT_SIDE_ANGLE_DISTRIBUTION = 'random_right' | ||
|
||
|
||
# Hole array parameters [m]: | ||
INCLUDE_HOLES = True | ||
CIRCULAR_HOLE_DIAMETER = 0 | ||
RECTANGULAR_HOLE_SIDE_X = 200e-9 | ||
RECTANGULAR_HOLE_SIDE_Y = 100e-9 | ||
PERIOD_X = 300e-9 | ||
PERIOD_Y = 300e-9 | ||
|
||
|
||
# Staggered attice of holes: | ||
FIRST_HOLE_COORDINATE = 200e-9 | ||
NUMBER_OF_PERIODS_X = 4 | ||
NUMBER_OF_PERIODS_Y = 4 | ||
HOLE_COORDINATES = np.zeros((NUMBER_OF_PERIODS_X * NUMBER_OF_PERIODS_Y, 3)) | ||
HOLE_SHAPES = ['rectangle' for x in range(HOLE_COORDINATES.shape[0])] | ||
hole_number = 0 | ||
for i in range(NUMBER_OF_PERIODS_Y): | ||
for j in range(NUMBER_OF_PERIODS_X): | ||
HOLE_COORDINATES[hole_number, 0] = -(NUMBER_OF_PERIODS_X - 1) * PERIOD_X / 2 + j * PERIOD_X | ||
HOLE_COORDINATES[hole_number, 1] = FIRST_HOLE_COORDINATE + i * PERIOD_Y | ||
HOLE_COORDINATES[hole_number, 2] = 0 | ||
hole_number += 1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
"""Config file to simulate a membrane with a staggered lattice of rectangular slits | ||
Here we impose thermal gradient in vertical direction""" | ||
|
||
import numpy as np | ||
|
||
|
||
# General parameters: | ||
OUTPUT_FOLDER_NAME = 'Anisotropy study vertical' | ||
NUMBER_OF_PHONONS = 1000 | ||
NUMBER_OF_TIMESTEPS = 30000 | ||
NUMBER_OF_NODES = 400 | ||
TIMESTEP = 1e-12 | ||
T = 4.0 | ||
|
||
# Map & profiles parameters: | ||
NUMBER_OF_PIXELS_X = 100 | ||
NUMBER_OF_PIXELS_Y = 100 | ||
NUMBER_OF_TIMEFRAMES = 6 | ||
|
||
# Material parameters: | ||
MEDIA = 'Si' | ||
SPECIFIC_HEAT_CAPACITY = 0.0176 # [J/kg/K] for Si at 4 K | ||
|
||
|
||
# System dimensions [m]: | ||
THICKNESS = 150e-9 | ||
WIDTH = 1300e-9 | ||
LENGTH = 1300e-9 | ||
|
||
# STRUCTURE: | ||
|
||
# | C | | ||
# | | ^ | ||
# | | | | ||
# | | | | ||
# | H | | ||
|
||
INCLUDE_RIGHT_SIDEWALL = True | ||
INCLUDE_LEFT_SIDEWALL = True | ||
INCLUDE_TOP_SIDEWALL = False | ||
INCLUDE_BOTTOM_SIDEWALL = False | ||
|
||
# Hot and cold sides [m]: | ||
COLD_SIDE_POSITION = 'top' | ||
HOT_SIDE_POSITION = 'bottom' | ||
HOT_SIDE_X = 0 | ||
HOT_SIDE_Y = 0 | ||
HOT_SIDE_WIDTH_X = WIDTH | ||
HOT_SIDE_WIDTH_Y = 0 | ||
HOT_SIDE_ANGLE_DISTRIBUTION = 'random_up' | ||
|
||
# Hole array parameters [m]: | ||
INCLUDE_HOLES = True | ||
CIRCULAR_HOLE_DIAMETER = 0 | ||
RECTANGULAR_HOLE_SIDE_X = 200e-9 | ||
RECTANGULAR_HOLE_SIDE_Y = 100e-9 | ||
PERIOD_X = 300e-9 | ||
PERIOD_Y = 300e-9 | ||
|
||
|
||
# Staggered attice of holes: | ||
FIRST_HOLE_COORDINATE = 200e-9 | ||
NUMBER_OF_PERIODS_X = 4 | ||
NUMBER_OF_PERIODS_Y = 4 | ||
HOLE_COORDINATES = np.zeros((NUMBER_OF_PERIODS_X * NUMBER_OF_PERIODS_Y, 3)) | ||
HOLE_SHAPES = ['rectangle' for x in range(HOLE_COORDINATES.shape[0])] | ||
hole_number = 0 | ||
for i in range(NUMBER_OF_PERIODS_Y): | ||
for j in range(NUMBER_OF_PERIODS_X): | ||
HOLE_COORDINATES[hole_number, 0] = -(NUMBER_OF_PERIODS_X - 1) * PERIOD_X / 2 + j * PERIOD_X | ||
HOLE_COORDINATES[hole_number, 1] = FIRST_HOLE_COORDINATE + i * PERIOD_Y | ||
HOLE_COORDINATES[hole_number, 2] = 0 | ||
hole_number += 1 | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,97 @@ | ||
"""Module that creates animations from recorded phonon paths""" | ||
|
||
import sys | ||
import os | ||
import shutil | ||
import imageio | ||
import numpy as np | ||
import matplotlib.pyplot as plt | ||
|
||
from freepaths.config import cf | ||
from freepaths.output_structure import draw_structure | ||
|
||
|
||
def generate_frames_xy(): | ||
"""Generate animation frames with phonon paths""" | ||
|
||
data = np.genfromtxt("Data/Phonon paths.csv", | ||
unpack=False, | ||
delimiter=',', | ||
skip_header=1, | ||
encoding='utf-8') | ||
|
||
# Create XY plots for each timestep where all phonon shown at the same time: | ||
number_of_steps = np.shape(data)[0] | ||
number_of_phonons = np.shape(data)[1]//3 | ||
|
||
for step in range(1, number_of_steps): | ||
fig, ax = plt.subplots() | ||
|
||
# Draw the structure: | ||
patches = draw_structure(cf) | ||
for patch in patches: | ||
ax.add_patch(patch) | ||
|
||
# Draw the paths: | ||
for phonon_num in range(number_of_phonons): | ||
x_coords = np.trim_zeros(data[:, 3 * phonon_num], trim='b') | ||
y_coords = np.trim_zeros(data[:, 3 * phonon_num + 1], trim='b') | ||
ax.plot(x_coords[:step], y_coords[:step], linewidth=0.5) | ||
|
||
# Plot settings: | ||
ax.set_xlim([-0.55*cf.width*1e6, 0.55*cf.width*1e6]) | ||
ax.set_ylim([0, cf.length*1e6]) | ||
ax.set_aspect('equal') | ||
ax.axis('off') | ||
for spine in ['top', 'right', 'left', 'bottom']: | ||
ax.spines[spine].set_visible(False) | ||
fig.savefig(f"Frames/frame_{step:0>6}.png", dpi=600, bbox_inches="tight") | ||
plt.close(fig) | ||
|
||
# Progress: | ||
sys.stdout.write(f"\rAnimation: {step}/{number_of_steps - 1} frames") | ||
|
||
# Create XY plots for each step for each phonon one by one: | ||
# cmap = plt.get_cmap("tab10") | ||
# frame_number = 0 | ||
# number_of_phonons = np.shape(data)[1]//3 | ||
# for phonon_num in range(number_of_phonons): | ||
# x_coords = np.trim_zeros(data[:, 3 * phonon_num], trim='b') | ||
# y_coords = np.trim_zeros(data[:, 3 * phonon_num + 1], trim='b') | ||
# steps = np.shape(x_coords)[0] | ||
# for step in range(1, steps): | ||
# fig, ax = plt.subplots() | ||
# ax.plot(x_coords[:step], y_coords[:step], color=cmap(phonon_num), linewidth=0.5) | ||
# ax.axis('off') | ||
# for spine in ['top', 'right', 'left', 'bottom']: | ||
# ax.spines[spine].set_visible(False) | ||
# ax.set_xlim([-0.55*cf.width*1e6, 0.55*cf.width*1e6]) | ||
# ax.set_ylim([0, cf.length*1e6]) | ||
# ax.set_aspect('equal') | ||
# fig.savefig(f"Frames/frame_{frame_number:0>6}.png", dpi=600, bbox_inches="tight") | ||
# plt.close(fig) | ||
# frame_number += 1 | ||
|
||
|
||
def generate_animation_xy(): | ||
"""Generate animation of phonon path in XY plane""" | ||
sys.stdout.write(f"\rAnimation: creating animation file") | ||
images = [] | ||
filenames = os.listdir("Frames/") | ||
for filename in filenames: | ||
images.append(imageio.imread(f"Frames/{filename}")) | ||
imageio.mimsave("Animated paths XY.gif", images, | ||
fps=cf.output_animation_fps, subrectangles=True) | ||
|
||
|
||
def delete_frames(): | ||
"""Delete frames after creating the animation""" | ||
folder_path = "Frames/" | ||
shutil.rmtree(folder_path) | ||
|
||
|
||
def create_animation(): | ||
"""Main function that creates the animation""" | ||
generate_frames_xy() | ||
generate_animation_xy() | ||
delete_frames() |
Oops, something went wrong.