Characterization model of molecular interaction based on MATLAB

Molecules are constantly in irregular movement. The phenomenon of diffusion is an example of the random movement of molecules. The so-called diffusion refers to the phenomenon that two different substances enter each other when they come into contact with each other. There are both gravitational and repulsive forces between molecules. Solids can maintain a certain shape and volume and are difficult to break, indicating that there is gravitational force between molecules, while solid and liquid molecules maintain a certain gap and are difficult to be compressed, indicating that there is repulsive force between molecules. The intermolecular gravitational and repulsive forces in matter exist at the same time. Both the gravitational and repulsive forces decrease with the increase of the intermolecular distance, and the repulsive force decreases faster. When the molecular distance is a certain value r0, the gravitational force is equal to the repulsive force, and the molecules are in an equilibrium position; when the molecular distance is greater than r0, the gravitational force plays a major role; when the molecular distance is less than r0, the repulsive force plays a major role. If the molecular distance is greater than 10 times the molecular diameter, the intermolecular force becomes very weak, and it can be considered that the intermolecular force is zero at this time.

MATLAB is a high-level language for scientific and engineering calculations. It integrates the processing functions of scientific calculations, automatic control, signal processing, neural networks, and image processing. It has extremely high programming efficiency. MATLAB is a highly integrated system. Simulink provided by MATLAB is a software package for modeling, simulating and analyzing dynamic systems. It supports linear and nonlinear systems and can be used in continuous time domain, discrete time domain, or both. It also supports systems with multiple sampling rates. In the past few years, Simulink has become the most widely used software package for modeling dynamic systems in mathematical and industrial applications.

3.2 Design of molecular function

    In this example, we want to display the position of the molecule through the input coordinate values, so we first design the molecular function. The MATLAB code is as follows:

x=linspace(x1,x2,Mx);

y=linspace(y1,y2,My);

z = linspace (z1, z2, Mz);

load pot.out;

time = can (1: 220,881);

va=reshape(data,My,Mx,Mz);

load FF.out;

data1 = FF (1: 220881);

w=reshape(data1,My,Mx,Mz);

p = patch(isosurface(x, y, z, va,-0.36073643,w));

isonormals(x,y,z,va, p)

set(p, 'FaceColor', 'interp', 'EdgeColor', 'none');

hidden on

daspect([1 1 1])

view(3)

lighting phong

hsurf=isosurface(x, y, z, va,-0.3566);

vertices=hsurf.vertices(:,:);

save vertice.txt vertices -ascii;

faces=hsurf.faces(:,:);

save face.txt faces -ascii    ;     

·linspace

x=linspace(a1,a2,a3); a1 is the first element, a2 is the last element, a3 means x has a3 elements in total, and each element has the same spacing.

·load

    Load external data.

·reshape

The array can be reorganized and deformed, Y = reshape(X,m,n). The precondition that the number of elements in Y and X must be equal. Then the above command will convert X to m*n matrix.

·isosurface

Point set of the formed surface

    Then, we can get the following simulation results.

3.3 Molecular positioning design

    In this module, we mainly design such a function, input x, y, z coordinate values, and then display the molecule at the corresponding position. In this chapter 3.2, we have designed the molecular function. Below we mainly display the molecules by inputting coordinate values. The design code is as follows:

     The top-level code is:

clc;

clear;

close all;

NUM=input('Please enter the number of molecules to be displayed');

for i=1:NUM

x1=input('Please enter the upper limit of the coordinate of the molecular X axis MIN\n');

x2=input('Please enter the lower limit of the coordinate of the molecular X axis MAX\n');

y1=input('Please enter the upper limit MIN of the Y axis of the molecule MIN\n');

y2=input('Please enter the lower limit of the coordinate of the numerator Y axis MAX\n');

z1=input('Please enter the upper limit of the coordinate of the molecular Z axis MIN\n');

z2=input('Please enter the lower limit of the coordinate of the molecular Z axis MAX\n');

fenzi(x1,x2,y1,y2,z1,z2);

hold on;

end

In order to make the display effect of the system obvious, we modify the molecular function.

……………………………………

%(x1,y1,z1)UP

hndl=plot3(x1,y1,z1);

set(hndl,'markersize',30,'marker','.','color','k');

A=text(x1,y1,z1,'A');

set(A,'fontsize',18,'color','k');

