# Problem with coefficient c in function form in solving 2D-PDE (PDE toolbox)

3 Ansichten (letzte 30 Tage)
Chiara Moreschini am 1 Mai 2020
I'm trying to solve a 2D-PDE with a c coefficent in function form, but i'm having some trouble in using location struct.
here is my function for c coefficient:
______________________________________________
function cmatrix = ccoeffunction(location,~)
n1 = 4;
nr = numel(location.x);
Ds=1.4e-10;
jv=2e-5;
cmatrix = zeros(n1,nr);
cmatrix(1,:) = Ds*ones(1,nr);
cmatrix(2,:) = jv*(location.y)+jv*((location.y).^3)/3;
cmatrix(3,:) = -jv*(location.x)+Ds*((location.x)./(location.y));
cmatrix(4,:) = Ds*ones(1,nr);
end
_______________________________________________
However the location struct passed to the function contains in fields x and y just one zero, so my function doesen't work correctly.
______________________________________________
location =
struct with fields:
x: 0
y: 0
z: 0
subdomain: 1
_______________________________________________
How can i pass to my function the correct location struct???
Thanks
##### 0 Kommentare-2 ältere Kommentare anzeigen-2 ältere Kommentare ausblenden

Melden Sie sich an, um zu kommentieren.

### Akzeptierte Antwort

Ravi Kumar am 1 Mai 2020
Hi Chiara,
Solver will call the function several times to check if it is returing the correct format of coeff and so on, for these probing calls a single point is used. If you continue and get past this initial calls, you will be able to see that solver eventually calls with location of several Gauss points where element matrices are integrated.
Regards,
Ravi
##### 8 Kommentare6 ältere Kommentare anzeigen6 ältere Kommentare ausblenden
Ravi Kumar am 1 Mai 2020
Well, this could be it! You say your model in nm, I am thining you geometry then shoulod be 300 nm x100 nm. In which case you need to update your geometry creation to account the correct units:
rect=[3;4;0;[300;300;0;0;0;100;100]*1E-9];
If you do so, and plot the last time step solution, then this is what I get:
pdeplot(model_sangue,'XYData',cs_b_nodi(:,end),'ZData',cs_b_nodi(:,end),'Mesh','on')
Based on time-variation, I also think your tlist needs to scaled appropriately.
Regards,
Ravi
Chiara Moreschini am 1 Mai 2020
Thank you very much!!

Melden Sie sich an, um zu kommentieren.

### Kategorien

Mehr zu Heat Transfer finden Sie in Help Center und File Exchange

### Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by