7
Exemplo 1 In[11]:= Clear[u, r, t] Dab = 1*^-10; R = 0.025; sR = 1*^-100; eq = D[u[t, r],t] Dab r D[rD[u[t, r],r],r]; c1 = u[0, r] == 0.98; c2 = D[u[t, r],r]/.r sR == 0; c3 = u[t, R] == 0.5 + 0.48 Exp[- 100 t]; sol1 = NDSolveValue[{eq, c1, c2, c3}, u, {t, 0, 3*^6}, {r, sR, R}] Out[19]= InterpolatingFunction Domain: 0., 3. × 10 6 , 1. × 10 -100 , 0.025 Output: scalar ContourPlot[sol1[t, r], {t, 0, 3*^6}, {r, sR, R}, AxesLabel Automatic, ColorFunction "SunsetColors", PlotLegends Automatic, FrameLabel {"tempo", "raio"}] 0 500 000 1.0 × 10 6 1.5 × 10 6 2.0 × 10 6 2.5 × 10 6 3.0 × 10 6 0.000 0.005 0.010 0.015 0.020 0.025 tempo raio 0.55 0.60 0.65 0.70 0.75 0.80 0.85 0.90 0.95

Exemplo 1 - ppgia.pucpr.brjamhour/Download/difusao.pdf · Exemplo 1 In[11]:= Clear[u, r, t] Dab = 1*^-10; R = 0.025; sR = 1*^-100; eq = D[u[t, r], t]⩵ Dab r D[r D[u[t, r], r], r]

  • Upload
    others

  • View
    3

  • Download
    0

Embed Size (px)

Citation preview

Page 1: Exemplo 1 - ppgia.pucpr.brjamhour/Download/difusao.pdf · Exemplo 1 In[11]:= Clear[u, r, t] Dab = 1*^-10; R = 0.025; sR = 1*^-100; eq = D[u[t, r], t]⩵ Dab r D[r D[u[t, r], r], r]

Exemplo 1

In[11]:= Clear[u, r, t]

Dab = 1*^-10;

R = 0.025;

sR = 1*^-100;

eq = D[u[t, r], t] ⩵ Dab r D[r D[u[t, r], r], r];

c1 = u[0, r] == 0.98;

c2 = D[u[t, r], r] /. r → sR == 0;

c3 = u[t, R] == 0.5 + 0.48 Exp[-100 t];

sol1 = NDSolveValue[{eq, c1, c2, c3}, u, {t, 0, 3*^6}, {r, sR, R}]

Out[19]= InterpolatingFunction Domain: 0., 3.×106, 1.×10-100, 0.025Output: scalar

ContourPlot[sol1[t, r], {t, 0, 3*^6}, {r, sR, R},

AxesLabel → Automatic, ColorFunction → "SunsetColors",

PlotLegends → Automatic, FrameLabel → {"tempo", "raio"}]

0 500000 1.0×106 1.5×106 2.0×106 2.5×106 3.0×1060.000

0.005

0.010

0.015

0.020

0.025

tempo

raio

0.55

0.60

0.65

0.70

0.75

0.80

0.85

0.90

0.95

Page 2: Exemplo 1 - ppgia.pucpr.brjamhour/Download/difusao.pdf · Exemplo 1 In[11]:= Clear[u, r, t] Dab = 1*^-10; R = 0.025; sR = 1*^-100; eq = D[u[t, r], t]⩵ Dab r D[r D[u[t, r], r], r]