hold on

%(x1,y2,z1)UP

hndl=plot3(x1,y2,z1);

set(hndl,'markersize',30,'marker','.','color','k');

B=text(x1,y2,z1,'B');

set(B,'fontsize',18,'color','k');

hold on

%(x2,y1,z1)UP

hndl=plot3(x2,y1,z1);

set(hndl,'markersize',30,'marker','.','color','k');

C=text(x2,y1,z1,'C');

set(C,'fontsize',18,'color','k');

hold on

%(x2,y2,z1)UP

hndl=plot3(x2,y2,z1);

set(hndl,'markersize',30,'marker','.','color','k');

D=text(x2,y2,z1,'D');

set(D,'fontsize',18,'color','k');

hold on

%(x1,y1,z1)DOWN

hndl=plot3(x1,y1,z2);

set(hndl,'markersize',30,'marker','.','color','k');

E=text(x1,y1,z2,'E');

set(E,'fontsize',18,'color','k');

hold on

%(x1,y2,z2)DOWN

hndl=plot3(x1,y2,z2);

set(hndl,'markersize',30,'marker','.','color','k');

F=text(x1,y2,z2,'F');

set(F,'fontsize',18,'color','k');

hold on

%(x2,y1,z2)DOWN

hndl=plot3(x2,y1,z2);

set(hndl,'markersize',30,'marker','.','color','k');

G=text(x2,y1,z2,'G');

set(G,'fontsize',18,'color','k');

hold on

%(x2,y2,z2)DOWN

hndl=plot3(x2,y2,z2);

set(hndl,'markersize',30,'marker','.','color','k');

H=text(x2,y2,z2,'H');

set(H,'fontsize',18,'color','k');

hold on

lx2=[x1 x2];ly2=[y1 y1];lz2=[z1 z1];

BL2=plot3(lx2,ly2,lz2,'b');

set(BL2,'linewidth',1);

hold on

lx4=[x1 x2];ly4=[y2 y2];lz4=[z1 z1];

BL4=plot3(lx4,ly4,lz4,'b');

set(BL4,'linewidth',1);

hold on

lx8=[x1 x2];ly8=[y2 y2];lz8=[z2 z2];

BL8=plot3(lx8,ly8,lz8,'b');

set(BL8,'linewidth',1);

hold on

lx11=[x1 x2];ly11=[y1 y1];lz11=[z2 z2];

BL11=plot3(lx11,ly11,lz11,'b');

set(BL11,'linewidth',1);

hold on

lx1=[x1 x1];ly1=[y1 y2];lz1=[z1 z1];

BL1=plot3(lx1,ly1,lz1,'b');

set(BL1,'linewidth',1);

hold on

lx7 = [x2 x2]; ly7 = [y1 y2]; lz7 = [z1 z1];

BL7=plot3(lx7,ly7,lz7,'b');

set(BL7,'linewidth',1);

hold on

lx9=[x2 x2];ly9=[y1 y2];lz9=[z2 z2];

BL9=plot3(lx9,ly9,lz9,'b');

set(BL9,'linewidth',1);

hold on

lx12=[x1 x1];ly12=[y1 y2];lz12=[z2 z2];

BL12=plot3(lx12,ly12,lz12,'b');

set(BL12,'linewidth',1);

hold on

lx3=[x1 x1];ly3=[y1 y1];lz3=[z1 z2];

BL3=plot3(lx3,ly3,lz3,'b');

set(BL3,'linewidth',1);

hold on

lx5 = [x1 x1]; ly5 = [y2 y2]; lz5 = [z1 z2];

BL5=plot3(lx5,ly5,lz5,'b');

set(BL5,'linewidth',1);

hold on

lx6=[x2 x2];ly6=[y2 y2];lz6=[z1 z2];

BL6=plot3(lx6,ly6,lz6,'b');

set(BL6,'linewidth',1);

hold on

lx10=[x2 x2];ly10=[y1 y1];lz10=[z1 z2];

BL10=plot3(lx10,ly10,lz10,'b');

set(BL10,'linewidth',1);

hold on

When we simulate the system, we can get the following results.

·Enter one minute

 

Figure 3-2 Molecular position display

·Enter two minutes

Figure 3-2 The position of multiple molecules shows the simulation effect diagram

Guess you like

Origin blog.csdn.net/ccsss22/article/details/108897545