a particular hopf-cole solution to burgers' equation
DESCRIPTION
Equation World presents the Hopf-Cole technique to transform a solution to the heat equation into a solution to Burgers' equation. However, they do not allow for a non-unit viscosity and their signs differ from many spectral methods texts. This Mathematica notebook slightly generalizes Equation World's presentation to account for these differences. It additionally includes a particular Burgers' solution in both physical and spectral space to aid in numerical solver verification.TRANSCRIPT
Verifying that the basic Hopf−Cole transformation, w = 2 u-1 ux
where ut = uxx , satisfies the homogeneous Burgers’ equation wt - wxx - wwx = 0 per Equation World’s description
In[2]:= CleanSlate@D;
HCleanSlateL Contexts purged: 8Global‘<HCleanSlateL Approximate kernel memory recovered: 1 Kb
In[1]:= w@x_, t_D := ��������������������2
u@x, tD D@u@x, tD, xD;
In[2]:= terms = Expand@8D@w@x, tD, tD,-D@w@x, tD, 8x, 2<D,-w@x, tD D@w@x, tD, xD<D;
MatrixForm@termsDOut[3]//MatrixForm=
i
k
jjjjjjjjjjjjjjjjjjjjj
- ���������������������������������������������2 uH0,1L@x,tD uH1,0L@x,tD
u@x,tD2 + ������������������������2 uH1,1L@x,tD
u@x,tD
- ��������������������������4 uH1,0L@x,tD3
u@x,tD3 + ���������������������������������������������6 uH1,0L@x,tD uH2,0L@x,tD
u@x,tD2 - ������������������������2 uH3,0L@x,tD
u@x,tD
��������������������������4 uH1,0L@x,tD3
u@x,tD3 - ���������������������������������������������4 uH1,0L@x,tD uH2,0L@x,tD
u@x,tD2
y
{
zzzzzzzzzzzzzzzzzzzzz
In[4]:= transformedTerms = Expand@terms ��. 8D@u@x, tD, 8x, 2<D ® D@u@x, tD, tD,D@u@x, tD, 8x, 3<D ® D@u@x, tD, 8x, 1<, 8t, 1<D<D;
MatrixForm@transformedTermsDOut[5]//MatrixForm=
i
k
jjjjjjjjjjjjjjjjjjjjj
- ���������������������������������������������2 uH0,1L@x,tD uH1,0L@x,tD
u@x,tD2 + ������������������������2 uH1,1L@x,tD
u@x,tD
���������������������������������������������6 uH0,1L@x,tD uH1,0L@x,tD
u@x,tD2 - ��������������������������4 uH1,0L@x,tD3
u@x,tD3 - ������������������������2 uH1,1L@x,tD
u@x,tD
- ���������������������������������������������4 uH0,1L@x,tD uH1,0L@x,tD
u@x,tD2 + ��������������������������4 uH1,0L@x,tD3
u@x,tD3
y
{
zzzzzzzzzzzzzzzzzzzzz
In[6]:= residual = Total@transformedTermsD
Out[6]= 0
Verifying the Hopf−Cole transformation, w = -2 Νu-1 ux where
ut = Νuxx , satisfies the homogenous Burgers’ variant wt - Νwxx + wwx = 0 with constant Ν
In[7]:= CleanSlate@D;
HCleanSlateL Contexts purged: 8Global‘<HCleanSlateL Approximate kernel memory recovered: 0 Kb
In[1]:= w@x_, t_D := ��������������������-2 Ν
u@x, tD D@u@x, tD, xD;
In[2]:= terms = Expand@8D@w@x, tD, tD,-Ν D@w@x, tD, 8x, 2<D,w@x, tD D@w@x, tD, xD<D;
MatrixForm@termsDOut[3]//MatrixForm=
i
k
jjjjjjjjjjjjjjjjjjjjj
������������������������������������������������2 Ν uH0,1L@x,tD uH1,0L@x,tD
u@x,tD2 - ���������������������������2 Ν uH1,1L@x,tD
u@x,tD
������������������������������4 Ν2 uH1,0L@x,tD3
u@x,tD3 - ��������������������������������������������������6 Ν2 uH1,0L@x,tD uH2,0L@x,tD
u@x,tD2 + �����������������������������2 Ν2 uH3,0L@x,tD
u@x,tD
- ������������������������������4 Ν2 uH1,0L@x,tD3
u@x,tD3 + ��������������������������������������������������4 Ν2 uH1,0L@x,tD uH2,0L@x,tD
u@x,tD2
y
{
zzzzzzzzzzzzzzzzzzzzz
In[4]:= transformedTerms = ExpandBterms ��. :
D@u@x, tD, 8x, 2<D ® ���1
Ν D@u@x, tD, tD,
D@u@x, tD, 8x, 3<D ® ���1
Ν D@u@x, tD, 8x, 1<, 8t, 1<D
>F;MatrixForm@transformedTermsD
Out[5]//MatrixForm=
i
k
jjjjjjjjjjjjjjjjjjjjj
������������������������������������������������2 Ν uH0,1L@x,tD uH1,0L@x,tD
u@x,tD2 - ���������������������������2 Ν uH1,1L@x,tD
u@x,tD
- ������������������������������������������������6 Ν uH0,1L@x,tD uH1,0L@x,tD
u@x,tD2 + ������������������������������4 Ν2 uH1,0L@x,tD3
u@x,tD3 + ���������������������������2 Ν uH1,1L@x,tD
u@x,tD
������������������������������������������������4 Ν uH0,1L@x,tD uH1,0L@x,tD
u@x,tD2 - ������������������������������4 Ν2 uH1,0L@x,tD3
u@x,tD3
y
{
zzzzzzzzzzzzzzzzzzzzz
In[6]:= residual = Total@transformedTermsD
Out[6]= 0
Verifying the complex exponential series solution u of the equation ut = Νuxx on the periodic domain [0,L)
Because the equation is linear, we may verify each term independently.
In[7]:= CleanSlate@D;
HCleanSlateL Contexts purged: 8Global‘<HCleanSlateL Approximate kernel memory recovered: 18 Kb
In[1]:= u@x_, t_, n_D := u`@nD ExpB-
ikjjjj ������������2 n Π
L
y{zzzz2
Ν tF ExpBäikjjjj ������������2 n Π
L
y{zzzz xF;
2 Hopf−Cole.nb
In[2]:= terms = Expand@8D@u@x, t, nD, tD,-Ν D@u@x, t, nD, 8x, 2<D<D;
MatrixForm@termsDOut[3]//MatrixForm=
i
k
jjjjjjjjjjjjjjjj
- �����������������������������������������������������4 ã
�������������������2 ä n Π x
L- ��������������������������4 n2 Π2 t Ν
L2 n2 Π2 Ν u`@nD
L2
�����������������������������������������������������4 ã
�������������������2 ä n Π x
L- ��������������������������4 n2 Π2 t Ν
L2 n2 Π2 Ν u`@nD
L2
y
{
zzzzzzzzzzzzzzzz
In[4]:= residual = Simplify@8Total@termsD,Hu@x, t, nD �. x ® 0L - Hu@x, t, nD �. x ® LL,HD@u@x, t, nD, xD �. x ® 0L - HD@u@x, t, nD, xD �. x ® LL<, n Î IntegersD
Out[4]= 80, 0, 0<
Verifying that complex exponential series solution u of ut = Νuxx transformed by the Hopf−Cole variant w = -2 Νu-1
ux satisfies the homogeneous Burgers’ equation wt - Νwxx + wwx = 0 on the periodic domain [0,L) with constant Ν
In[5]:= CleanSlate@D;
HCleanSlateL Contexts purged: 8Global‘<HCleanSlateL Approximate kernel memory recovered: 14 Kb
We verify for only a small number of terms because of the nonlinear nature of the equation.
In[1]:= u@x_, t_D :=ân=-3
3u`@nD ExpB-
ikjjjj ������������2 n Π
L
y{zzzz2
Ν tF ExpBäikjjjj ������������2 n Π
L
y{zzzz xF;
In[2]:= w@x_, t_D := ��������������������-2 Ν
u@x, tD D@u@x, tD, xD;
Hopf−Cole.nb 3
In[3]:= terms = Expand@8D@w@x, tD, tD,-Ν D@w@x, tD, 8x, 2<D,w@x, tD D@w@x, tD, xD<D;
MatrixForm@termsDOut[4]//MatrixForm=
A very large output was generated. Here is a sample of it:
i
k
jjjjjjjjjjjjjjjjjjjjjj
�����������������������������������������������������������������������������������������������������������������������������������������432 ä ã
- ������������������12 ä Π x
L- ����������������������72 Π2 t Ν
L2 Π3 Ν2 u`@-3D2
L3ikjjjjjjjã
- �������������������������������������������6 ä �1� �1� x
L- ��������������
�1�
�1� u`@-3D+ã�1� �1�+�3�+�1�+ã
���������������1�
L-�1�
u`@3Dy
{zzzzzzz2
+ ��������������������������������������������480 ä �3� u
`@-3D u`@-2DL3 H�1�L2 + �����������
�1�
�1�+ �31� + ��������������������
128 �5�
L3 H�1�L + ��������
L3ikjjjjjjjjjã
�1�
�1�
Show Less Show More Show Full Output Set Size Limit...
In[5]:= residual = FullSimplify@8Total@termsD,Hw@x, tD �. x ® 0L - Hw@x, tD �. x ® LL,HD@w@x, tD, xD �. x ® 0L - HD@w@x, tD, xD �. x ® LL<, 8n Î Integers, t > 0, L > 0, Ν > 0<D;
MatrixForm@residualDOut[6]//MatrixForm=
i
kjjjjjjjj0
0
0
y
{zzzzzzzz
The closed form of the solution:
In[7]:= FullSimplify@w@x, tDD
Out[7]=ikjjj4 ä Π Ν
ikjjj3 u`@-3D + 2 ã
��������������������������������2 Π Hä L x+10 Π t ΝL
L2 u`@-2D +
ã������������������������������4 Π Hä L x+8 Π t ΝL
L2 u`@-1D - ã
������������������������������8 Π Hä L x+4 Π t ΝL
L2 u`@1D - 2 ã
��������������������������������10 Π Hä L x+2 Π t ΝL
L2 u`@2D - 3 ã
�������������12 ä Π x
L u`@3Dy{
zzzy{zzz �
ikjjjL ikjjju`@-3D + ã
��������������������������������2 Π Hä L x+10 Π t ΝL
L2 u`@-2D + ã
������������������������������4 Π Hä L x+8 Π t ΝL
L2 u`@-1D + ã
������������������������������6 Π Hä L x+6 Π t ΝL
L2 u`@0D +
ã������������������������������8 Π Hä L x+4 Π t ΝL
L2 u`@1D + ã
��������������������������������10 Π Hä L x+2 Π t ΝL
L2 u`@2D + ã
�������������12 ä Π x
L u`@3Dy{
zzzy{zzz
A particular Burgers’ equation solution for solver verification
In[8]:= CleanSlate@D;
HCleanSlateL Contexts purged: 8Global‘<HCleanSlateL Approximate kernel memory recovered: 0 Kb
4 Hopf−Cole.nb
In[1]:= L = 2 Π;Ν = 1;tinitial = 0; tfinal = 1; tstep = Htfinal - tinitialL�10;times = Range@tinitial, tfinal, tstepD;Nsamples = 1024;
u`@n_D :=
Ø≤≤≤≤≤≤≤≤≤≤≤≤≤∞
±
≤≤≤≤≤≤≤≤≤≤≤≤≤
u`@-nD n < 0
4 n � 0
2 n � 1
1 n � 2
0 n � 3
0 n > 3
In[7]:= u@x_, t_D :=ân=-3
3u`@nD ExpB-
ikjjjj ������������2 n Π
L
y{zzzz2
Ν tF ExpBäikjjjj ������������2 n Π
L
y{zzzz xF;
In[8]:= w@x_, t_D = ��������������������-2 Ν
u@x, tD D@u@x, tD, xD;
In physical space, the closed form of the solution is:
In[9]:= FullSimplify@w@x, tDD
Out[9]= - �������������������������������������������������������������������������������������������������������
4 ä I-1 + ã2 ä xM I1 + ã3 t+ä x + ã2 ä xM1 + 2 ã3 t+ä x + 4 ã4 t+2 ä x + 2 ã3 t+3 ä x + ã4 ä x
If, in addition, we require the input arguments to be purely real, the closed form of the solution is:
In[10]:= FullSimplify@ComplexExpand@w@x, tDDD
Out[10]= ������������������������������������������������������������������������������
4 Iã3 t + 2 Cos@xDM Sin@xD2 ã4 t + 2 ã3 t Cos@xD + Cos@2 xD
In physical space, the initial condition is:
In[11]:= FullSimplify@w@x, 0DD
Out[11]= �����������������������������������������������������������
4 HSin@xD + Sin@2 xDL2 + 2 Cos@xD + Cos@2 xD
We verify a zero residual for this solution:
In[12]:= terms = Expand@8D@w@x, tD, tD,-Ν D@w@x, tD, 8x, 2<D,w@x, tD D@w@x, tD, xD<D;
residual = FullSimplify@8Total@termsD,Hw@x, tD �. x ® 0L - Hw@x, tD �. x ® LL,HD@w@x, tD, xD �. x ® 0L - HD@w@x, tD, xD �. x ® LL<, 8n Î Integers<D;
MatrixForm@residualDOut[14]//MatrixForm=
i
kjjjjjjjj0
0
0
y
{zzzzzzzz
In physical space the solution looks like:
Hopf−Cole.nb 5
In[15]:= Plot3D@w@x, tD, 8x, 0, L<, 8t, tinitial, tfinal<, 8PlotRange ® 8Full, Full, Full<,AxesLabel ® 8"x", "t", "w@x,tD"<,Ticks ® 880, Π, 2 Π<, Automatic, Automatic<<D
Out[15]=
We sample the solution to allow comparison with spectral methods:
In[16]:= sampleW@npoints_, times_D := TableB
ChopBNBTableBwB ���������������������2 Рj
npoints, tF, 8j, 0, npoints - 1<FFF
, 8t, times<F;physicalData = sampleW@Nsamples, timesD;ListPlot3D@physicalData, 8PlotRange ® 8Full, Full, Full<,DataRange ® 880, L<, 80, tfinal<<,AxesLabel ® 8"j", "t", "w@xj,tD"<<D
Out[18]=
6 Hopf−Cole.nb
Transform each timestep into spectral space , using the signal processing convention that we normalize the forward transform by1/N:
In[19]:= spectralData = Chop@Map@Fourier@ð, FourierParameters ® 81, -1<D &, physicalDataDD;
In[20]:= waveNumberPairs@xs_D := Module@8n2floor = Floor@Length@xsD�2D,n2ceiling = Ceiling@Length@xsD�2D,<,H*Map from DFT coefficient array to one of 88wavenumber,coefficient<< *LSort@MapThread@List, 8
RotateLeft@Range@-n2floor, n2ceiling - 1D, n2floorD, xs<DD
D;spectralPairs = Map@waveNumberPairs, spectralDataD;spectralAbsPairs = Map@waveNumberPairs, Abs@spectralDataDD;spectralArgPairs = Map@waveNumberPairs, Arg@spectralDataDD;
� Spectrum detail for initial time:
In[24]:= ListLogPlotATooltip@spectralAbsPairs@@1DDD, 9PlotRange ® 8Full, Full<, AxesLabel ® 9kn, Abs@w`D=, Filling ® Axis
=E
Out[24]=
Hopf−Cole.nb 7
In[25]:= sortPairsByMagnitude@xs_D := Sort@xs, Abs@Last@ð1DD > Abs@Last@ð2DD &D;Take@sortPairsByMagnitude@spectralPairs@@1DDD, 16D �� TableForm
Out[26]//TableForm=
1 -1052.94 ä
-1 1052.94 ä
2 -875.924 ä
-2 875.924 ä
3 814.673 ä
-3 -814.673 ä
5 -222.369 ä
-5 222.369 ä
6 154.384 ä
-6 -154.384 ä
4 -115.767 ä
-4 115.767 ä
8 -52.1693 ä
-8 52.1693 ä
9 27.663 ä
-9 -27.663 ä
� Spectrum detail for final time:
In[27]:= ListLogPlotATooltip@spectralAbsPairs@@-1DDD, 9PlotRange ® 8Full, Full<, AxesLabel ® 9kn, Abs@w`D=, Filling ® Axis
=E
Out[27]=
8 Hopf−Cole.nb
In[28]:= sortPairsByMagnitude@xs_D := Sort@xs, Abs@Last@ð1DD > Abs@Last@ð2DD &D;Take@sortPairsByMagnitude@spectralPairs@@-1DDD, 16D �� TableForm
Out[29]//TableForm=
1 -388.425 ä
-1 388.425 ä
2 54.2387 ä
-2 -54.2387 ä
3 -8.44437 ä
-3 8.44437 ä
4 1.34427 ä
-4 -1.34427 ä
5 -0.214898 ä
-5 0.214898 ä
6 0.0343808 ä
-6 -0.0343808 ä
7 -0.00550127 ä
-7 0.00550127 ä
8 0.000880282 ä
-8 -0.000880282 ä
� Spectra details for all sampled times:
Obtain {n, t, value} triples for each sampled quantity :
In[30]:= spectralTriples = Flatten@MapThread@Insert@ð2, ð1, Table@8j, 2<, 8j, Length@ð2D<DD &,8times, spectralPairs<D, 1D;
spectralTriples = Select@spectralTriples, Abs@ð@@3DDD > 0 &D;spectralAbsTriples = Map@8ð@@1DD, ð@@2DD, Abs@ð@@3DDD< &, spectralTriplesD;spectralArgTriples = Map@8ð@@1DD, ð@@2DD, Arg@ð@@3DDD< &, spectralTriplesD;
In[34]:= ListPlot3DAspectralAbsTriples, 9PlotRange ® Full, AxesLabel ® 9kn, t, Abs@w`D==E
Out[34]=
Hopf−Cole.nb 9