├── .github └── workflows │ ├── macos.yml │ ├── ubuntu.yml │ └── windows.yml ├── Atif ├── example │ ├── input_example.dat │ ├── input_example1.dat │ ├── input_example2.dat │ └── input_example3.dat └── src │ ├── cmake │ ├── AtifLx │ ├── AtifOS │ ├── CMakeLists.txt │ └── Makefile │ └── source │ ├── Initialization.cpp │ ├── Initialization.h │ ├── besselfunction.cpp │ ├── besselfunction.h │ ├── bulkchempotential.cpp │ ├── bulkchempotential.h │ ├── bulkchempotentialDFT.cpp │ ├── bulkchempotentialDFT.h │ ├── bulkgama.cpp │ ├── bulkgama.h │ ├── calculategama.cpp │ ├── calculategama.h │ ├── chargeshell.cpp │ ├── chargeshell.h │ ├── clibrary.h │ ├── constantnum.h │ ├── createdirectory.h │ ├── derivelectrocorrel.cpp │ ├── derivelectrocorrel.h │ ├── derivhardspherechain.cpp │ ├── derivhardspherechain.h │ ├── energycalculation.cpp │ ├── energycalculation.h │ ├── energyelectrochain.cpp │ ├── energyelectrochain.h │ ├── energyhardspherechain.cpp │ ├── energyhardspherechain.h │ ├── energyimagecharge.cpp │ ├── energyimagecharge.h │ ├── eulerlagrangeequation.cpp │ ├── eulerlagrangeequation.h │ ├── eulerlagrangeequationDFT.cpp │ ├── eulerlagrangeequationDFT.h │ ├── externalpotential.cpp │ ├── externalpotential.h │ ├── fileoutput.cpp │ ├── fileoutput.h │ ├── gaussianintegration.cpp │ ├── gaussianintegration.h │ ├── getnumbersbyline.cpp │ ├── getnumbersbyline.h │ ├── imagecharge.cpp │ ├── imagecharge.h │ ├── inhomvandelwaal.cpp │ ├── inhomvandelwaal.h │ ├── localgama.cpp │ ├── localgama.h │ ├── main.cpp │ ├── main.h │ ├── mark.dat │ ├── poissonequation.cpp │ ├── poissonequation.h │ ├── psichargeshell.cpp │ ├── psichargeshell.h │ ├── renormGLGR.cpp │ ├── renormGLGR.h │ ├── renormalization.cpp │ ├── renormalization.h │ ├── renormeulerlagrange.cpp │ ├── renormeulerlagrange.h │ ├── rombergintegration.cpp │ ├── rombergintegration.h │ ├── simpsonintegration.cpp │ ├── simpsonintegration.h │ ├── systemset.cpp │ ├── systemset.h │ ├── volumefraction.cpp │ ├── volumefraction.h │ ├── weighteddensity.cpp │ └── weighteddensity.h ├── GETTINGSTART.md ├── LICENSE.md └── README.md /.github/workflows/macos.yml: -------------------------------------------------------------------------------- 1 | name: macOS 2 | 3 | on: 4 | push: 5 | branches: [ "main" ] 6 | pull_request: 7 | branches: [ "main" ] 8 | 9 | jobs: 10 | build: 11 | 12 | runs-on: macos-latest 13 | 14 | steps: 15 | - uses: actions/checkout@v3 16 | 17 | - name: make 18 | run: cd Atif/src/cmake && make 19 | 20 | - uses: actions/upload-artifact@v3 21 | with: 22 | name: macOS 23 | path: ./Atif/src/cmake/AtifExe 24 | -------------------------------------------------------------------------------- /.github/workflows/ubuntu.yml: -------------------------------------------------------------------------------- 1 | name: Ubuntu 2 | 3 | on: 4 | push: 5 | branches: [ "main" ] 6 | pull_request: 7 | branches: [ "main" ] 8 | 9 | jobs: 10 | build: 11 | 12 | runs-on: ubuntu-latest 13 | 14 | steps: 15 | - uses: actions/checkout@v3 16 | 17 | - name: make 18 | run: cd Atif/src/cmake && make 19 | 20 | - uses: actions/upload-artifact@v3 21 | with: 22 | name: ubuntu 23 | path: ./Atif/src/cmake/AtifExe 24 | -------------------------------------------------------------------------------- /.github/workflows/windows.yml: -------------------------------------------------------------------------------- 1 | name: Windows 2 | 3 | on: 4 | push: 5 | branches: [ "main" ] 6 | pull_request: 7 | branches: [ "main" ] 8 | 9 | jobs: 10 | build: 11 | 12 | runs-on: Windows-latest 13 | 14 | steps: 15 | - uses: actions/checkout@v3 16 | 17 | - name: show current pwd 18 | run: pwd 19 | 20 | - name: cmake generate 21 | run: mkdir D:\\a\\Atif\\Atif\\Atif\\build && cd D:\\a\\Atif\\Atif\\Atif\\build && pwd && cmake ../src/cmake 22 | 23 | - name: cmake build 24 | run: cd D:\\a\\Atif\\Atif\\Atif\\build && cmake --build . --config Release 25 | 26 | 27 | - name: ls files 28 | run: cd D:\\a\\Atif\\Atif\\Atif\\build && ls 29 | 30 | - uses: actions/upload-artifact@v3 31 | with: 32 | name: Windows 33 | path: D:\\a\\Atif\\Atif\\Atif\\build\\Release\\AtifExe.exe 34 | -------------------------------------------------------------------------------- /Atif/example/input_example.dat: -------------------------------------------------------------------------------- 1 | =================================================================================== 2 | /**************The lines below are for the parameters of the system **************/ 3 | =================================================================================== 4 | /***Method: DFT/SCFT; geometry: Planar/Spherical/Cylindrical; # of surface: Single/ 5 | Two; the model of short-range external potential: LJ(Lenard-Jones)/SW(Square-well) 6 | potential; Charge shell model: 0<=B<=A<=1 (B&A: parameters in charge shell model)*/ 7 | METHOD: 8 | DFT; Planar; Two; SW; 1.0, 0.0 9 | =================================================================================== 10 | /****Polymer. Polymer 1(poly-1): monomer concentration [M]: rhopm1, polymerization: 11 | mp1, # of blocks: nb1, Chain Model, Bending potential; Poly-2: similar with poly-1/ 12 | POLYMER: 13 | 0.1, 40, 1, Flexible, 0; 0.0, 0, 0, Flexible, 0 14 | =================================================================================== 15 | /*Sequence. 1st line: monomer # of each block of poly-1: mb1[]; 2nd line for poly-2 16 | : mb2[]; 3rd line: valency of each block of poly-1: z1[]; 4th line for poly-2: z2[]/ 17 | SEQUENCE: 18 | 40 19 | 0 20 | -1 21 | 0 22 | =================================================================================== 23 | /***************The box size and the step length: unit [see below]****************/ 24 | SIZE: 25 | 8; 0.01 26 | =================================================================================== 27 | /***Salt concentration [M] and total volume fraction (for incompressible system)**/ 28 | SALT_HS: 29 | 0.0; 0.74 30 | =================================================================================== 31 | /*External potential. Surface charge density: (C/m^2). Short-range force: monomers, 32 | positive salt, negative salt, positive counterion, negative counterion, solvent***/ 33 | WALL: 34 | 0.02; 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 35 | =================================================================================== 36 | /**Set pairwise interaction (kBT): monomers; positive salt; negative salt; positive 37 | counterions; negative counterions*****/ 38 | ENERGY: 39 | 0.0; 0.0 40 | 0.0; 0.0 41 | =================================================================================== 42 | /*****Set valency. Salt(positive : negative); counterion(positive : negative)*****/ 43 | VALENCY: 44 | 1 : -1; 1 : -1 45 | =================================================================================== 46 | /**********Set diameters (unit: see below). Monomers; positive salt; negative salt; 47 | positive counterion; negative counterion; hard sphere solvent********************/ 48 | DIAMETER: 49 | 1.0; 1.0; 1.0; 1.0; 1.0; 1.0 50 | =================================================================================== 51 | /*Dielectric constant: solution, surfaces; temperature (K); length unit of system**/ 52 | PERMITEMLEN: 53 | 78.5, 78.5; 298.15; 4.0E-10 54 | =================================================================================== 55 | /******Iterative parameters. maximum iteration #: maxItera; Picard mixture: mixCoe; 56 | Charging step: cstep; Guess surface potential: phL_L; Error tolerance: errTol*****/ 57 | ITERATIVE: 58 | 1E5; 0.001; 1; 0.0; 1.0E-7 59 | =================================================================================== 60 | /**********************Set the path for the output file ***************************/ 61 | FILEPATH: 62 | ~/Atif/output/examples/ 63 | =================================================================================== 64 | -------------------------------------------------------------------------------- /Atif/example/input_example1.dat: -------------------------------------------------------------------------------- 1 | =================================================================================== 2 | /**************The lines below are for the parameters of the system **************/ 3 | =================================================================================== 4 | /***Method: DFT/SCFT; geometry: Planar/Spherical/Cylindrical; # of surface: Single/ 5 | Two; the model of short-range external potential: LJ(Lenard-Jones)/SW(Square-well) 6 | potential; Charge shell model: 0<=B<=A<=1 (B&A: parameters in charge shell model)*/ 7 | METHOD: 8 | DFT; Planar; Single; SW; 1.0, 0.0 9 | =================================================================================== 10 | /****Polymer. Polymer 1(poly-1): monomer concentration [M]: rhopm1, polymerization: 11 | mp1, # of blocks: nb1, Chain Model, Bending potential; Poly-2: similar with poly-1/ 12 | POLYMER: 13 | 0.0, 40, 1, Flexible, 0; 0.0, 50, 1, Semi-flexible, 0 14 | =================================================================================== 15 | /*Sequence. 1st line: monomer # of each block of poly-1: mb1[]; 2nd line for poly-2 16 | : mb2[]; 3rd line: valency of each block of poly-1: z1[]; 4th line for poly-2: z2[]/ 17 | SEQUENCE: 18 | 40 19 | 40 20 | -1 21 | -1 22 | =================================================================================== 23 | /***************The box size and the step length: unit [see below]****************/ 24 | SIZE: 25 | 30; 0.01 26 | =================================================================================== 27 | /***Salt concentration [M] and total volume fraction (for incompressible system)**/ 28 | SALT_HS: 29 | 0.1; 0.74 30 | =================================================================================== 31 | /*External potential. Surface charge density: (C/m^2). Short-range force: monomers, 32 | positive salt, negative salt, positive counterion, negative counterion, solvent***/ 33 | WALL: 34 | 0.0; 0.0, 0.0, 0.0, 0.0, 0.0 35 | =================================================================================== 36 | /**Set pairwise interaction (kBT): monomers; positive salt; negative salt; positive 37 | counterions; negative counterions*****/ 38 | ENERGY: 39 | 0.0; 0.0 40 | 0.0; 0.0 41 | =================================================================================== 42 | /*****Set valency. Salt(positive : negative); counterion(positive : negative)*****/ 43 | VALENCY: 44 | 2 : -1; 1 : -1 45 | =================================================================================== 46 | /**********Set diameters (unit: see below). Monomers; positive salt; negative salt; 47 | positive counterion; negative counterion; hard sphere solvent********************/ 48 | DIAMETER: 49 | 2; 1; 1; 1; 1 50 | =================================================================================== 51 | /*Dielectric constant: solution, surfaces; temperature (K); length unit of system**/ 52 | PERMITEMLEN: 53 | 78.5, 78.5; 298.15; 3.0E-10 54 | =================================================================================== 55 | /******Iterative parameters. maximum iteration #: maxItera; Picard mixture: mixCoe; 56 | Charging step: cstep; Guess surface potential: phL_L; Error tolerance: errTol*****/ 57 | ITERATIVE: 58 | 1E5; 0.001; 1; 0.0; 1.0E-7 59 | =================================================================================== 60 | /**********************Set the path for the output file ***************************/ 61 | FILEPATH: 62 | ~/Atif/output/example1/DFT/ 63 | =================================================================================== 64 | -------------------------------------------------------------------------------- /Atif/example/input_example2.dat: -------------------------------------------------------------------------------- 1 | =================================================================================== 2 | /**************The lines below are for the parameters of the system **************/ 3 | =================================================================================== 4 | /***Method: DFT/SCFT; geometry: Planar/Spherical/Cylindrical; # of surface: Single/ 5 | Two; the model of short-range external potential: LJ(Lenard-Jones)/SW(Square-well) 6 | potential; Charge shell model: 0<=B<=A<=1 (B&A: parameters in charge shell model)*/ 7 | METHOD: 8 | DFT; Planar; Single; SW; 1.0, 0.0 9 | =================================================================================== 10 | /****Polymer. Polymer 1(poly-1): monomer concentration [M]: rhopm1, polymerization: 11 | mp1, # of blocks: nb1, Chain Model, Bending potential; Poly-2: similar with poly-1/ 12 | POLYMER: 13 | 0.1, 40, 8, Semi-flexible, 10; 0.0, 0, 0, Flexible, 0 14 | =================================================================================== 15 | /*Sequence. 1st line: monomer # of each block of poly-1: mb1[]; 2nd line for poly-2 16 | : mb2[]; 3rd line: valency of each block of poly-1: z1[]; 4th line for poly-2: z2[]/ 17 | SEQUENCE: 18 | 5; 5; 5; 5; 5; 5; 5; 5 19 | 0 20 | -1; 0; -1; 0; -1; 0; -1; 0 21 | 0 22 | =================================================================================== 23 | /***************The box size and the step length: unit [see below]****************/ 24 | SIZE: 25 | 20; 0.02 26 | =================================================================================== 27 | /***Salt concentration [M] and total volume fraction (for incompressible system)**/ 28 | SALT_HS: 29 | 0.0; 0.74 30 | =================================================================================== 31 | /*External potential. Surface charge density: (C/m^2). Short-range force: monomers, 32 | positive salt, negative salt, positive counterion, negative counterion, solvent***/ 33 | WALL: 34 | 0.02; 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 35 | =================================================================================== 36 | /**Set pairwise interaction (kBT): monomers; positive salt; negative salt; positive 37 | counterions; negative counterions*****/ 38 | ENERGY: 39 | 0.0; 0.0 40 | 0.0; 0.0 41 | =================================================================================== 42 | /*****Set valency. Salt(positive : negative); counterion(positive : negative)*****/ 43 | VALENCY: 44 | 1 : -1; 1 : -1 45 | =================================================================================== 46 | /**********Set diameters (unit: see below). Monomers; positive salt; negative salt; 47 | positive counterion; negative counterion; hard sphere solvent********************/ 48 | DIAMETER: 49 | 1.0; 1.0; 1.0; 1.0; 1.0; 1.0; 1.0; 1.0; 1.0; 1.0; 1.0; 1.0; 1.0 50 | =================================================================================== 51 | /*Dielectric constant: solution, surfaces; temperature (K); length unit of system**/ 52 | PERMITEMLEN: 53 | 78.5, 78.5; 298.15; 4.0E-10 54 | =================================================================================== 55 | /******Iterative parameters. maximum iteration #: maxItera; Picard mixture: mixCoe; 56 | Charging step: cstep; Guess surface potential: phL_L; Error tolerance: errTol*****/ 57 | ITERATIVE: 58 | 1E5; 0.001; 1; 0.0; 1.0E-7 59 | =================================================================================== 60 | /**********************Set the path for the output file ***************************/ 61 | FILEPATH: 62 | ~/Atif/output/example2/DFT/ 63 | =================================================================================== 64 | -------------------------------------------------------------------------------- /Atif/example/input_example3.dat: -------------------------------------------------------------------------------- 1 | =================================================================================== 2 | /**************The lines below are for the parameters of the system **************/ 3 | =================================================================================== 4 | /***Method: DFT/SCFT; geometry: Planar/Spherical/Cylindrical; # of surface: Single/ 5 | Two; the model of short-range external potential: LJ(Lenard-Jones)/SW(Square-well) 6 | potential; Charge shell model: 0<=B<=A<=1 (B&A: parameters in charge shell model)*/ 7 | METHOD: 8 | DFT; Planar; Two; SW; 1.0, 0.0 9 | =================================================================================== 10 | /****Polymer. Polymer 1(poly-1): monomer concentration [M]: rhopm1, polymerization: 11 | mp1, # of blocks: nb1, Chain Model, Bending potential; Poly-2: similar with poly-1/ 12 | POLYMER: 13 | 0.1, 40, 1, Flexible, 0; 0.0, 0, 0, Flexible, 0 14 | =================================================================================== 15 | /*Sequence. 1st line: monomer # of each block of poly-1: mb1[]; 2nd line for poly-2 16 | : mb2[]; 3rd line: valency of each block of poly-1: z1[]; 4th line for poly-2: z2[]/ 17 | SEQUENCE: 18 | 40 19 | 0 20 | -1 21 | 0 22 | =================================================================================== 23 | /***************The box size and the step length: unit [see below]****************/ 24 | SIZE: 25 | 8; 0.01 26 | =================================================================================== 27 | /***Salt concentration [M] and total volume fraction (for incompressible system)**/ 28 | SALT_HS: 29 | 0.0; 0.74 30 | =================================================================================== 31 | /*External potential. Surface charge density: (C/m^2). Short-range force: monomers, 32 | positive salt, negative salt, positive counterion, negative counterion, solvent***/ 33 | WALL: 34 | 0.02; 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 35 | =================================================================================== 36 | /**Set pairwise interaction (kBT): monomers; positive salt; negative salt; positive 37 | counterions; negative counterions*****/ 38 | ENERGY: 39 | 0.0; 0.0 40 | 0.0; 0.0 41 | =================================================================================== 42 | /*****Set valency. Salt(positive : negative); counterion(positive : negative)*****/ 43 | VALENCY: 44 | 1 : -1; 1 : -1 45 | =================================================================================== 46 | /**********Set diameters (unit: see below). Monomers; positive salt; negative salt; 47 | positive counterion; negative counterion; hard sphere solvent********************/ 48 | DIAMETER: 49 | 1.0; 1.0; 1.0; 1.0; 1.0; 1.0 50 | =================================================================================== 51 | /*Dielectric constant: solution, surfaces; temperature (K); length unit of system**/ 52 | PERMITEMLEN: 53 | 78.5, 78.5; 298.15; 4.0E-10 54 | =================================================================================== 55 | /******Iterative parameters. maximum iteration #: maxItera; Picard mixture: mixCoe; 56 | Charging step: cstep; Guess surface potential: phL_L; Error tolerance: errTol*****/ 57 | ITERATIVE: 58 | 1E5; 0.001; 1; 0.0; 1.0E-7 59 | =================================================================================== 60 | /**********************Set the path for the output file ***************************/ 61 | FILEPATH: 62 | ~/Atif/output/example3/H8/ 63 | =================================================================================== 64 | -------------------------------------------------------------------------------- /Atif/src/cmake/AtifLx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jiangj-physchem/Atif/617d77d2fa6a16644b2b85e7c1d36f931886f1fd/Atif/src/cmake/AtifLx -------------------------------------------------------------------------------- /Atif/src/cmake/AtifOS: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jiangj-physchem/Atif/617d77d2fa6a16644b2b85e7c1d36f931886f1fd/Atif/src/cmake/AtifOS -------------------------------------------------------------------------------- /Atif/src/cmake/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.16) 2 | project(Atif CXX) 3 | 4 | set(CMAKE_C_STANDARD 1) 5 | set(CMAKE_CXX_STANDARD 17) 6 | 7 | FILE(GLOB MyCppSources ../source/*.cpp) 8 | 9 | add_executable(AtifExe ${MyCppSources}) 10 | 11 | target_include_directories(AtifExe PUBLIC ../source) 12 | -------------------------------------------------------------------------------- /Atif/src/cmake/Makefile: -------------------------------------------------------------------------------- 1 | CC=g++ 2 | DIR_INC=-I ../source 3 | CFLAGS=-Wall -g -O2 $(DIR_INC) 4 | DIR_SRC= ../source 5 | CPP_FILES=$(wildcard ${DIR_SRC}/*.cpp) 6 | SRC=$(CPP_FILES) 7 | OBJ=$(SRC:.cpp=.o) 8 | 9 | TARGET=AtifExe 10 | 11 | defaut: $(TARGET) 12 | -rm $(OBJ) 13 | 14 | $(TARGET): $(OBJ) 15 | $(CC) -o $@ $(OBJ) 16 | 17 | %.o: %.cpp 18 | $(CC) $(CFLAGS) -c $< -o $@ 19 | 20 | .PHONY : clean 21 | clean: 22 | rm $(TARGET) $(OBJ) 23 | 24 | -------------------------------------------------------------------------------- /Atif/src/source/Initialization.cpp: -------------------------------------------------------------------------------- 1 | //*******************solve Euler Lagrange***************// 2 | 3 | #include "Initialization.h" 4 | #include "eulerlagrangeequation.h" 5 | #include "eulerlagrangeequationDFT.h" 6 | #include "getnumbersbyline.h" 7 | //#include "poissonequation.h" 8 | #include "fileoutput.h" 9 | 10 | extern int ngrid; //the number of grids 11 | extern int ngrid_m; //the number of grids: the middle between two surfaces 12 | extern short nspecies; 13 | extern double errTol; 14 | 15 | 16 | void Initialization(double gama,double f,double eta_t,int* LLI, int* ULI,float* D,double* BB,double* etar,float* Z, 17 | double* rhoB,double* mu,double** Ext,double** ATT,double*** BesselZero,double*** Psi_IJ,double** rho, 18 | double** pairEner,string* MODEL,string* MethG) 19 | { 20 | int iter; 21 | //int thresh_copy,thresh_in,thresh_out; 22 | //short copy_yes; 23 | double mixCoe,maxItera,err,mix_f,temp,deltaPhi;//,lunit; 24 | //double err_temp1,err_temp2,mix_f_temp1,mix_f_temp2; 25 | double* Psi; 26 | double** rho1; 27 | short hspecies; 28 | //double** rho_temp1; 29 | //double** rho_temp2; 30 | 31 | mixCoe = 0.001; 32 | maxItera = 1.0E6; 33 | //lunit = 5.0E-10; 34 | hspecies = nspecies - 1; 35 | Psi = new double[ngrid+1](); 36 | rho1 = new double*[nspecies](); 37 | //rho_temp1 = new double*[nspecies](); 38 | //rho_temp2 = new double*[nspecies](); 39 | for(short i=0; iULI[i])) rho[i][k] = 0; 52 | } 53 | } 54 | 55 | iter = 0; 56 | mix_f = mixCoe; 57 | deltaPhi= 0; 58 | err = 0; 59 | do 60 | { 61 | if(MethG[0] == "scft") 62 | { 63 | EulerLagrange(deltaPhi,f,eta_t,LLI,ULI,D,Z,etar,Psi,pairEner,mu,rhoB,Ext,BesselZero, 64 | rho,rho1,MODEL); 65 | } 66 | if(MethG[0] == "dft") 67 | { 68 | EulerLagrangeDFT(gama,deltaPhi,f,eta_t,LLI,ULI,D,BB,Z,etar,Psi,pairEner,mu,rhoB,Ext,ATT, 69 | BesselZero,Psi_IJ,rho,rho1,MODEL); 70 | } 71 | 72 | 73 | err = 0; 74 | for(short i=0; i 1E-10) 77 | { 78 | for(int k=LLI[i]; k<=ngrid_m; ++k) 79 | { 80 | temp = fabs(rho1[i][k]-rho[i][k])/rhoB[i]; 81 | if(err < temp) err = temp; 82 | } 83 | } 84 | } 85 | 86 | for(short i=0; i= errTol) && (iter <= maxItera)); 98 | 99 | //make sure the iteration convergence 100 | for(short i=0; i>psi_delta>>C_psi>>iter>>ngrid_old>>Ener_Save[0]; 130 | 131 | if(ngrid == ngrid_old) 132 | { 133 | for(int k=0; k<=ngrid_m; ++k) 134 | { 135 | //inFile>>rho[0][k]>>rho[1][k]>>rho[2][k]>>rho[3][k]>>rho[4][k]>>rho[5][k]>>rho[6][k]>>rho[7][k]>>rho[8][k]; 136 | GetNumbersByLine(inFile,InputRho); 137 | for(short i=0; i>rho[0][k]>>rho[1][k]>>rho[2][k]>>rho[3][k]>>rho[4][k]>>rho[5][k]>>rho[6][k]>>rho[7][k]>>rho[8][k]; 152 | GetNumbersByLine(inFile,InputRho); 153 | for(short i=0; i= kL)//111111 173 | { 174 | ngridk = (kL+kR)/2; 175 | if((kR-kL+1)%2 == 0) 176 | { 177 | for(int k=kL; k<=ngridk; ++k) 178 | { 179 | for(short i=0; i=(ngridk+1); --k) 187 | { 188 | for(short i=0; ingridk; --k) 209 | { 210 | for(short i=0; iULI[i])) rho[i][k] = 0; 242 | } 243 | } 244 | } 245 | 246 | 247 | void Initialization(double& sigma_t,double& dcharge,int& cstep,int& iter,int* LLI, int* ULI,double* rhoB, 248 | double** rho,ifstream& inFile) 249 | { 250 | 251 | double* FirstLine; 252 | 253 | FirstLine = new double[5](); 254 | GetNumbersByLine(inFile,FirstLine); 255 | sigma_t = FirstLine[0]; 256 | dcharge = FirstLine[1]; 257 | cstep = (int) FirstLine[2]; 258 | iter = FirstLine[3]; 259 | 260 | 261 | for(int k=0; k<=ngrid; ++k) 262 | { 263 | for(short i=0; iULI[i])) rho[i][k] = 0; 267 | } 268 | } 269 | 270 | 271 | delete [] FirstLine; 272 | } 273 | 274 | /* 275 | void Initialization(double& sigma_t,double& dcharge,int& cstep,int& iter,double** rho,ifstream& inFile) 276 | { 277 | int ngrid_old,ngrid_old2,m_old2,kL,kR,ngridk; 278 | double* FirstLine; 279 | double* InputRho; 280 | 281 | FirstLine = new double[5](); 282 | InputRho = new double[nspecies](); 283 | GetNumbersByLine(inFile,FirstLine); 284 | sigma_t = FirstLine[0]; 285 | dcharge = FirstLine[1]; 286 | cstep = (int) FirstLine[2]; 287 | iter = FirstLine[3]; 288 | ngrid_old = FirstLine[4]; 289 | //inFile>>psi_delta>>C_psi>>iter>>ngrid_old>>Ener_Save[0]; 290 | 291 | if(ngrid == ngrid_old) 292 | { 293 | for(int k=0; k<=ngrid; ++k) 294 | { 295 | //inFile>>rho[0][k]>>rho[1][k]>>rho[2][k]>>rho[3][k]>>rho[4][k]>>rho[5][k]>>rho[6][k]>>rho[7][k]>>rho[8][k]; 296 | GetNumbersByLine(inFile,InputRho); 297 | for(short i=0; i>rho[0][k]>>rho[1][k]>>rho[2][k]>>rho[3][k]>>rho[4][k]>>rho[5][k]>>rho[6][k]>>rho[7][k]>>rho[8][k]; 311 | GetNumbersByLine(inFile,InputRho); 312 | for(short i=0; i>rho[0][k]>>rho[1][k]>>rho[2][k]>>rho[3][k]>>rho[4][k]>>rho[5][k]>>rho[6][k]>>rho[7][k]>>rho[8][k]; 320 | GetNumbersByLine(inFile,InputRho); 321 | for(short i=0; i= kL)//111111 339 | { 340 | ngridk = (kL+kR)/2; 341 | if((kR-kL+1)%2 == 0) 342 | { 343 | for(int k=kL; k<=ngridk; ++k) 344 | { 345 | for(short i=0; i=(ngridk+1); --k) 353 | { 354 | for(short i=0; ingridk; --k) 375 | { 376 | for(short i=0; i Error_T) && (k < Max_k)); 72 | 73 | if(k >= Max_k) 74 | { 75 | std::cerr<<"we cannot get converge value for Bessel function"< 1E-15)) //if(i==0 || i==1) 66 | { 67 | muID[i] = log(rhoBM1/((double) mp[0]))/((double) mp[0]); 68 | } 69 | else if((i >= nb[0]) && (i < nblocks) && (rhoBM2 > 1E-15)) //else if(i==2 || i==3) 70 | { 71 | muID[i] = log(rhoBM2/((double) mp[1]))/((double) mp[1]); 72 | } 73 | else if((i >= nblocks) && (rhoB[i] > 1E-15)) 74 | { 75 | muID[i] = log(rhoB[i]); 76 | } 77 | } 78 | 79 | //van del Waals 80 | //depthW= 1.2; 81 | coe = Pi*dr*0.5; 82 | for(short j1=0; j1 (error*gamai)) 79 | { 80 | temp1 = 0.0; 81 | temp2 = 0.0; 82 | for(short i=0; i iter_MAX) 115 | { 116 | std::cerr<<"Exceed the iterative maximum bulkpotentialsolvent code: 1"< iter_MAX) 199 | { 200 | std::cerr<<"Exceed the iterative maximum bulkpotentialsolvent code: 1"< (error*DEB0)) 123 | { 124 | for(short i=0; i iter_MAX) 165 | { 166 | std::cerr<<"Exceed the iterative maximum in calculategamma.cpp"< (error*DEB0)) 299 | { 300 | for(short i=0; i iter_MAX) 341 | { 342 | std::cerr<<"Exceed the iterative maximum in calculategamma.cpp"< BIJ[i][j]) kip = BIJ[i][j]; 54 | 55 | kin = kin + DMAXg; 56 | kip = kip + DMAXg; 57 | for(int k1=kin; k1<=kip; ++k1) 58 | { 59 | iR_p = k + k1 - DMAXg; 60 | IntegF[k1] = rho[j][iR_p]; 61 | //IntegF[k1] = rho[j][iR_p]*Psi_IJ[i][j][k1]; 62 | } 63 | temp1 = GaussianIntegrationShell(IntegF,Psi_IJ[i][j],0,RanSH,kin,kip); 64 | DSH[i][k] += temp1; 65 | } 66 | } 67 | } 68 | 69 | delete [] IntegF; 70 | for(short i=0; i BIJ[i][j]) kip = BIJ[i][j]; 178 | 179 | kin = kin + DMAX; 180 | kip = kip + DMAX; 181 | for(int k1=kin; k1<=kip; ++k1) 182 | { 183 | iR_p = k + k1 - DMAX; 184 | IntegF[k1] = rho[j][iR_p]; 185 | //IntegF[k1] = rho[j][iR_p]*Psi_IJ[i][j][k1]; 186 | } 187 | temp1 = GaussianIntegrationShell(IntegF,Psi_IJ[i][j],0,RanSH,kin,kip); 188 | DSH[i][k] += temp1; 189 | } 190 | } 191 | } 192 | 193 | delete [] IntegF; 194 | for(short i=0; i BIJ[i][j]) kip = BIJ[i][j]; 300 | 301 | kin = kin + DMAX; 302 | kip = kip + DMAX; 303 | for(int k1=kin; k1<=kip; ++k1) 304 | { 305 | iR_p = k + k1 - DMAX; 306 | IntegF[k1] = rho[j][iR_p]*Psi_IJ[i][j][k1]; 307 | } 308 | temp1 = SimpsonIntegration(IntegF,0,RanSH,kin,kip); 309 | 310 | DSH[i][k] += temp1; 311 | } 312 | } 313 | 314 | } 315 | 316 | 317 | delete [] IntegF; 318 | for(short i=0; i // rand(),srand() 5 | #include 6 | #include 7 | #include 8 | #include //time() 9 | #include 10 | #include 11 | #include 12 | #endif // CLIBRARY_H_ 13 | -------------------------------------------------------------------------------- /Atif/src/source/constantnum.h: -------------------------------------------------------------------------------- 1 | //define constantnum.h 2 | #ifndef CONSTANTNUM_H_ 3 | #define CONSTANTNUM_H_ 4 | 5 | //**********Global Constants****************// 6 | #define epsilon0 8.854187817E-12L //the permittivity of vacuum 7 | #define kB 1.3806504E-23L //Boltzmann's constant 8 | #define e0 1.60217646E-19L //elementary charge 9 | #define Na 6.02214179E+23L //Avogadro's constant 10 | #define Pi 3.1415926536 11 | //******************************************// 12 | #endif // CONSTANTNUM_H_ 13 | -------------------------------------------------------------------------------- /Atif/src/source/createdirectory.h: -------------------------------------------------------------------------------- 1 | //create a directory 2 | #ifndef CREATEDDIRECTORY_H_ 3 | #define CREATEDDIRECTORY_H_ 4 | #include "clibrary.h" 5 | #include 6 | #include 7 | #include 8 | 9 | #if defined(WIN32) 10 | #include 11 | #endif 12 | 13 | using namespace std; 14 | 15 | namespace createdirectory 16 | { 17 | #if defined(WIN32) 18 | int mkpath(string s) 19 | { 20 | size_t pre=0,pos; 21 | std::string dir; 22 | int mdret,errno_0; 23 | 24 | if(s[s.size()-1]!='/') 25 | { 26 | // force trailing / so we can handle everything in loop 27 | s+='/'; 28 | } 29 | 30 | errno_0 = errno; 31 | while((pos=s.find_first_of('/',pre))!=string::npos) 32 | { 33 | errno = errno_0; 34 | 35 | dir=s.substr(0,pos++); 36 | pre=pos; 37 | if(dir.size()==0) continue; // if leading / first time is 0 length 38 | if((mdret=::_mkdir(dir.c_str())) && errno!=EEXIST) // && pos!=(s.size()-2) 39 | { 40 | return mdret; 41 | } 42 | if((pos==s.size()) && errno==EEXIST) mdret = 0; 43 | 44 | } 45 | return mdret; 46 | } 47 | #else 48 | int mkpath(string s,mode_t mode=0755) 49 | { 50 | size_t pre=0,pos; 51 | std::string dir; 52 | int mdret,errno_0; 53 | 54 | if(s[s.size()-1]!='/') 55 | { 56 | // force trailing / so we can handle everything in loop 57 | s+='/'; 58 | } 59 | 60 | errno_0 = errno; 61 | while((pos=s.find_first_of('/',pre))!=string::npos) 62 | { 63 | errno = errno_0; 64 | 65 | dir=s.substr(0,pos++); 66 | pre=pos; 67 | if(dir.size()==0) continue; // if leading / first time is 0 length 68 | if((mdret=::mkdir(dir.c_str(),mode)) && errno!=EEXIST) // && pos!=(s.size()-2) 69 | { 70 | return mdret; 71 | } 72 | if((pos==s.size()) && errno==EEXIST) mdret = 0; 73 | 74 | } 75 | return mdret; 76 | } 77 | #endif 78 | } 79 | #endif //CREATEDDIRECTORY_H_ 80 | -------------------------------------------------------------------------------- /Atif/src/source/derivelectrocorrel.h: -------------------------------------------------------------------------------- 1 | //declaration the function for calculating inhomogeneous chemical potential// 2 | //****************** for electrostatic correlation ***********************// 3 | #ifndef DERIVELECTROCORREL_H_ 4 | #define DERIVELECTROCORREL_H_ 5 | void DerivElectroCorrel(double gammab,int* LLI,int* ULI,float* D,float* Z,double* rhoB, 6 | double** ATT,double** rho,double** DES); 7 | void DerivElectroCorrel(double* rhoB,double gammab,float* D,float* Z,double** ATT, 8 | double* DESB,double& ES_EN); 9 | #endif //DERIVELECTROCORREL_H_ 10 | -------------------------------------------------------------------------------- /Atif/src/source/derivhardspherechain.h: -------------------------------------------------------------------------------- 1 | //declaration the function for calculating inhomogeneous chemical potential// 2 | //********************* for hard sphere chain ****************************// 3 | //*****************************FMT + TPT1**********************************// 4 | #ifndef DERIVHARDSPHERECHAIN_H_ 5 | #define DERIVHARDSPHERECHAIN_H_ 6 | void DerivHardSphereChain(int MAXR,int* LLI,int* ULI,double* rhoB,float* D,float* Z,double** ATT, 7 | double** rho,double** DCH); 8 | void DerivHardSphereChain(double* rhoB,float* D,float* Z,double** ATT,double* DCHB,double& HCH_EN); 9 | #endif //DERIVHARDSPHERECHAIN_H_ 10 | -------------------------------------------------------------------------------- /Atif/src/source/energycalculation.cpp: -------------------------------------------------------------------------------- 1 | //***********potential from electrostatistic correlation****************// 2 | #include "clibrary.h" 3 | #include "inhomvandelwaal.h" 4 | #include "imagecharge.h" 5 | #include "derivelectrocorrel.h" 6 | #include "energyelectrochain.h" 7 | #include "simpsonintegration.h" 8 | #include "energyimagecharge.h" 9 | #include "derivhardspherechain.h" 10 | #include "energyhardspherechain.h" 11 | #include "chargeshell.h" 12 | #include "constantnum.h" 13 | #include "energycalculation.h" 14 | 15 | extern double dr; 16 | extern double BJ; 17 | extern short* mp;//monomer # on copolymer 18 | extern short* nb;//# of blocks in copolymer i; 19 | extern short** mb;//# of monomers in each block 20 | extern int ngrid; 21 | extern int ngrid_m; //the number of grids: the middle between two surfaces 22 | extern int ngrid_b; 23 | extern int DMAX; 24 | extern short nspecies; 25 | extern short neutsys; 26 | 27 | 28 | void EnergyCalculation(double sigma,double gammab,double f,int* LLI,int* ULI,float* D,float* Z,double* rhoB, 29 | double* BB,double** pairEner,double** ATT,double** rho,double* Psi,double*** Psi_IJ, 30 | double& Ener_tot) 31 | { 32 | double* f_im; 33 | double* u_im; 34 | double* f_TOT; 35 | double** DCH; 36 | double** DEC; 37 | double** DSH; 38 | double** VanDW; 39 | double** UUIM; 40 | 41 | int MAXR; 42 | short hspecies,nblocks; 43 | double EN_EX,f_im_k,EN_HC,EN_EC,EN_IM,temp,rhoBM1,rhoBM2; 44 | 45 | nblocks = nb[0] + nb[1]; 46 | hspecies= nspecies - 1; 47 | MAXR = DMAX + ngrid_m; 48 | 49 | u_im = new double[ngrid+1](); 50 | f_im = new double[ngrid+1](); 51 | f_TOT = new double[ngrid+1](); 52 | 53 | DCH = new double*[hspecies](); 54 | DEC = new double*[hspecies](); 55 | DSH = new double*[hspecies](); 56 | VanDW= new double*[hspecies](); 57 | UUIM = new double*[hspecies](); 58 | 59 | for(short i=0; i 1E-10) 146 | { 147 | for(short j=0; j 1E-10) 155 | { 156 | for(short j=nb[0]; j 1.0E-10) lambda[k] = log(rho[hspecies][k])*VV; 245 | lambda[ngrid-k] = lambda[k]; 246 | f_im[ngrid-k] = f_im[k]; 247 | 248 | for(short j=0; j 1E-10) 279 | { 280 | for(short j=0; j 1E-10) 287 | { 288 | for(short j=nb[0]; j 1.0e-12) p_max = p_max + 1; 100 | if(rhoBM2 > 1.0e-12) p_max = p_max + 1; 101 | 102 | 103 | gammar = 0.5/gammab; 104 | igammar= round(gammar/dr); 105 | 106 | b_max = RMAX + igammar; 107 | 108 | n_m_gama = ngrid_m + b_max; 109 | n_gama = ngrid + b_max*2; 110 | 111 | f_EN = new double[n_gama+1](); 112 | for(short i=0; i 0.99) N3 = 0.99; 177 | 178 | ///////////////electrostatic correlation for chain connectivity -start ///////////// 179 | //Start: chemical potential for chain connectivity 180 | //Here Y is log(Y) actually 181 | for(short p=0; p 1.0e-12) 201 | { 202 | AN0M1 = 0.0; 203 | for(short i=0; i 1.0e-12) 221 | { 222 | AN0M2 = 0.0; 223 | for(short i=nb[0]; i 1.0e-12) p_max = p_max + 1; 90 | if(rhoBM2 > 1.0e-12) p_max = p_max + 1; 91 | 92 | //big loop 93 | for(int k=0; k<=ngrid; ++k) 94 | { 95 | WeightedDensity(k,LLI,ULI,D,rho,NI); 96 | for(short i=0; i 0.99) N3 = 0.99; 130 | 131 | N31 = 1 - N3; 132 | LN31 = log(N31); 133 | 134 | En_HS = (N1*N2-NV1*NV2)/N31 - N0*LN31 + (N2*N2*N2-3*N2*NV2*NV2)*(N3+N31*N31*LN31)/(36*Pi*N3*N3*N31*N31); 135 | 136 | //Start: bulk chemical potential for chain connectivity 137 | //Here Y is log(Y) actually 138 | for(short p=0; p 1.0e-12) 159 | { 160 | AN0M1 = 0.0; 161 | for(short i=0; i 1.0e-12) 177 | { 178 | AN0M2 = 0.0; 179 | for(short i=nb[0]; i= iterk) 136 | { 137 | std::cerr<<"something wrong in image charge energy: J(ak) error"<depthLR[2][i]) 22 | { 23 | Ext[i][k] += 1E20; 24 | } 25 | 26 | if(k>=depthLR[0][i] && k<=depthLR[1][i]) 27 | { 28 | Ext[i][k] += uWall[i]; 29 | } 30 | 31 | if(k>=depthLR[3][i] && k<=depthLR[2][i]) 32 | { 33 | Ext[i][k] += uWall[i]; 34 | } 35 | } 36 | } 37 | } 38 | 39 | 40 | 41 | 42 | void ExternalPotential(double alpha,float* D,float* uWall,int** depthLR,double** Ext) 43 | { 44 | short hspecies; 45 | //int depthL1,depthL2,depthR1,depthR2; 46 | double DR3L,DR3R,coe,RL,RR,D3,R_star,E_cut,R_cut,R_min,E_min,R_minr,E_min0; 47 | 48 | hspecies= nspecies - 1; 49 | R_min = pow(0.4,1.0/6.0); 50 | R_minr = 1.0/R_min; 51 | //E_min = 2.0*Pi*(2.0*pow(R_minr,9.0)/45.0-pow(R_minr,3.0)/3.0); 52 | E_min = 2.0*pow(R_minr,9.0)/45.0-pow(R_minr,3.0)/3.0; 53 | 54 | for(short i=0; idepthLR[2][i]) Ext[i][k] += 2E10; 70 | 71 | if(k>=depthLR[0][i] && k<=depthLR[1][i]) 72 | { 73 | RL = dr*k + R_star; 74 | DR3L= D3/(RL*RL*RL); 75 | 76 | Ext[i][k] += coe*(2.0*DR3L*DR3L*DR3L/45.0-DR3L/3.0-E_cut); 77 | } 78 | 79 | if(k>=depthLR[3][i] && k<=depthLR[2][i]) 80 | { 81 | RR = dr*(ngrid-k) + R_star; 82 | DR3R= D3/(RR*RR*RR); 83 | 84 | Ext[i][k] += coe*(2.0*DR3R*DR3R*DR3R/45.0-DR3R/3.0-E_cut); 85 | } 86 | 87 | 88 | } 89 | 90 | 91 | 92 | } 93 | 94 | 95 | 96 | 97 | 98 | } 99 | -------------------------------------------------------------------------------- /Atif/src/source/externalpotential.h: -------------------------------------------------------------------------------- 1 | //declaration the function for calculating external potential// 2 | //***********************************************************// 3 | #ifndef EXTERNALPOTENTIAL_H_ 4 | #define EXTERNALPOTENTIAL_H_ 5 | void ExternalPotential(float* uWall,int** depthLR,double** Ext); 6 | void ExternalPotential(double alpha,float* D,float* uWall,int** depthLR,double** Ext); 7 | #endif //EXTERNALPOTENTIAL_H_ 8 | -------------------------------------------------------------------------------- /Atif/src/source/fileoutput.cpp: -------------------------------------------------------------------------------- 1 | //***********solve the possion equation****************// 2 | #include "fileoutput.h" 3 | #include "createdirectory.h" 4 | //#include "constantnum.h" 5 | 6 | extern double dr; 7 | extern int ngrid; 8 | extern int ngrid_m; //the number of grids: the middle between two surfaces 9 | extern short nspecies; 10 | 11 | void FileOpen(int num_min,int num_max,ofstream& vari_press,ofstream& converge_rec,ofstream& parameters_s, 12 | ofstream& contact_theorem,string& fileIterative,string& fileILoop,string& fileTempDen, 13 | string& fileConverge,string& filePath,string nSurf) 14 | { 15 | int mkdir_0; 16 | short iDirect; 17 | string fileTemp; 18 | string fileDash = "_"; 19 | string fileVar_Press= "variable_pressure_"; 20 | string fileParameter= "sys_parameter_"; 21 | string fileContT= "contact_theorem_"; 22 | string suffix=".dat"; 23 | ostringstream os1; 24 | ostringstream os2; 25 | 26 | 27 | mkdir_0=createdirectory::mkpath(filePath); 28 | if(mkdir_0 != 0) 29 | { 30 | cerr<<"fail to create the directory"< 1E-10) 180 | { 181 | //rho_put[i] = rho[i][k]/rhoB[i]; 182 | rho_put[i] = rho[i][k]*coe3; 183 | } 184 | else 185 | { 186 | rho_put[i] = 0; 187 | } 188 | } 189 | 190 | R = k*dr; 191 | 192 | density_potential<<(R*lunit/nm)<<" "; 193 | for(short i=0; i= iterk) 71 | { 72 | std::cerr<<"something wrong in image charge: WKB error"<= iterk) 126 | { 127 | std::cerr<<"something wrong in image charge: WKB error"< ULI[j2]) kin2 = ULI[j2]; 71 | if(kin3 < LLI[j2]) kin3 = LLI[j2]; 72 | if(kin3 > ULI[j2]) kin3 = ULI[j2]; 73 | if(kin4 > ULI[j2]) kin4 = ULI[j2]; 74 | 75 | 76 | //integration from z - sIJ to z + sIJ 77 | temp0 = 0; 78 | SWD2 = depthW*depthW; 79 | SIJ2 = sIJ[j1][j2]*sIJ[j1][j2]; 80 | for(int k=kin2; k 22 | #include "energycalculation.h" 23 | -------------------------------------------------------------------------------- /Atif/src/source/mark.dat: -------------------------------------------------------------------------------- 1 | METHOD: 2 | POLYMER: 3 | SEQUENCE: 4 | SIZE: 5 | SALT_HS: 6 | WALL: 7 | ENERGY: 8 | VALENCY: 9 | DIAMETER: 10 | PERMITEMLEN: 11 | ITERATIVE: 12 | FILEPATH: 13 | -------------------------------------------------------------------------------- /Atif/src/source/poissonequation.cpp: -------------------------------------------------------------------------------- 1 | //***********solve the possion equation****************// 2 | #include "clibrary.h" 3 | #include "poissonequation.h" 4 | //#include "rombergintegration.h" 5 | #include "simpsonintegration.h" 6 | #include "constantnum.h" 7 | using namespace std; 8 | 9 | extern double dr; 10 | extern double kapa; 11 | extern double BJ; 12 | extern double boundary; 13 | extern int ngrid; 14 | extern int ngrid_m; //the number of grids: the middle between two surfaces 15 | extern int ngrid_b; //the number of grids: the middle between two surfaces 16 | extern short nspecies; 17 | 18 | //In this code, phiR means the middle potential of the system 19 | void PoissonEquationSingle(float* Z,double** rho,double phiL,double phiR,double* Psi) 20 | { 21 | //LLI: the lower limit of intergral: LLI[i]=round(D[i]*0.5/dr) 22 | //int ngridm1; //,i0 23 | double R1,lGau,rGau,coe,rhoD,phi0,sigma0,sigmai,size_b,R_L,dr_size_b; 24 | double* rhoZ; 25 | double* phii; 26 | short hspecies; 27 | 28 | hspecies = nspecies - 1; 29 | 30 | //coe = 2*Pi*BJ*dr; 31 | coe = 2*Pi*BJ*dr; 32 | lGau= 0.2113248654052; //(0.5-sqrt(3)/6)*dr 33 | rGau= 0.7886751345948; //(0.5+sqrt(3)/6)*dr 34 | size_b = ngrid_b*dr; 35 | //ngridm1 = ngrid_m + 1; 36 | dr_size_b= dr/size_b; 37 | //if(ngrid%2 != 0) size_mid = ngrid_m*dr + 0.5*dr; 38 | //ngrid0 = ngrid; 39 | //if(ngrid%2 != 0) ngrid0 = ngrid - 1; 40 | 41 | rhoZ = new double[ngrid_m+1](); 42 | phii = new double[ngrid_m+1](); 43 | 44 | for(int k=0; k<=ngrid_m; ++k) 45 | { 46 | rhoZ[k] = 0; 47 | for(short j=0; j=0; i1--) 364 | { 365 | Psi[i1] = Y[i1] - R[i1]*Psi[i1+1]; 366 | } 367 | 368 | 369 | 370 | 371 | delete [] A; 372 | delete [] B; 373 | delete [] C; 374 | delete [] E; 375 | delete [] L; 376 | delete [] R; 377 | delete [] Y; 378 | delete [] rhoZ; 379 | } 380 | 381 | 382 | -------------------------------------------------------------------------------- /Atif/src/source/poissonequation.h: -------------------------------------------------------------------------------- 1 | //declaration the functions for solving poisson euqation**********// 2 | //****************************************************************// 3 | #ifndef POISSONEQUATION_H_ 4 | #define POISSONEQUATION_H_ 5 | void PoissonEquationSingle(float* Z,double** rho,double phiL,double phiR,double* Psi); 6 | void PoissonEquationSingle(float* Z,double** rho,double* Psi); 7 | void PoissonEquationTwo(float* Z,double** rho,double* Psi); 8 | void PoissonEquationTwo(float* Z,double** rho,double phi,double* Psi); 9 | void PoissonEquation(float* Z,double** rho,double* Psi1,double* Psi); 10 | #endif //POISSONEQUATION_H_ 11 | -------------------------------------------------------------------------------- /Atif/src/source/psichargeshell.cpp: -------------------------------------------------------------------------------- 1 | //***********potential from electrostatistic correlation****************// 2 | #include "clibrary.h" 3 | #include "psichargeshell.h" 4 | #include "constantnum.h" 5 | 6 | extern double dr; 7 | extern double BJ; 8 | extern int DMAXg; 9 | extern int DMAX; 10 | extern short nspecies; 11 | //using namespace std; 12 | 13 | void PsiChargeShell(double* B,float* Z,double*** Psi_IJ) 14 | { 15 | double PiBJ,temp1,temp2,R_t2,R_t3,R_t,R_t0; 16 | double temp32,temp33,temp42,temp43,temp3,temp4,temp5; 17 | double* SubK; 18 | double** coe11_ij; 19 | double** coe12_ij; 20 | double** coe2_ij; 21 | double** coe3_ij; 22 | double** coe4_ij; 23 | double** coe5_ij; 24 | double** temp11_ij; 25 | double** temp12_ij; 26 | double** temp2_ij; 27 | double** DBIJ; 28 | int** BIJ; 29 | short hspecies; 30 | int kin,kip,kk; 31 | 32 | hspecies = nspecies - 1; 33 | 34 | BIJ = new int*[hspecies](); 35 | SubK = new double[3](); 36 | DBIJ = new double*[hspecies](); 37 | coe11_ij= new double*[hspecies](); 38 | coe12_ij= new double*[hspecies](); 39 | coe2_ij = new double*[hspecies](); 40 | coe3_ij = new double*[hspecies](); 41 | coe4_ij = new double*[hspecies](); 42 | coe5_ij = new double*[hspecies](); 43 | temp2_ij= new double*[hspecies](); 44 | temp11_ij= new double*[hspecies](); 45 | temp12_ij= new double*[hspecies](); 46 | 47 | SubK[0] = 0.0; 48 | SubK[1] = 0.2254033307585*dr; 49 | SubK[2] = 0.7745966692415*dr; 50 | 51 | for(short i=0; i B[j]) 109 | { 110 | for(int k=kin; k B[j]) 534 | { 535 | for(int k=kin; k<=kip; ++k) 536 | { 537 | k_abs= k; 538 | if(k < 0) k_abs = -k_abs; 539 | R_t = k_abs*dr; 540 | iR_t = k + DMAX; 541 | 542 | R_t2 = R_t*R_t; 543 | R_t3 = R_t*R_t2; 544 | if(k_abs < DBIJ[i][j]) 545 | { 546 | Psi_IJ[i][j][iR_t] = temp11_ij[i][j] + coe11_ij[i][j]*R_t2 + coe2_ij[i][j]*R_t; 547 | } 548 | else 549 | { 550 | Psi_IJ[i][j][iR_t] = temp2_ij[i][j] + coe3_ij[i][j]*R_t + coe4_ij[i][j]*R_t2 + coe5_ij[i][j]*R_t3; 551 | } 552 | } 553 | } 554 | else 555 | { 556 | for(int k=kin; k<=kip; ++k) 557 | { 558 | k_abs= k; 559 | if(k < 0) k_abs = -k_abs; 560 | R_t = k_abs*dr; 561 | iR_t = k + DMAX; 562 | 563 | R_t2 = R_t*R_t; 564 | R_t3 = R_t*R_t2; 565 | if(k_abs < DBIJ[i][j]) 566 | { 567 | Psi_IJ[i][j][iR_t] = temp12_ij[i][j] + coe12_ij[i][j]*R_t2 + coe2_ij[i][j]*R_t; 568 | } 569 | else 570 | { 571 | Psi_IJ[i][j][iR_t] = temp2_ij[i][j] + coe3_ij[i][j]*R_t + coe4_ij[i][j]*R_t2 + coe5_ij[i][j]*R_t3; 572 | } 573 | } 574 | } 575 | 576 | } 577 | } 578 | 579 | 580 | 581 | for(short i=0; i 1E-10) 62 | { 63 | for(short i=0; i 0) DL1[j0] = 0.5*(D[i] + D[i-1]); 77 | } 78 | 79 | j0 = MB1[i+1] - 1; 80 | DL1[j0] = D[i]; 81 | if((j0 == MB1[i]) && (j0 > 0)) DL1[j0] = 0.5*(D[i] + D[i-1]); 82 | if(j0 < (mp1-1)) DR1[j0] = 0.5*(D[i] + D[i+1]); 83 | } 84 | 85 | 86 | 87 | 88 | if(MODEL[0] == "semiflexible" || MODEL[0] == "semi-flexible")//stiff chain 89 | { 90 | for(int k1=0; k1 1E-10) 104 | { 105 | for(short i=0; i 0) DL2[j0] = 0.5*(D[i0] + D[i0-1]); 120 | } 121 | j0 = MB2[i+1] - 1; 122 | DL2[j0] = D[i0]; 123 | if((j0 == MB2[i]) && (j0 > 0)) DL2[j0] = 0.5*(D[i0] + D[i0-1]); 124 | if(j0 < (mp2-1)) DR2[j0] = 0.5*(D[i0] + D[i0+1]); 125 | } 126 | 127 | if(MODEL[1] == "semiflexible" || MODEL[1] == "semi-flexible")//stiff chain 128 | { 129 | for(int k1=0; k1 1) 25 | { 26 | final_result += (integrandF[iaa] + integrandF[ibb]); 27 | final_result += (integrandF[ibb-1]*4.0); 28 | for(int k=(iaa+1); k<(ibb-2); k=(k+2)) 29 | { 30 | final_result += (integrandF[k]*4.0); 31 | final_result += (integrandF[k+1]*2.0); 32 | } 33 | final_result = final_result*dr/3.0; 34 | } 35 | 36 | 37 | final_result0 = 0; 38 | if((ibb0-iaa0) == 1) 39 | { 40 | dr2 = dr*dr; 41 | dr1_1 = 1/dr; 42 | dr2_6 = dr1_1*dr1_1/6; 43 | 44 | 45 | if((iaa0==aa) && (ibb0==bb)) 46 | { 47 | final_result0 = (integrandF[iaa0] + integrandF[ibb0])*0.5*dr; 48 | } 49 | else if((iaa0>aa) && (ibb0 aa) 65 | { 66 | coe1 = dr2_6*(integrandF[iaa0-1] - 2.0*integrandF[iaa0] + integrandF[ibb0]); 67 | coe2 = (integrandF[ibb0] - integrandF[iaa0-1])*dr1_1/4; 68 | coe3 = integrandF[iaa0]; 69 | } 70 | else if(ibb0 < bb) 71 | { 72 | coe1 = dr2_6*(integrandF[iaa0] - 2.0*integrandF[ibb0] + integrandF[ibb0+1]); 73 | coe2 = (4.0*integrandF[ibb0] - integrandF[ibb0+1] - 3.0*integrandF[iaa0])*dr1_1/4; 74 | coe3 = integrandF[iaa0]; 75 | } 76 | 77 | final_result0 = dr2*dr*coe1 + dr2*coe2 + dr*coe3; 78 | } 79 | } 80 | 81 | final_result += final_result0; 82 | 83 | return final_result; 84 | } 85 | 86 | 87 | 88 | 89 | 90 | double SimpsonIntegration(double* integrandF,int aa,int bb,int ia,int ib,int i_R) 91 | { 92 | int iaa,ibb,iaa0,ibb0,i_Ra,i_Rb,i_Rk;//basic_n_mim,exp_v; 93 | double final_result,final_result0,dr2; 94 | double coe1,coe2,coe3,coe4,dr1_1,dr1_6,dr2_6; 95 | 96 | final_result = 0; 97 | if(ib==ia) return final_result; 98 | 99 | dr2 = dr*dr; 100 | iaa = ia; 101 | ibb = ib; 102 | if((ib-ia+1)%2 == 0) ibb = ib -1; 103 | iaa0 = ibb; 104 | ibb0 = ib; 105 | final_result = 0; 106 | if((ibb-iaa) > 1) 107 | { 108 | i_Rk = ibb-i_R; 109 | final_result += (integrandF[iaa]*(iaa-i_R) + integrandF[ibb]*i_Rk); 110 | final_result += (integrandF[ibb-1]*(i_Rk-1)*4.0); 111 | for(int k=(iaa+1); k<(ibb-2); k=(k+2)) 112 | { 113 | i_Rk = k - i_R; 114 | final_result += (integrandF[k]*i_Rk*4.0); 115 | final_result += (integrandF[k+1]*(i_Rk+1)*2.0); 116 | } 117 | final_result = final_result*dr2/3.0; 118 | } 119 | 120 | 121 | final_result0 = 0; 122 | if((ibb0-iaa0) == 1) 123 | { 124 | dr1_1 = 1/dr; 125 | dr1_6 = dr1_1/6; 126 | dr2_6 = dr1_1*dr1_6; 127 | 128 | i_Ra = iaa0 - i_R; 129 | i_Rb = ibb0 - i_R; 130 | if((iaa0==aa) && (ibb0==bb)) 131 | { 132 | final_result0 = (integrandF[iaa0]*i_Ra + integrandF[ibb0]*i_Rb)*0.5*dr2; 133 | } 134 | else if((iaa0>aa) && (ibb0 aa) 154 | { 155 | coe1 = dr1_6*(integrandF[iaa0-1]*(i_Ra-1) - 2.0*integrandF[iaa0]*i_Ra + 156 | integrandF[ibb0]*i_Rb); 157 | coe2 = (integrandF[ibb0]*i_Rb - integrandF[iaa0-1]*(i_Ra-1))/4; 158 | coe3 = integrandF[iaa0]*i_Ra*dr; 159 | //FF_IN[i] = dr2*(0.5*integrandF[iaa0-1]*(drr*i)*(drr*i-dr) - integrandF[iaa0]*(drr*i+dr)*(drr*i-dr) 160 | //+ 0.5*integrandF[ibb0]*(drr*i+dr)*(drr*i)); 161 | } 162 | else if(ibb0 < bb) 163 | { 164 | coe1 = dr1_6*(integrandF[iaa0]*i_Ra - 2.0*integrandF[ibb0]*i_Rb + 165 | integrandF[ibb0+1]*(i_Rb+1)); 166 | coe2 = (4.0*integrandF[ibb0]*i_Rb - integrandF[ibb0+1]*(i_Rb+1) - 167 | 3.0*integrandF[iaa0]*i_Ra)/4; 168 | coe3 = integrandF[iaa0]*i_Ra*dr; 169 | //FF_IN[i] = dr2*(0.5*integrandF[iaa0]*(drr*i-dr)*(drr*i-2*dr) - integrandF[ibb0]*(drr*i)*(drr*i-2*dr) 170 | //+ 0.5*integrandF[ibb0+1]*(drr*i)*(drr*i-dr)); 171 | } 172 | 173 | final_result0 = dr2*dr*coe1 + dr2*coe2 + dr*coe3; 174 | } 175 | } 176 | 177 | final_result += final_result0; 178 | 179 | return final_result; 180 | } 181 | 182 | 183 | 184 | double SimpsonIntegration(double* integrandF,int aa,int bb,int ia,int ib,double D2_j,int i_R) 185 | { 186 | int iaa,ibb,iaa0,ibb0,i_Rk;//basic_n_mim,exp_v; 187 | double final_result,final_result0,dr2,dr3,DD_2; 188 | double coe1,coe2,coe3,coe4,dr1_1,i_D_Ra0,i_D_Rb0,i_D_Ra1,i_D_Rb1; 189 | 190 | dr2 = dr*dr; 191 | dr3 = dr2*dr; 192 | DD_2 = D2_j/dr2; 193 | 194 | final_result = 0; 195 | if(ib==ia) return final_result; 196 | 197 | iaa = ia; 198 | ibb = ib; 199 | if((ib-ia+1)%2 == 0) ibb = ib -1; 200 | iaa0 = ibb; 201 | ibb0 = ib; 202 | final_result = 0; 203 | if((ibb-iaa) > 1) 204 | { 205 | i_Rk = ibb-i_R; 206 | final_result += (integrandF[iaa]*(DD_2-(iaa-i_R)*(iaa-i_R)) + 207 | integrandF[ibb]*(DD_2-i_Rk*i_Rk)); 208 | final_result += (integrandF[ibb-1]*(DD_2-(i_Rk-1)*(i_Rk-1))*4.0); 209 | for(int k=(iaa+1); k<(ibb-2); k=(k+2)) 210 | { 211 | i_Rk = k - i_R; 212 | final_result += (integrandF[k]*(DD_2-i_Rk*i_Rk)*4.0); 213 | final_result += (integrandF[k+1]*(DD_2-(i_Rk+1)*(i_Rk+1))*2.0); 214 | } 215 | final_result = final_result*dr3/3.0; 216 | } 217 | 218 | 219 | 220 | final_result0 = 0; 221 | if((ibb0-iaa0) == 1) 222 | { 223 | i_D_Ra0 = DD_2 - (iaa0 - i_R)*(iaa0 - i_R); 224 | i_D_Rb0 = DD_2 - (ibb0 - i_R)*(ibb0 - i_R); 225 | i_D_Ra1 = DD_2 - (iaa0-i_R-1)*(iaa0-i_R-1); 226 | i_D_Rb1 = DD_2 - (ibb0-i_R+1)*(ibb0-i_R+1); 227 | if((iaa0==aa) && (ibb0==bb)) 228 | { 229 | final_result0 = (integrandF[iaa0]*i_D_Ra0 + integrandF[ibb0]*i_D_Rb0)*0.5*dr3; 230 | } 231 | else if((iaa0>aa) && (ibb0 aa) 252 | { 253 | coe1 = (integrandF[iaa0-1]*i_D_Ra1 - 2.0*integrandF[iaa0]*i_D_Ra0 + 254 | integrandF[ibb0]*i_D_Rb0)/6; 255 | coe2 = (integrandF[ibb0]*i_D_Rb0 - integrandF[iaa0-1]*i_D_Ra1)*dr/4; 256 | coe3 = integrandF[iaa0]*i_D_Ra0*dr2; 257 | //FF_IN[i] = dr2*(0.5*integrandF[iaa0-1]*(drr*i)*(drr*i-dr) - integrandF[iaa0]*(drr*i+dr)*(drr*i-dr) 258 | //+ 0.5*integrandF[ibb0]*(drr*i+dr)*(drr*i)); 259 | } 260 | else if(ibb0 < bb) 261 | { 262 | coe1 = (integrandF[iaa0]*i_D_Ra0 - 2.0*integrandF[ibb0]*i_D_Rb0 + 263 | integrandF[ibb0+1]*i_D_Rb1)/6; 264 | coe2 = (4.0*integrandF[ibb0]*i_D_Rb0 - integrandF[ibb0+1]*i_D_Rb1 - 265 | 3.0*integrandF[iaa0]*i_D_Ra0)*dr/4; 266 | coe3 = integrandF[iaa0]*i_D_Ra0*dr2; 267 | //FF_IN[i] = dr2*(0.5*integrandF[iaa0]*(drr*i-dr)*(drr*i-2*dr) - integrandF[ibb0]*(drr*i)*(drr*i-2*dr) 268 | //+ 0.5*integrandF[ibb0+1]*(drr*i)*(drr*i-dr)); 269 | } 270 | 271 | final_result0 = dr3*coe1 + dr2*coe2 + dr*coe3; 272 | } 273 | } 274 | 275 | final_result += final_result0; 276 | 277 | return final_result; 278 | } 279 | 280 | 281 | double SimpsonIntegration(int aa,int bb,int ia,int ib,double D2_j) 282 | { 283 | int iaa,ibb,iaa0,ibb0;//basic_n_mim,exp_v; 284 | double final_result,final_result0,dr2,dr3,DD_2; 285 | double coe1,coe2,coe3,i_D_Ra0,i_D_Rb0,i_D_Ra1; 286 | 287 | dr2 = dr*dr; 288 | dr3 = dr2*dr; 289 | DD_2 = D2_j/dr2; 290 | 291 | final_result = 0; 292 | if(ib==ia) return final_result; 293 | 294 | iaa = ia; 295 | ibb = ib; 296 | if((ib-ia+1)%2 == 0) ibb = ib -1; 297 | iaa0 = ibb; 298 | ibb0 = ib; 299 | final_result = 0; 300 | if((ibb-iaa) > 1) 301 | { 302 | final_result += ((DD_2-iaa*iaa) + (DD_2-ibb*ibb)); 303 | final_result += ((DD_2-(ibb-1)*(ibb-1))*4.0); 304 | for(int k=(iaa+1); k<(ibb-2); k=(k+2)) 305 | { 306 | final_result += (DD_2-k*k)*4.0; 307 | final_result += (DD_2-(k+1)*(k+1))*2.0; 308 | } 309 | final_result = final_result*dr3/3.0; 310 | } 311 | 312 | 313 | 314 | final_result0 = 0; 315 | if((ibb0-iaa0) == 1) 316 | { 317 | i_D_Ra0 = DD_2 - iaa0*iaa0; 318 | i_D_Rb0 = DD_2 - ibb0*ibb0; 319 | if((iaa0==aa) && (ibb0==bb)) 320 | { 321 | final_result0 = (i_D_Ra0 + i_D_Rb0)*0.5*dr3; 322 | } 323 | else 324 | { 325 | i_D_Ra1 = DD_2 - (iaa0-1)*(iaa0-1); 326 | 327 | coe1 = (i_D_Ra1 - 2.0*i_D_Ra0 + i_D_Rb0)/6; 328 | coe2 = (i_D_Rb0 - i_D_Ra1)*dr/4; 329 | coe3 = i_D_Ra0*dr2; 330 | 331 | final_result0 = dr3*coe1 + dr2*coe2 + dr*coe3; 332 | } 333 | } 334 | 335 | final_result += final_result0; 336 | 337 | return final_result; 338 | } 339 | 340 | 341 | double SimpsonIntegration(double* integrandF1,double* integrandF2,int aa,int bb,int ia,int ib) 342 | { 343 | int iaa,ibb,iaa0,ibb0;//basic_n_mim,exp_v; 344 | double final_result,final_result0,dr2; 345 | double coe1,coe2,coe3,coe4,dr1_1,dr2_6; 346 | 347 | final_result = 0; 348 | if(ib==ia) return final_result; 349 | 350 | 351 | iaa = ia; 352 | ibb = ib; 353 | if((ib-ia+1)%2 == 0) ibb = ib -1; 354 | iaa0 = ibb; 355 | ibb0 = ib; 356 | final_result = 0; 357 | if((ibb-iaa) > 1) 358 | { 359 | final_result += (integrandF1[iaa]*integrandF2[iaa] + integrandF1[ibb]*integrandF2[ibb]); 360 | final_result += (integrandF1[ibb-1]*integrandF2[ibb-1]*4.0); 361 | for(int k=(iaa+1); k<(ibb-2); k=(k+2)) 362 | { 363 | final_result += (integrandF1[k]*integrandF2[k]*4.0); 364 | final_result += (integrandF1[k+1]*integrandF2[k+1]*2.0); 365 | } 366 | final_result = final_result*dr/3.0; 367 | } 368 | 369 | 370 | final_result0 = 0; 371 | if((ibb0-iaa0) == 1) 372 | { 373 | dr2 = dr*dr; 374 | dr1_1 = 1/dr; 375 | dr2_6 = dr1_1*dr1_1/6; 376 | 377 | 378 | if((iaa0==aa) && (ibb0==bb)) 379 | { 380 | final_result0 = (integrandF1[iaa0]*integrandF2[iaa0] + integrandF1[ibb0]*integrandF2[ibb0])*0.5*dr; 381 | } 382 | else if((iaa0>aa) && (ibb0 aa) 401 | { 402 | coe1 = dr2_6*(integrandF1[iaa0-1]*integrandF2[iaa0-1] - 2.0*integrandF1[iaa0]*integrandF2[iaa0] + 403 | integrandF1[ibb0]*integrandF2[ibb0]); 404 | coe2 = (integrandF1[ibb0]*integrandF2[ibb0] - integrandF1[iaa0-1]*integrandF2[iaa0-1])*dr1_1/4; 405 | coe3 = integrandF1[iaa0]*integrandF2[iaa0]; 406 | } 407 | else if(ibb0 < bb) 408 | { 409 | coe1 = dr2_6*(integrandF1[iaa0]*integrandF2[iaa0] - 2.0*integrandF1[ibb0]*integrandF2[ibb0] + 410 | integrandF1[ibb0+1]*integrandF2[ibb0+1]); 411 | coe2 = (4.0*integrandF1[ibb0]*integrandF2[ibb0] - integrandF1[ibb0+1]*integrandF2[ibb0+1] - 412 | 3.0*integrandF1[iaa0]*integrandF2[iaa0])*dr1_1/4; 413 | coe3 = integrandF1[iaa0]*integrandF2[iaa0]; 414 | } 415 | 416 | final_result0 = dr2*dr*coe1 + dr2*coe2 + dr*coe3; 417 | } 418 | } 419 | 420 | final_result += final_result0; 421 | 422 | return final_result; 423 | } 424 | 425 | 426 | 427 | double SimpsonIntegration(double* integrandF1,double* integrandF2,int orient0,int ia,int ib) 428 | { 429 | int iaa,ibb,iaa0,ibb0;//basic_n_mim,exp_v; 430 | double final_result,final_result0,dr2; 431 | double coe1,coe2,coe3,dr1_1,dr2_6; 432 | 433 | final_result = 0; 434 | if(ib==ia) 435 | { 436 | final_result = (dr*0.5*integrandF1[orient0]*integrandF2[orient0]*4.0/3.0); 437 | return final_result; 438 | } 439 | 440 | 441 | iaa = ia; 442 | ibb = ib; 443 | if((ib-ia+1)%2 == 0) ibb = ib -1; 444 | iaa0 = ibb; 445 | ibb0 = ib; 446 | final_result = 0; 447 | if((ibb-iaa) > 1) 448 | { 449 | final_result += (integrandF1[iaa]*integrandF2[iaa] + integrandF1[ibb]*integrandF2[ibb]); 450 | final_result += (integrandF1[ibb-1]*integrandF2[ibb-1]*4.0); 451 | for(int k=(iaa+1); k<(ibb-2); k=(k+2)) 452 | { 453 | final_result += (integrandF1[k]*integrandF2[k]*4.0); 454 | final_result += (integrandF1[k+1]*integrandF2[k+1]*2.0); 455 | } 456 | final_result = final_result*dr/3.0; 457 | } 458 | 459 | 460 | final_result0 = 0; 461 | if((ibb0-iaa0) == 1) 462 | { 463 | if((iaa0==ia) && (ibb0==ib)) 464 | { 465 | final_result0 = (integrandF1[iaa0]*integrandF2[iaa0] + integrandF1[ibb0]*integrandF2[ibb0])*0.5*dr; 466 | } 467 | else 468 | { 469 | coe1 = 0; 470 | coe2 = 0; 471 | coe3 = 0; 472 | 473 | dr2 = dr*dr; 474 | dr1_1 = 1/dr; 475 | dr2_6 = dr1_1*dr1_1/6; 476 | 477 | if(iaa0 > ia) 478 | { 479 | coe1 = dr2_6*(integrandF1[iaa0-1]*integrandF2[iaa0-1] - 2.0*integrandF1[iaa0]*integrandF2[iaa0] + 480 | integrandF1[ibb0]*integrandF2[ibb0]); 481 | coe2 = (integrandF1[ibb0]*integrandF2[ibb0] - integrandF1[iaa0-1]*integrandF2[iaa0-1])*dr1_1/4; 482 | coe3 = integrandF1[iaa0]*integrandF2[iaa0]; 483 | } 484 | else if(ibb0 < ib) 485 | { 486 | coe1 = dr2_6*(integrandF1[iaa0]*integrandF2[iaa0] - 2.0*integrandF1[ibb0]*integrandF2[ibb0] + 487 | integrandF1[ibb0+1]*integrandF2[ibb0+1]); 488 | coe2 = (4.0*integrandF1[ibb0]*integrandF2[ibb0] - integrandF1[ibb0+1]*integrandF2[ibb0+1] - 489 | 3.0*integrandF1[iaa0]*integrandF2[iaa0])*dr1_1/4; 490 | coe3 = integrandF1[iaa0]*integrandF2[iaa0]; 491 | } 492 | 493 | final_result0 = dr2*dr*coe1 + dr2*coe2 + dr*coe3; 494 | } 495 | } 496 | 497 | final_result += final_result0; 498 | 499 | return final_result; 500 | } 501 | 502 | 503 | 504 | 505 | 506 | 507 | 508 | 509 | 510 | 511 | 512 | 513 | 514 | 515 | 516 | 517 | 518 | 519 | 520 | 521 | 522 | 523 | 524 | 525 | 526 | 527 | 528 | 529 | 530 | 531 | 532 | 533 | 534 | 535 | 536 | 537 | 538 | 539 | -------------------------------------------------------------------------------- /Atif/src/source/simpsonintegration.h: -------------------------------------------------------------------------------- 1 | //declaration the functions for Simpson Inergration// 2 | //*****************************************************************// 3 | #ifndef SIMPSONINTEGRAL_H_ 4 | #define SIMPSONINTEGRAL_H_ 5 | double SimpsonIntegration(double* integrandF,int aa,int bb,int ia,int ib); 6 | double SimpsonIntegration(double* integrandF,int aa,int bb,int ia,int ib,int i_R); 7 | double SimpsonIntegration(double* integrandF,int aa,int bb,int ia,int ib,double D2_j,int i_R); 8 | double SimpsonIntegration(int aa,int bb,int ia,int ib,double D2_j); 9 | double SimpsonIntegration(double* integrandF1,double* integrandF2,int aa,int bb,int ia,int ib); 10 | double SimpsonIntegration(double* integrandF1,double* integrandF2,int orient0,int ia,int ib); 11 | #endif //SIMPSONINTEGRAL_H_ 12 | -------------------------------------------------------------------------------- /Atif/src/source/systemset.h: -------------------------------------------------------------------------------- 1 | //define systemset.h 2 | #ifndef SYSTEMSET_H_ 3 | #define SYSTEMSET_H_ 4 | #include "clibrary.h" 5 | #include "constantnum.h" 6 | #include 7 | 8 | extern short nspecies; 9 | extern short* nb;//# of blocks in copolymer i; 10 | using namespace std; 11 | 12 | 13 | namespace systemset 14 | { 15 | struct Species //coordinate for short 16 | { 17 | float Z; //valency 18 | float D; //diameter 19 | float uWall;//interaction with wall; unit: kBT 20 | 21 | Species() 22 | { 23 | Z = 0.0; 24 | D = 0.0; 25 | uWall = 0.0; 26 | } 27 | }; 28 | struct SysInfo //dielectric constant assigned on the field link 29 | { 30 | float size; //separation of two plates 31 | double phi; //the surface electric potential 32 | float T; //Temperature 33 | float permiS; //dilectric constant for solution 34 | float permiW; //dilectric constant for surfaces 35 | float stepLen; //step length of the numerical method 36 | double lenth; //length unit 37 | //short iCode;//initialize 38 | 39 | SysInfo() 40 | { 41 | size = 0.0; 42 | phi = 0.0; 43 | T = 0.0; 44 | permiS = 0.0; 45 | permiW = 0.0; 46 | stepLen = 0.0; 47 | lenth = 0.0; 48 | } 49 | }; 50 | struct IteraInfo 51 | { 52 | int cstep; 53 | double mixCoe; //mixture coefficient of picard iteration 54 | double phL_L; 55 | double errTol; //the error tolerence 56 | double maxItera; //maximum iteration steps 57 | 58 | IteraInfo() 59 | { 60 | cstep = 0; 61 | mixCoe = 0.0; 62 | phL_L = 0.0; 63 | errTol = 0.0; 64 | maxItera = 0.0; 65 | } 66 | }; 67 | struct PolyInfo 68 | { 69 | short mp; //polymerization 70 | short nb; //number of blocks 71 | double rhopm;//monomer density 72 | string MODEL; 73 | double epsilon_b; 74 | 75 | PolyInfo() 76 | { 77 | mp = 0; 78 | nb = 0; 79 | rhopm= 0; 80 | MODEL= ""; 81 | epsilon_b=0; 82 | } 83 | }; 84 | 85 | struct MethodGeom 86 | { 87 | string Method; 88 | string Geomet; 89 | string nSurfs; 90 | string exPoten; 91 | double a; 92 | double b; 93 | 94 | MethodGeom() 95 | { 96 | Method= ""; 97 | Geomet= ""; 98 | nSurfs= ""; 99 | exPoten= ""; 100 | a = 1; 101 | b = 0; 102 | } 103 | }; 104 | 105 | void readSystem(short& nspecies1,PolyInfo* pInfo,Species* species,SysInfo& sysInfo,IteraInfo& iteraInfo, 106 | double* rhoB,double** pairEner,double& eta0,short** mb,float** zb,char fileName[],string& filePath); 107 | 108 | void readSystem(PolyInfo* pInfo,char fileName[],MethodGeom& MethG); 109 | } 110 | #endif // SYSTEMSET_H_ 111 | -------------------------------------------------------------------------------- /Atif/src/source/volumefraction.cpp: -------------------------------------------------------------------------------- 1 | //***********solve the possion equation****************// 2 | #include "clibrary.h" 3 | #include "volumefraction.h" 4 | #include "simpsonintegration.h" 5 | #include "constantnum.h" 6 | 7 | extern double dr; 8 | extern short nspecies; 9 | extern int LLIM; //the minimum lower limit of intergral 10 | extern int ngrid; //the number of grids 11 | extern int ngrid_m; //the number of grids: the middle between two surfaces 12 | 13 | void VolumeFraction(double eta_t,float* D,double* etar,double** rho) 14 | { 15 | short hspecies; 16 | double eta0; 17 | double* D3; 18 | double* eta; 19 | 20 | hspecies = nspecies - 1; 21 | 22 | eta = new double[hspecies](); 23 | D3 = new double[nspecies](); 24 | 25 | for(short i=0; i eta_t) 45 | { 46 | for(short i=0; i etar[i]) 49 | { 50 | rho[i][k] = rho[i][k]*etar[i]/eta[i]; 51 | rho[i][ngrid-k] = rho[i][k]; 52 | } 53 | } 54 | } 55 | 56 | eta0= 0; 57 | for(short i=0; i ULI[j]) kip = ULI[j]; 98 | 99 | temp =SimpsonIntegration(rho[j],0,ngrid,kin,kip,D2,i); 100 | N3I[j]=Pi*temp; 101 | eta[j] = N3I[j]; 102 | } 103 | 104 | 105 | delete [] N3I; 106 | } 107 | 108 | 109 | void VolumeFractionDFT(double eta_t,float* D,int* LLI,int* ULI,double* etar,double** rho) 110 | { 111 | short hspecies; 112 | double eta0; 113 | double* eta; 114 | 115 | hspecies = nspecies - 1; 116 | 117 | eta = new double[hspecies](); 118 | 119 | 120 | for(int k=LLIM; k<=ngrid_m; ++k) 121 | { 122 | VolumeFraction(k,LLI,ULI,D,rho,eta); 123 | 124 | 125 | eta0 = 0; 126 | for(short i=0; i eta_t) 132 | { 133 | for(short i=0; i etar[i]) 136 | { 137 | rho[i][k] = rho[i][k]*etar[i]/eta[i]; 138 | rho[i][ngrid-k] = rho[i][k]; 139 | } 140 | } 141 | } 142 | } 143 | 144 | delete [] eta; 145 | } 146 | -------------------------------------------------------------------------------- /Atif/src/source/volumefraction.h: -------------------------------------------------------------------------------- 1 | //declaration the functions for calculating volume fraction ******// 2 | //****************************************************************// 3 | #ifndef VOLUMEFRACTION_H_ 4 | #define VOLUMEFRACTION_H_ 5 | void VolumeFraction(double eta_t,float* D,double* etar,double** rho); 6 | void VolumeFraction(int i,int* LLI,int* ULI,float* D,double** rho,double* eta); 7 | void VolumeFractionDFT(double eta_t,float* D,int* LLI,int* ULI,double* etar,double** rho); 8 | #endif //VOLUMEFRACTION_H_ 9 | -------------------------------------------------------------------------------- /Atif/src/source/weighteddensity.h: -------------------------------------------------------------------------------- 1 | //declaration the functions for calculating weighted density******// 2 | //************** from FMT (see Rosenfeld, PRL, 1989 **************// 3 | //****************************************************************// 4 | #ifndef WEIGHTEDDENSITY_H_ 5 | #define WEIGHTEDDENSITY_H_ 6 | void WeightedDensity(int i,int* LLI,int* ULI,float* D,double** rho,double** NI); 7 | void WeightedDensity(float* D,double* rhoB,double** NIB); 8 | void WeightedDensity(int i,int* LLI,int* ULI,double* B,double** H,double** rho,double** QI); 9 | void WeightedDensity(double gammab,double* rhoB,double* B,double** H,double** QIB); 10 | void WeightedDensityDirk(int i,int* LLI,int* ULI,double* B,double** H,double** rho,double** QI); 11 | void WeightedDensityDirk(double gammab,double* rhoB,double* B,double** H,double** QIB); 12 | void WeightedDensityV(int i,int* LLI,int* ULI,double* B,double** H,double** rho,double** QI); 13 | void WeightedDensityV(double gammab,double* rhoB,double* B,double** H,double** QIB); 14 | void WeightedDensityDirk(int i,int* LLI,int* ULI,double* B,double** rho,double* QI); 15 | void WeightedDensityDirk(double gammab,double* rhoB,double* B,double* QIB); 16 | void WeightedDensityV(int i,int* LLI,int* ULI,double* B,double** rho,double* QI); 17 | void WeightedDensityV(double gammab,double* rhoB,double* B,double* QIB); 18 | 19 | #endif //WEIGHTEDDENSITY_H_ 20 | -------------------------------------------------------------------------------- /GETTINGSTART.md: -------------------------------------------------------------------------------- 1 | ## Getting start 2 | The following instructions explain how to compile **Atif** on your local machine. 3 | 4 | [An example input file](Atif/example/input_example.dat) are also provided to help you get started with your own project using Atif. The meanings of the parameters in the [input file](Atif/example/input_example.dat) have also been explained clearly in it. (If you get confused about the input file, please directly contact [the developer](https://github.com/jiangj-physchem)) 5 | 6 | Note that this guide is written for the Linux working environment, but it should also apply to the Mac OS terminal and Xcode and Visual Studio C++. 7 | 8 | ### Prerequisites 9 | 10 | You should make sure that `cmake` and `gcc` are installed properly on your machine. 11 | 12 | ### Installation 13 | 14 | Download the entire [Atif](Atif) directory to your local path `/Users/jiangj/`. 15 | ``` 16 | cd /Users/jiangj/Atif/cmake/ 17 | make 18 | ``` 19 | Then you will get an executable file named **ATIFExe** in the folder `/Users/jiangj/Atif/cmake/`. Now you are ready to start your project! 20 | ``` 21 | echo "/Users/jiangj/Atif/example/input_example.dat" | nohup ./ATIFExe & 22 | ``` 23 | You will find the output files in the folder as shown in the last line of the [input file](Atif//example/input_example.dat). 24 | -------------------------------------------------------------------------------- /LICENSE.md: -------------------------------------------------------------------------------- 1 | Copyright (c) 2021/01/08 Jian Jiang 2 | 3 | Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: 4 | 5 | The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. 6 | 7 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 8 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | ## Atif 2 | Atif is **an advanced theoretical tool for inhomogeneous fluids**. Atif can be used to study many kinds of fluids near a dielectric interface (**allow dielectric constant discontinuity**): 3 | * hard sphere fluids with size symmetry/asymmetry 4 | * electrolytes including size symmetry/asymmetry and monovalent/multivalent ions 5 | * flexible and semiflexible uncharged/charged polymers (polyelectrolytes) 6 | * block uncharged/charged polymers and sequential uncharged/charged polymers 7 | 8 | Currently, this theoretical tool is only for open systems (Grand-canonical ensemble). Howerver, it is very easy to make use of this tool to study issues in a closed system (canonical ensemble) with little changes (please directly contact [the developer](https://github.com/jiangj-physchem) if necessary). In addition, this current version can be used to study the inhomogeneous properties near a **planar surface** or in a **confined space**. 9 | 10 | In the future, we would also like to involve **spherical** and **cylindrical interfaces**. 11 | 12 | ## The theories we used in this tool 13 | 14 | **I. self-consistent field theory (SCFT)** 15 | * the flexible polymer is modeled by freely jointed chain model 16 | * the semiflexible polymer is modeled using discrete worm-like chain model 17 | * the excluded volume effect is treated using local incompressible condition 18 | * the electrosatic potenital is obtained using point charge model 19 | 20 | **II. density functional theory (DFT)** 21 | * the flexible polymer is modeled by freely jointed chain model 22 | * the semiflexible polymer is modeled using discrete worm-like chain model 23 | * the excluded volume effect is involved using modified fundamental measure theory (MFMT) 24 | * the electrostatic potential is obtained using truncated shell model (TSM) 25 | * the electrostatic correlations are involved using a functional mean spherical approximation (MSA) 26 | * the non-bonded chain connectivtiy contirbutions are considered using thermodynamic perturbation theory (TPT) 27 | 28 | I will cite the corresponding references subsequently. 29 | 30 | ## How to use Atif? 31 | Before you enjoy in **Atif**, please read the [GETTINGSTART.md](GETTINGSTART.md) file 32 | 33 | ## Want to thank the developer? 34 | If you think Atif really help you during your research career, please feel free to thank the developer in the "Acknowledge" section in your publications. If you would like to put the developer in the author list of your publications, please directly contact [the developer](https://github.com/jiangj-physchem). 35 | 36 | ## Contributing 37 | 38 | Currently, we have not set up the rules for submitting pull requests. Please directly contact [the developer](https://github.com/jiangj-physchem) if you would like to contribute. 39 | 40 | ## License 41 | 42 | Atif is licensed under the [MIT License](LICENSE.md). 43 | --------------------------------------------------------------------------------