# Discussion Forum

## Calculation of the electron energy distribution function using LiveLink for MATLAB

Hello,

Comsol has PlASMA MODULE, where we can calculate the isotropic part of the EEDF using the Boltzmann equation, but I also want to calculate the anisotropic part of the EEDF. To do this, we wrote the code in Matlab, which allows us to calculate the isotropic and anisotropic parts of the EEDF. And the problem is how to correctly make the replacement of the EEDF in Comsol so that the dimensions match correctly. The problem is solved as follows: we take the values of the reduced field and other parameters taken from the Comsol model and use them to calculate the EEDF in Matlab. Further, the calculated in Matlab EEDF used in the Comsol model to calculate the constant rates, etc. The main problem is the dimension of the data matrix loaded from Matlab to Comsol. Is it possible in Comsol to set the EEDF not via the interpolation (in this case, you will need to enter the dependence of the EEDF on the energy and average energy and this interpolation will be used in all nodes, which does not suit us), but as a function depends on the coordinates, time, the reduced field and other parameters necessary for the calculation? How to agree on the dimension of the EEDF in Matlab and Comsol? Or is there another way to calculate the anisotropic part of the EEDF in Comsol?

Thanks a lot.

1 Reply Last Post 22/04/2021, 04:39 GMT-4

Posted: 2 weeks ago

Hi Kurban

You can use the external MATLAB functions in your Comsol models.

The manual Introduction to LiveLink for Matlab has a chapter on this: "Using External MATLAB® Functions". The most crucial part of the example is this: "The functions you write must adhere to a certain structure. In order for the calls from COMSOL to MATLAB to be as efficient as possible the arguments are transferred to MATLAB in blocks. This means that for both functions, all the input arguments are vectors, and the functions needs to return vectors with the same length as the input arguments. It is highly recommended to test the functions on the MATLAB command line with some vectors arguments having reasonable values for the arguments in question."

You can define functions with any argument you want. E.g. x, y, z, t, parameter values etc.

-------------------
Lars Gregersen
Comsol Denmark