ktongue/docker_container / finite_difference /src /diffu /diffu_damping_of_sines.py
download
raw
906 Bytes
from matplotlib.pyplot import *
from numpy import *
def component(Q, x, t, k, a=1):
return Q*exp(-a*k**2*t)*sin(k*x)
def u(x, t):
return component(1, x, t, pi, 1) + component(0.1, x, t, 100*pi, 1)
x = linspace(0, 1, 2001)
a = 1
amplitudes = array([0.1, 0.01])
k = 100*pi
times1 = log(amplitudes)/(-a*k**2)
k = pi
times2 = log(amplitudes)/(-a*k**2)
times = [0] + times1.tolist() + times2.tolist()
for t in times:
figure()
plot(x, u(x,t))
title('t=%.2E' % t)
xlabel('x')
ylabel('u')
axis([0, 1, -0.1, 1.1])
savefig('tmp_%.2E.pdf' % t)
savefig('tmp_%.2E.png' % t)
import os
times = times[:1] + times[2:]
os.system('doconce combine_images tmp_%.2E.pdf tmp_%.2E.pdf tmp_%.2E.pdf tmp_%.2E.pdf diffusion_damping.pdf' % tuple(times))
os.system('doconce combine_images tmp_%.2E.png tmp_%.2E.png tmp_%.2E.png tmp_%.2E.png diffusion_damping.png' % tuple(times))
show()

Xet Storage Details

Size:
906 Bytes
·
Xet hash:
632558485b352df78242c1f0f6f307a1d5b9532078f2e1564b1cd800f8f4f34d

Xet efficiently stores files, intelligently splitting them into unique chunks and accelerating uploads and downloads. More info.