Coder Social home page Coder Social logo

Diffusion equation about fvtool HOT 6 CLOSED

simulkade avatar simulkade commented on May 30, 2024
Diffusion equation

from fvtool.

Comments (6)

simulkade avatar simulkade commented on May 30, 2024

Hi @ainafp

Thank you for your nice words.
Right now, you can only have the main diagonal of a tensor in the diffusion coefficient. For instance, for a 2D diffusion problem you can write:

L = 50;  % domain length
Nx = 20; % number of cells
m = createMesh2D(Nx,Nx, L,L);
D_x = 1;
D_y = 20;
D = createFaceVariable(m, [D_x, D_y]);
Mdiff = diffusionTerm(D);

or alternatively

L = 50;  % domain length
Nx = 20; % number of cells
m = createMesh2D(Nx,Nx, L,L);
D_x = 1;
D_y = 20;
D = createFaceVariable(m, 0.0);
D.xvalue(:) = D_x;
D.yvalue(:) = D_y;
Mdiff = diffusionTerm(D);

from fvtool.

simulkade avatar simulkade commented on May 30, 2024

@ainafp
Apparently, it is possible to diagonalize the diffusion tensor by finding the right coordinate.

from fvtool.

ainafp avatar ainafp commented on May 30, 2024

ok thanks! I'll try to do it diagonalizing and otherwise I will extend it to use a matrix.
Thank you for being so responsive! I saw you added the example to the toolbox too.

from fvtool.

simulkade avatar simulkade commented on May 30, 2024

Please feel free to submit a PR if you manage to extend the code. I forgot to link the example. It's good that you saw it yourself!

from fvtool.

ainafp avatar ainafp commented on May 30, 2024

Hello!
I am trying to input the tensor finally, entering vectors instead of scalars in xvalue, yvalue and zvalue.
Can I do it as FaceVariable? Or should I do some kind of mean like harmonicMean?
I am not sure I understand the difference between face and center of the cells.
Thank you in advance!

from fvtool.

simulkade avatar simulkade commented on May 30, 2024

Hi @ainafp
The fluxes are calculated on the interfaces between finite volume cells. Usually, the value of, e.g., concentration on the interface (or what I call a face variable) is calculated by linearly interpolating between the values of concentration in the neighboring cells. Also, the transport coefficients need to be calculated on the cell interfaces, that is done by using one of the averaging methods.
To answer your question about using a FaceVariable or averaging an scalar to get the FaceVariable, it depends on your specific problem. My guess is, you need to define the FaceVariable and assign the values of your diagonal tensors [ax, ay, az] to the FaceVariable, i.e.,

F = createFaceVariable(m, [ax, ay, az]);

which automatically assigns ax, ay, and az, to xvalue, yvalue, and zvalue of a FaceVariable, respectively.

P.S. I have written a post about the transport coefficients here

from fvtool.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.