How to find the potential that corresponds to some particular (x,y,z) coordinate ?

1 回表示 (過去 30 日間)
Anthony Owusu-Mensah
Anthony Owusu-Mensah 2020 年 6 月 23 日
コメント済み: darova 2020 年 6 月 26 日
Please I attached is a trajectory file from molecular dynamics simulation and potential matrix obtained by solving 3D Poisson equation.
The 3rd to 5th column are atomic positions and the 6th column is the charge density
The goal is to obtain potential by solving 3D Poisson's equation using finite difference method .
, where V(x,y,z) is the potential and rho is the charge density.
To begin with,I tabulated the charge densities over a 3D grid with the script below;
A = importdata('traj128_new.gro Charge.txt');
%%
x = str2double( A.textdata(3:end,4) ); % x positions
y = str2double( A.textdata(3:end,5) ); % y postions
z = str2double( A.textdata(3:end,6) ); % z positions
c = str2double( A.textdata(3:end,7) ); % charge
xx = linspace(min(x1),max(x1),60);
yy = linspace(min(y1),max(y1),60);
zz = linspace(min(z1),max(z1),60)
[xq,yq,zq] = meshgrid(xx,yy,zz); %query points
F = scatteredInterpolant(x,y,z,c); %Interpolant
rho = F(xq,yq,zq); % 3D charge density over a grid
I then use the charge densities tabulated over the grid to solve for the 3D potential. Both the charge density and the resulting potential are multidimensional arrays. My interest is finding the potential at some coordinate.
For instance say I have x =2.5, y = 3.5 and z = 4.5. My interest is in finding V(x,y,z), that is the the potential that corresponds to some coordinates in the volume.

回答 (1 件)

darova
darova 2020 年 6 月 24 日
YOu are doing alright. Just pass to scatteredInterpolant values without NaN
ix = ~isnan(x+y+z+c);
F = scatteredInterpolant(x(ix),y(ix),z(ix),c(ix)); %Interpolant
  4 件のコメント
Anthony Owusu-Mensah
Anthony Owusu-Mensah 2020 年 6 月 25 日
編集済み: Anthony Owusu-Mensah 2020 年 6 月 25 日
I used the (x,y,z) and c data to compute some value rho. I used the computed rho to solve for V. So given some coordinates x,y,z, what value in V corresponds to that coordinates.
Note = rho was computed using query points xq, yq and zq which is different from (x,y,z).
darova
darova 2020 年 6 月 26 日
im lost, sorry i can't help

サインインしてコメントする。

カテゴリ

Help Center および File ExchangeParticle & Nuclear Physics についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by