-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add implicit implementation of the scheme
- Loading branch information
Showing
8 changed files
with
178 additions
and
7 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
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,69 @@ | ||
import os | ||
import numpy as np | ||
import matplotlib | ||
import matplotlib.pyplot as plt | ||
|
||
font_size = 15 | ||
params = { | ||
'image.origin': 'lower', | ||
'image.interpolation': 'nearest', | ||
'image.cmap': 'gray', | ||
'axes.grid': False, | ||
'savefig.dpi': 500, | ||
'axes.labelsize': font_size, | ||
'axes.titlesize': font_size, | ||
'lines.markersize': 3, | ||
'lines.linewidth': 1.4, | ||
'font.size': font_size, | ||
'legend.fontsize': 13, | ||
'xtick.labelsize': font_size, | ||
'text.usetex': True, | ||
'ytick.labelsize': font_size, | ||
'font.family': 'serif', | ||
} | ||
|
||
matplotlib.rcParams.update(params) | ||
|
||
sample_path = os.path.join('singleGraph', '3', 'line_T.xy') | ||
cases = [ | ||
dict( | ||
id='explicit', | ||
style=dict(label= 'expl. RK4', color='k' , linestyle='solid'), | ||
), | ||
dict( | ||
id='implicit-Euler', | ||
style=dict(label='impl. Euler', color='tab:red', linestyle='dashed'), | ||
), | ||
dict( | ||
id='implicit-backward', | ||
style=dict(label='impl. backward', color='tab:purple' , linestyle='dashdot'), | ||
), | ||
dict( | ||
id='implicit-Crank-Nicolson', | ||
style=dict(label='impl. C-N 0.9', color='tab:blue' , linestyle='dotted'), | ||
), | ||
|
||
] | ||
|
||
plt.figure() | ||
|
||
# analytical solution | ||
L = 2*np.pi | ||
x = np.linspace(-L/2, L/2, 200) | ||
sigma = L/20 | ||
x0 = 0 | ||
T = lambda x: np.exp(-((x-x0)*(x-x0))/(2*sigma*sigma)) | ||
plt.plot(x, T(x), color='tab:gray', linestyle='dashed', label='analytical') | ||
|
||
for case in cases: | ||
data_path = os.path.join('postProcessing-' + case['id'], sample_path) | ||
d = np.loadtxt(data_path, unpack=True) | ||
plt.plot(d[0], d[1], **case['style']) | ||
|
||
|
||
plt.xlabel('x, m') | ||
plt.ylabel('T, [-]') | ||
plt.xticks(ticks=[-np.pi, -0.5*np.pi, 0, 0.5*np.pi, np.pi], labels=['$-\pi$', '$-\pi/2$', '0', '$\pi$/2', '$\pi$']) | ||
plt.legend() | ||
plt.grid() | ||
plt.savefig('convection1d_ddt.pdf') |
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,41 @@ | ||
#!/bin/sh | ||
cd ${0%/*} || exit 1 # Run from this directory | ||
|
||
foamListTimes -rm | ||
rm -r postProcessing* | ||
rm -r 0 | ||
cp -r 0.orig 0 | ||
blockMesh | ||
|
||
foamDictionary -entry "divSchemes/div(phi,T)" \ | ||
-set "GaussScaleSelective Gauss linear orthogonal 2.0 upwind blended 1.0" \ | ||
system/fvSchemes | ||
|
||
explicitRK4scalarTransportFoam | ||
postProcess -func singleGraph -latestTime | ||
mv postProcessing postProcessing-explicit | ||
foamListTimes -rm | ||
|
||
foamDictionary -entry "ddtSchemes/default" -set "Euler" \ | ||
system/fvSchemes | ||
scalarTransportFoam | ||
postProcess -func singleGraph -latestTime | ||
mv postProcessing postProcessing-implicit-Euler | ||
foamListTimes -rm | ||
|
||
foamDictionary -entry "ddtSchemes/default" -set "backward" \ | ||
system/fvSchemes | ||
scalarTransportFoam | ||
postProcess -func singleGraph -latestTime | ||
mv postProcessing postProcessing-implicit-backward | ||
foamListTimes -rm | ||
|
||
foamDictionary -entry "ddtSchemes/default" -set "CrankNicolson 0.9" \ | ||
system/fvSchemes | ||
scalarTransportFoam | ||
postProcess -func singleGraph -latestTime | ||
mv postProcessing postProcessing-implicit-Crank-Nicolson | ||
foamListTimes -rm | ||
|
||
|
||
#------------------------------------------------------------------------------ |
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