Editing Bim package
Jump to navigation
Jump to search
The edit can be undone. Please check the comparison below to verify that this is what you want to do, and then publish the changes below to finish undoing the edit.
Latest revision | Your text | ||
Line 1: | Line 1: | ||
Package for solving Diffusion Advection Reaction (DAR) Partial Differential Equations based on the Finite Volume Scharfetter-Gummel (FVSG) method a.k.a Box Integration Method (BIM). | |||
== Tutorials == | == Tutorials == | ||
Line 5: | Line 5: | ||
This is a short example on how to use <tt>bim</tt> to solve a 2D Diffusion Advection Reaction problem. | This is a short example on how to use <tt>bim</tt> to solve a 2D Diffusion Advection Reaction problem. | ||
The coplete code for this example can is on [[Agora]] at this [http://agora.octave.org/snippet/1bqV link]. | |||
We want to solve the equation | We want to solve the equation | ||
Line 65: | Line 65: | ||
to see the mesh you can use functions from the [[fpl_package|fpl package]] | to see the mesh you can use functions from the [[fpl_package|fpl package]] | ||
{{Code| | {{Code|Plot mesh in the 2D problem|<syntaxhighlight lang="octave" style="font-size:13px"> | ||
pdemesh (mesh.p, mesh.e, mesh.t) | pdemesh (mesh.p, mesh.e, mesh.t) | ||
view (2) | view (2) | ||
Line 80: | Line 80: | ||
xu = mesh.p(1,:).'; | xu = mesh.p(1,:).'; | ||
yu = mesh.p(2,:).'; | yu = mesh.p(2,:).'; | ||
</syntaxhighlight> | </syntaxhighlight>}} | ||
}} | |||
Line 91: | Line 90: | ||
</syntaxhighlight>}} | </syntaxhighlight>}} | ||
<pre> | |||
epsilon = .1; | epsilon = .1; | ||
phi = xu + yu; | phi = xu + yu; | ||
</ | </pre> | ||
<b> Construct the discretized operators</b> | <b> Construct the discretized operators</b> | ||
Line 137: | Line 136: | ||
<B> Solve for the | <B> Solve for the displacements</B> | ||
{{Code| | {{Code|Displacement in the 2D problem|<syntaxhighlight lang="octave" style="font-size:13px"> | ||
temp = [Ann Ani ; Ain Aii ] \ [ jn+bn-And*ud(GammaD) ; bi-Aid*ud(GammaD)]; | temp = [Ann Ani ; Ain Aii ] \ [ jn+bn-And*ud(GammaD) ; bi-Aid*ud(GammaD)]; | ||
u = ud; | u = ud; | ||
Line 148: | Line 147: | ||
<b> Compute the fluxes through Dirichlet sides</b><br> | <b> Compute the fluxes through Dirichlet sides</b><br> | ||
{{Code| | {{Code|Fluxes at sides in the 2D problem|<syntaxhighlight lang="octave" style="font-size:13px"> | ||
jd = [Add Adi Adn] * u([GammaD; Omega; GammaN]) - bd; | jd = [Add Adi Adn] * u([GammaD; Omega; GammaN]) - bd; | ||
</syntaxhighlight>}} | </syntaxhighlight>}} | ||
Line 161: | Line 160: | ||
<B> Compute the internal Advection-Diffusion flux</B> | <B> Compute the internal Advection-Diffusion flux</B> | ||
<pre> | |||
[jxglob, jyglob] = bim2c_global_flux (mesh, u, epsilon*ones(nelems, 1), ones(nnodes, 1), ones(nnodes, 1), phi); | [jxglob, jyglob] = bim2c_global_flux (mesh, u, epsilon*ones(nelems, 1), ones(nnodes, 1), ones(nnodes, 1), phi); | ||
</ | </pre> | ||
<B> Export data to VTK format</B> | <B> Export data to VTK format</B> | ||
Line 170: | Line 169: | ||
or [[https://wci.llnl.gov/codes/visit/|visit]] | or [[https://wci.llnl.gov/codes/visit/|visit]] | ||
<pre> | |||
fpl_vtk_write_field ("vtkdata", mesh, {u, "Solution"}, {[gx; gy]', "Gradient"}, 1); | fpl_vtk_write_field ("vtkdata", mesh, {u, "Solution"}, {[gx; gy]', "Gradient"}, 1); | ||
</ | </pre> | ||
you can also plot your data directly in Octave using <code> pdesurf </code> | you can also plot your data directly in Octave using <code> pdesurf </code> | ||
<pre> | |||
pdesurf (mesh.p, mesh.t, u) | pdesurf (mesh.p, mesh.t, u) | ||
</ | </pre> | ||
it will look like this | it will look like this | ||
Line 242: | Line 241: | ||
== External links == | == External links == | ||
* [http://octave.sourceforge.net/bim/index.html BIM package at Octave Forge]. | |||
[[Category:OctaveForge]] | |||
[[Category:Packages]] | |||
[[Category: |