In[20]:= RowBarLegend[{Hue[#] &, {0.5, 0.98}}],

ManipulateGraphicsFlatten{Hue[sol1[t * 3600 * 24, #]], Disk[{0, 0}, #]} & /@

Reverse@Range[1*^-6, 0.025, 0.0001], {{t, 0, "dias"}, 0, 34}

Out[20]=

0.5

0.6

0.7

0.8

0.9

dias

34.

Exemplo 2

In[21]:= Clear[eq, u, t, z]

eq = D[u[t, z], t] ⩵ Dab D[u[t, z], z, z];

c1 = D[u[t, z], z] /. z → 0.005 ⩵ 0;

c2 = D[u[t, z], z] /. z → -0.005 ⩵ 0;

c3 = u[t, 0.005] ⩵ 0.5 + 0.48 * Exp[-1000 t] ;

c4 = u[t, -0.005] ⩵ 0.5 + 0.48 * Exp[-1000 t] ;

c5 = u[0, z] ⩵ 0.98 ;

Dab = 1*^-10;

sol2 = NDSolveValue[{eq, c3, c4, c5}, u, {t, 0, 3*^5}, {z, -0.005, 0.005}];

2 difusao.nb

Page 3: Exemplo 1 - ppgia.pucpr.brjamhour/Download/difusao.pdf · Exemplo 1 In[11]:= Clear[u, r, t] Dab = 1*^-10; R = 0.025; sR = 1*^-100; eq = D[u[t, r], t]⩵ Dab r D[r D[u[t, r], r], r]

In[30]:= ContourPlot[sol2[t, z], {t, 0, 3*^5}, {z, -0.005, 0.005}, ColorFunction → "SunsetColors",

PlotLegends → Automatic, FrameLabel → {"tempo", "altura"}]

Out[30]=

0 50000 100000 150000 200000 250000 300000

-0.004

-0.002

0.000

0.002

0.004

tempo

altura

0.55

0.60

0.65

0.70

0.75

0.80

0.85

0.90

0.95

Manipulate[

Plot[sol2[t * 3600 * 24, z], {z, -0.005, 0.005}, PlotRange → {0.4, 1}]

, {{t, 0, "dias"}, 0, 3.4}]

Out[31]=

dias

3.175

-0.004 -0.002 0.000 0.002 0.004

0.5

0.6

0.7

0.8

0.9

1.0

difusao.nb 3

Page 4: Exemplo 1 - ppgia.pucpr.brjamhour/Download/difusao.pdf · Exemplo 1 In[11]:= Clear[u, r, t] Dab = 1*^-10; R = 0.025; sR = 1*^-100; eq = D[u[t, r], t]⩵ Dab r D[r D[u[t, r], r], r]

Exemplo 3

In[1]:= Clear[u, t, z]

eq = D[u[t, z], t] ⩵ Dab D[u[t, z], z, z];

c1 = D[u[t, z], z] /. z → 0 ⩵ 0;

c2 = u[t, 0.01] ⩵ 0.5 + 0.48 * Exp[-100 t] ;

c3 = u[0, z] ⩵ 0.98 ;

Dab = 1*^-10;

sol3 = NDSolveValue[{eq, c1, c2, c3}, u, {t, 0, 2*^6}, {z, 0, 0.01}];

Plot3D[sol3[t, z], {t, 0, 2*^6}, {z, 0, 0.01}, AxesLabel → Automatic, PlotRange → All]

DensityPlot[sol3[t, r], {t, 0, 1*^6}, {r, 0, 0.01},

ColorFunction → "SunsetColors", PlotLegends → Automatic]

0.5

0.6

0.7

0.8

0.9

4 difusao.nb

Page 5: Exemplo 1 - ppgia.pucpr.brjamhour/Download/difusao.pdf · Exemplo 1 In[11]:= Clear[u, r, t] Dab = 1*^-10; R = 0.025; sR = 1*^-100; eq = D[u[t, r], t]⩵ Dab r D[r D[u[t, r], r], r]

ContourPlot[sol3[t, r], {t, 0, 1 100 000}, {r, 0, 0.01}, ColorFunction → "SunsetColors",

PlotLegends → Automatic, FrameLabel → {"tempo", "altura"}]

0 200000 400000 600000 800000 1×1060.000

0.002

0.004

0.006

0.008

0.010

tempo

altura

0.55

0.60

0.65

0.70

0.75

0.80

0.85

0.90

0.95

In[9]:= Manipulate[

Plot[sol3[t, z], {z, 0, 0.01}, PlotRange → {0.4, 1}]

, {t, 0, 2*^6}]

Out[9]=

t

0.000 0.002 0.004 0.006 0.008 0.010

0.5

0.6

0.7

0.8

0.9

1.0

difusao.nb 5

Page 6: Exemplo 1 - ppgia.pucpr.brjamhour/Download/difusao.pdf · Exemplo 1 In[11]:= Clear[u, r, t] Dab = 1*^-10; R = 0.025; sR = 1*^-100; eq = D[u[t, r], t]⩵ Dab r D[r D[u[t, r], r], r]

In[10]:= Manipulate[

BarLegend[{Blend[{Red, Orange, Yellow, Green, Blue, Purple, Black},

Rescale[sol3[t, #], {0.98, 0.5}]] &, {0, 0.01}}]

, {t, 0, 2*^6}]

Out[10]=

t

1.09679×

0

0.002

0.004

0.006

0.008

0.010

Outros

(* PH *)

ph = NDSolveValue[{D[u[t, x, y], t] ⩵ D[u[t, x, y], x, x] + D[u[t, x, y], y, y],

u[0, x, y] ⩵ If[-1 < x < 1 && -1 < y < 1, 0, 1],

u[t, -1, y] ⩵ u[t, 1, y] ⩵ u[t, x, -1] ⩵ u[t, x, 1] ⩵ 1,

WhenEvent[u[t, 0, 0] ⩵ .5, {T = t, "StopIntegration"}]},

u, {t, 0, 10}, {x, -1, 1}, {y, -1, 1}];

Plot3D[ph[T, x, y], {x, -1, 1}, {y, -1, 1}]

6 difusao.nb

Page 7: Exemplo 1 - ppgia.pucpr.brjamhour/Download/difusao.pdf · Exemplo 1 In[11]:= Clear[u, r, t] Dab = 1*^-10; R = 0.025; sR = 1*^-100; eq = D[u[t, r], t]⩵ Dab r D[r D[u[t, r], r], r]

(* Transferencia de Calor *)

Clear[u, x, y, t];

L1 = 2; L2 = 2; (* length and widht of the plate *)

eq = {D[u[x, y, t], t] ⩵ D[u[x, y, t], x, x] + D[u[x, y, t], y, y]};

c1 = {u[x, y, 0] ⩵ 0};

c2 = u[0, y, t] == Sint L1;

c3 = u[x, 0, t] ⩵ -Sint L2;

c4 = u[L1, y, t] ⩵ 0;

c5 = u[x, L2, t] ⩵ 0;

sol = NDSolveValue[ {eq, c1, c2, c3, c, c5}, u, {x, 0, 2}, {y, 0, 2}, {t, 0.01, 30}]

DensityPlot3D[sol[x, y, t], {x, 0, 2}, {y, 0, 2}, {t, 0.01, 30},

ColorFunction → "TemperatureMap", PlotLegends → Automatic,

AxesLabel → Automatic, AxesStyle → Directive[Black, Thick, 15]]

u → InterpolatingFunctionDomain: {{0., 2.}, {0., 2.}, {0.01, 30.}}Output: scalar

difusao.nb 7