Quantcast
Channel: Latest Discussions - COMSOL Forums
Viewing all articles
Browse latest Browse all 26527

Inserting array in comsol model struct

$
0
0
Hi,

I wanted to solve 2D Poisson's equation in a structure and for this, I need to update position dependent concentration array/matrix (rho) in the model. What is the syntax of using external function/inserting processed matrix in comsol field?

I know the process for 1D problem. For example, to insert a position dependent array in the field " equ.f " of Poisson solver model (classical PDE>Poisson's equation), I use the following syntax:

equ.f = {{'getRho(x)'}};

Here, getRho(x) is a user defined external matlab function whose work is just to interpolate the data in finite element space.

for example: the user defined function getRho(x) definition:
--------------------------------------------------------------------
function y=getRho(x)

% Load device information: 'zi' is finite difference grid points and 'rho' is the array of values at those points
load device 'zi' 'rho'

% Interpolating for FEM space and returning
y=interp1(zi,rho,x,'nearest');
----------------------------------------------------------------------

As a result, the position dependent processed concentration data are fed to comsol field: equ.f.


I want a similar process of inserting 2D position dependent concentration data into the field: equ.f.

Can someone please help me?

Viewing all articles
Browse latest Browse all 26527

Trending Articles