Before the tutorial, we need a Linux system (CentOS) with gcc-8, gfortran-8. Other prerequisite softwares for CASTEP are: BLAS, LAPACK, OpenBLAS, cmake, openmpi. I install them in my own difined directory: ~/softwares/ , that is, in ~/softwares/bin are the executable files and in ~/softwares/lib are the library files. It is better not to install them in all different directories like ~/softwares/OpenBLAS, ~/softwares/LAPACK and so on, which will make the .bash_profile a lot of messy. It is even better if we define some new directories like ~/softwares/opt, in which we can manage the CASTEP, Python and some other user-specified softwares.
In this project, I put some notes and simple results for other beginners like me who want to try something new. Internet does change the world.
install the softwares in these three days and write the log.
export LANG="en_US.UTF-8"
export XAUTHORITY=$HOME/.Xauthority
play with the bash prompt looking. and add the following sentence to .bash_profile:
PS1='\e[1;34m\u:\w\n\e[0m\D{%m/%d}> '
see also: https://phoenixnap.com/kb/change-bash-prompt-linux
a) add to the client's ~/.ssh/CONFIG (or config) file:
ForwardX11 yes
b) change the server's /etc/ssh/sshd_config
X11Forwarding yes
X11DisplayOffset 10
X11UseLocalhost yes
c) restart the server ssh service (or simply reboot the server)
service sshd restart
or
/etc/init.d/sshd restart
or
sudo systemctl restart sshd
(see also, https://www.cyberciti.biz/faq/howto-restart-ssh/)
d) close all the terminals that link to the server from the client, then ssh again, which works for me.
working with "Tutorial 3 : Converging Testing":
taskset -c 13 castep.serial quartz
which let castep run on the core 13 of the CPU. (-c can be replaced by --cpu-list) cpu/processor affinity is the keyword to search. maybe we should disable the multicore feature.
had a discussion with ZHANG Qi on wechat about the "multiprocessing.Pool()". he gave me some advices and I tried several tests but failed. He sent me message this noon by showing me the correct way to communicate between processes using "multiprocessing.Manager().Queue()". The communication may slow down the calculation a bit.
My way is to averagely divide the processes to each processor. But "Pool()" will send the process to the processor just after the last one finished, however new process got some possibilities to be sent to the processor that is running for other processes. From this point, my way may be not faster than his too much. In case of sending several processes to the same processor, it may be better to let the processes communicate before they are launched. (which is suitable for large-scale parallel calculations.)
add an image into markdown file. see also: https://marinegeo.github.io/2018-08-10-adding-images-markdown/
finished tutorial-3, many info in (.castep) file still unknown for me. a simple case of geometry optimization for quartz system is also completed. see the note for details. see also: http://www.tcm.phy.cam.ac.uk/castep/Geom_Opt/GEOM_OPT.html and the note in notes_t_silicon/
about the pseudo-potential file, see also: http://www.castep.org/CASTEP/FAQPseudopotentials
to utilize the built-in library, just comment out the following sentences:
#%BLOCK SPECIES_POT
# Si Si_00.usp
#%ENDBLOCK SPECIES_POT
sudo yum -y groups install "GNOME Desktop"
echo "exec gnome-session" > ~/.xinitrc
then type in "startx" for a graphical desktop to be launched. (For now, only the screen connected to my computer can ouput a graphical desktop. If connected remotely, xauth error occurs and I haven't solve the problem.) I do not set this as my default login method, which can be done from the following command:
systemctl set-default graphical.target
continue reproducing the results in "Geometry Optimisation".
"to specify a restart and not a fresh calculation", we need a (.check) file existed and put the following line into the (.param) file
continuation : default
Geometry Optimization of Si-001 plane with hydrogen passivation. not succeeded for now.
mpirun to control the processes running on specified cores:
mpirun -n 4 -display-devel-map --map-by socket --bind-to cpu-list:ordered --cpu-list "4,5,6,7" castep.mpi si
where the option "--map-by socket" may be useless. However, it seems MPI first map the processes and then rank them and finally bind them to cores. see also: https://www.open-mpi.org/doc/v4.0/man1/mpirun.1.php for "Mapping, Ranking, and Binding: Oh My!"
A rankfile could be useful for this purpose.
1.1) "yum install code" may not work. "snap" may help:
sudo snap install --classic code
see also: https://code.visualstudio.com/docs/setup/linux
1.2) the CentOS7 does not detect my second screen. but this can be fixed after I install the Nvidia driver for xps8940 (GeForce RTX 3070). It says the default gcc for CentOS7 is 4.8.5 (see also: https://docs.nvidia.com/cuda/cuda-installation-guide-linux/index.html#runfile-nouveau). To perform the runfile installation, we need first to disable the Nouveau drivers by create a file at /usr/lib/modprobe.d/blacklist-nouveau.conf with following content:
blacklist nouveau
options nouveau modeset=0
then regenerate the kernal initramfs
sudo dracut --force
and change the graphical mode followed by reboot
systemctl set-default multi-user.target
init 3
reboot
and finally run the bash file downloaded from NVIDIA website
bash NVIDIA-*.run
After installation, reset the default login mode:
systemctl set-default graphical.target
or maybe just "init 5" back to graphical mode.
see also: https://blog.csdn.net/tony_vip/article/details/104531383 ; https://blog.csdn.net/xueshengke/article/details/78134991
1.3) fftw, openmpi
./configure --prefix=/home/cpan/softwares
"--enable-threads", "--enable-openmp", "--enable-mpi" may be useful for specific purpose when using fftw lib.
1.4) castep-20.11
1.4.1) prerequisite:
yum group install "Development Tools"
yum install centos-release-scl
yum install devtoolset-7
yum install lapack lapack-devel blas blas-devel openssl openssl-devel fftw fftw-devel openblas openblas-devel
add "source scl_source enable devtoolset-7" in "~/.bash_profile", and comment if after we install "castep".
1.4.2) serial version,
make FFT=fftw3 MATHLIBS=openblas FFTLIBDIR=/usr/lib64 MATHLIBDIR=/usr/lib64
make install INSTALL_DIR=/dir/to/install
1.4.3) parallel version
make COMMS_ARCH=mpi SUBARCH=mpi FFT=fftw3 MATHLIBS=openblas FFTLIBDIR=/usr/lib64 MATHLIBDIR=/usr/lib64
make install INSTALL_DIR=/dir/to/install
better not use "-j" flag, both "make" and "make check" could be much more efficient.
1.5) xmgrace, gnuplot
yum install xmgrace gnuplot
1.6) miniconda, openmm
bash Miniconda3-py39_4.9.2-Linux-x86_64.sh
eval "$(/home/cpan/softwares/opt/miniconda3/bin/conda shell.bash hook)"
conda install -c conda-forge openmm cudatoolkit==11.2.2
python -m simtk.testInstallation
Cuda Toolkit-11.4 is installed on xps8940, and related cudatoolkit-11.2.2 is installed by conda. The check/test is successfully over and I do not plan to re-install the Cuda Toolkit-11.2.2 on xps8940.
mpirun -n 4 castep.mpi si
is the same as the previous complicated command on cls0:
mpirun -n 4 -display-devel-map --map-by socket --bind-to cpu-list:ordered --cpu-list "4,5,6,7" castep.mpi si
And on xps8940, "mpirun" can run a new job smartly by sending processes to the idle processors with old ones running undisturbed. (actually, all calculations slow down) It should has 16 cpus, and I submit 4 "mpirun -n 4" jobs with the --cpu-list separately "0,1", "2,3", "4,5", "6,7", however the "Total time" are:
Total time = 442.15 s
Total time = 416.46 s
Total time = 363.72 s
Total time = 417.15 s
however "castep.serial" only cost ~260 s. need more tests.
it should be the high-energy state rather than the thickness of the vacuum largely impacts how to reach the local minimum.
I try to do the geometry optimization for different initial configurations that are slightly different from the crystal configuration. (1%,5%,0.1% randomly deviated) All finally output the dimerization. Climbing the hills in energy map is also found.
It is a functional module in CASTEP.
task : transitionstatesearch
1.1) I forgot to run "singlepoint" or "geometryoptimization" for LiPS singlet, which may indicate how to choose the "cut_off_ene".
The problem I met is that lithium atom moves away from nitrogen atom during optimization, however they should close each other due to electrostatic attraction.
sedc_scheme : G06
refs:
a) Interface covalent bonding endowing high-sulfur-loading paper cathode with robustness for energy-dense, compact and foldable lithium-sulfur batteries, Hong Li et. al., Chemical Enginerring Journal 412 (2021) 128562
b) Cobalt in Nitrogen-Doped Graphene as Single-Atom Catalyst for High-Sulfur Content Lithium−Sulfur Batteries, Zhenzhene Du et. al., Journal of the American Chemical Society 2019, 141, 3977--398
see also:
documentation for "sedc_scheme", https://www.tcm.phy.cam.ac.uk/castep/documentation/WebHelp/content/modules/castep/keywords/k_sedc_scheme_castep.htm ;
DFT-D3, https://www.chemie.uni-bonn.de/pctc/mulliken-center/software/dft-d3/ ;
"CASTEP background theory", https://www.tcm.phy.cam.ac.uk/castep/documentation/WebHelp/content/modules/castep/thcastepbackground.htm
2.1) Li2021 paper also suggests one "Hubbard U correction". see also: https://www.tcm.phy.cam.ac.uk/castep/documentation/WebHelp/content/modules/castep/keywords/k_hubbard_u_castep.htm
2.2) actually, both papers above do not emphasize the "norm conserving pseudo-potential".
2.2.1) they also prescribe the "cut_off_ene" as "400 eV" and "kpoints_mp_grid" as "3x3x1" or "5x5x1".
2.2.2) energy converges to "5e-6 eV/atom" or "1e-5 eV/atom", force converges to "0.01 eV/A"
a) is "metals_method : dm" relavent to our LiPS optimization on surfaces? comment it or not?
b) lz = 20 or more? (mine is 15)
c) do we need to firstly optimize the surface then the whole system? (haven't done yet)
1.1) slides of a lecture by Stewart Clark I found online also points that
Golden rule: Try to use the number of cores that gives you the highest common factor with the number of k-points
Example of 5-point calculation
10 cores: 48 seconds 13cores: 172 seconds
see: "Introduction to the CASTEP code", https://www.tcm.phy.cam.ac.uk/castep/oxford/castep.pdf
1.2) about the kpoints, see also: http://www.tcm.phy.cam.ac.uk/castep/documentation/WebHelp/content/modules/castep/tskcastepseteleckpoints.htm ; https://www.tcm.phy.cam.ac.uk/castep/documentation/WebHelp/content/modules/castep/dlgcastepelecoptkpoints.htm#:~:text=k-points tab The k-points tab provides access to,the calculation can be specified in several ways.
The quality of the k-point sampling is particularly important for metallic systems, where rapid changes in electronic structure may occur along the energy band that crosses the Fermi level. Insulartors or semiconductors, even whtn they are treated using variable occupation numbers for electronic states, are less sensitive to the quality of k-point sampling. The default settings used by CASTEP are designed to give accurate sampling for metallic systems. This means that you can get good results for insulators and semiconductors with a slightly less fine k-point mesh than the default.
working with the parameter settings for MnO2 surface system in recent several days. The "fix_occupancy : true" instructed in the tutorial could be very misleading for our systems. I'm considering comment the "fix_occupancy : true" command in (.param) file to re-run the optimization for LiPS on carbon or nitrogen doped carbon sheet.
having the single-point energy calculated for MnO2 system, that is, the calculation converges within 100 SCF cycles.
mixing_scheme : pulay
mix_charge_amp : 0.2
mix_spin_amp : 0.2
with "cut_off_energy : 500" and "kpoints_mp_grid 3 3 1 " written in the (.cell) file.
I'm thinking if ''BFGS'' is more accurate than ''LBFGS'' when run geometry optimization.
Is that ok to first optimize with ''LBFGS'' and ''geom_force_tol : 0.05'' and later with ''BFGS'' and ''geom_force_tol : 0.01''?
''BFGS'' + ''geom_force_tol : 0.01'' succeeded for C_Li2S6 system. (no_fix_occupancy5) other optimization are canceled.
select @xx
label "xx"
color label green
font label 35
set labeloffset 20 30
set monitor on/off
see also: https://cbm.msoe.edu/includes/modules/jmolTutorial/jmolLabel.html#anchor2 ; http://www.chm.bris.ac.uk/jmol/jmol-7/doc/JmolUserGuide/index.html
(1) MnO2 project was aborted after last summer. I cannot relax the LiPS on MnO2 surface.
(2) MoS2 project was constructed this month to collaborate with ZHANG Yu. We first relaxed the MoS2 surface and then put Li2S on it. Things got a little quicker because of the experiences last summer.
*** One problem I met is the error ''norm_sq is negative''. I tried ''%block species_pot'' in .cell file marked by ''NCP'' which really avoids the error repeated.
During checking the files (.cell, .param, and .geom), I found that the unit in .geom is bohr and in .cell is angstrom. My carelessness is the forgetting of changing bohr to angstrom when building the surface. After I fix the unit exchanging problem, the error disappears.
LiPS have been relaxed in the unit box (@xps8940), because I found the size of box in z-direction may affect the vdw correction of energy for MoS2 substrate.
Q: Should I re-relax the MoS2 substrate in the large box?
grahene is being relaxed in the large unit box (@xps8940) with no atom constrained for now.
2.1) LiPS relaxations on graphen begin.
The relaxation of Li2S4 on MoS2 is hard to fulfill. I'm thinking if the initial configure is bad and needs to be rotated to let two Li atoms close to the surface.
3.1) optimization done, still only one Li atom pointing down.
relaxation of Li2S6 on MoS2 completed.
relaxation of LiPS on graphene does not converge within 100 cycles.
Relaxation of LiPS on MoS2 completed! The next step should the search of transition states!
find something interesting on the website: http://www.castep.org/CASTEP/OtherCodes
``ase'' is a python package that incorporates a lot of calculators (like castep, vasp, gpaw etc.).
successfully install gpaw (parallel version). "pip install gpaw" is easy but only runs gpaw tests on single core. Following way has been tested: "yum install libxc-devel openblas-devel fftw-devel blacs-openmpi-devel scalapack-openmpi-devel" install the mpi-version for these packages. then "python -m pip install -v gpaw --user"
links below are helpful:
https://wiki.fysik.dtu.dk/gpaw/install.html#siteconfig ; https://wiki.fysik.dtu.dk/gpaw/platforms/Linux/centos.html
python 3.8 and 3.6 are tested to be successful for installing gpaw on xps8940 (user: guest, cp)
summary:
pip install ase
conda activate py38
export PATH=/usr/lib64/openmpi/bin:$PATH
export LD_LIBRARY_PATH=/usr/lib64/openmpi/lib:$LD_LIBRARY_PATH
export GPAW_SETUP_PATH=/home/cp/.local/share/gpaw_datasets/gpaw-setups-0.9.20000
the last line indicates where the preset dataset locates. better download it from https://wiki.fysik.dtu.dk/gpaw/setups/setups.html#installation-of-paw-datasets
then "source ~/.bash_gpaw" everytime before use gpaw. 4) go into the installing package of gpaw, edit the ./siteconfig.py,
fftw = True
scalapack = True
libraries = ['xc', 'fftw3', 'scalapack', 'mpiblacs']
library_dirs = ['/usr/lib64/openmpi/lib/']
then "pip install gpaw" and test by "gpaw info", "gpaw test" and "gpaw -P 4 test".
Reminder: To install the "gpaw" package of parallel version, we need to tell the OS where to find other packages (libxc, fftw, blacs, scalapack etc) of parallel version. (See also step 3 above)
play with Windows 10 OpenSSH for a couple of days. The official tutorial on installation may be helpful: https://learn.microsoft.com/zh-cn/windows-server/administration/openssh/openssh_install_firstuse
also learn to use powerShell, see also: https://blog.csdn.net/weixin_41010198/article/details/117513931
test Win10 firewall settings, but not succeed on specific local port for remote login.
see also, python installation in offline mode; mirrors; conda environment installation in offline mode
play with ase tutorial and gpaw tutorial.
"LCAO" mode is suitable for calculating geometries with a small basis set, and "PW" (plane-wave) mode is suitable for small unit cell.
problem fixed. a error caused by the typo in the original tutorial file. The following two sentences make the calculation absurd.
cell0 = al.cell
...
al.cell = (1+eps)*cell0
which should be rewritten by np.copy() to avoid excess changing of the cell parameter
cell0 = np.copy(al.cell)
Then the energies converge as cutoff increases.
see also, cp@xps8940:~/workspace/y23/02/gpaw_tutorial/0basics/Al/lattice_constant/0ecut.py
Usage in ase: (after "pip install dftd3")
xc = 'PBE'
calcname = 'graphite-{}'.format(xc)
dft = GPAW(mode=PW(500), kpts=(10, 10, 6), xc=xc, txt=calcname + '_DFTD3.log')
calc = DFTD3(method='pbe', damping='d3bj').add_calculator(dft)
The next step is to optimize the structure of Li metal and get the energy for different methods (LDA, PBE, PBE+DFT-D3).
intercalation energy : exp. (-0.124) , LDA (-0.359), PBE (-0.058), PBE+DFT-D3 (0.0005), BEEF-vdW (-0.0695)
not fully understand the Li/FePO4 part. explanations on the webpage are not complete.
2.1) no idea about the volume change during charge/discharge.
2.2) no idea about the gravimetric or volumetric energy density of a FePO4/C battery
initial = read(NEB_init.traj)
final = initial.copy()
cell = initial.get_cell()
# "view(initial)" to see the symmetry
final[-1].x -= (cell[0,0]+cell[1,0])/3.
final[-1].y -= (cell[0,1]+cell[1,1])/3.
neb = NEB(images)
neb.interpolate()
for image in images[0:7]:
calc = GPAW(mode=PW(500), kpts=(5, 5, 6), xc='LDA', txt=None, symmetry={'point_group': False})
image.set_calculator(calc)
image.set_constraint(FixAtoms(mask=[atom.symbol == 'C' for atom in image]))
# To better illustrate how the NEB method works, the symmetry is broken using the rattle function.
images[3].rattle(stdev=0.05, seed=42)
images[0].get_potential_energy()
images[0].get_forces()
images[6].get_potential_energy()
images[6].get_forces()
optimizer = BFGS(neb, trajectory='neb.traj', logfile='neb.log' )
optimizer.run(fmax=0.10)
An easy way to get the final position of a specific atom is to add a vector to its position. Such a vector is just difference between two identical atoms on the surface, no matter if these two are the nearest identical atoms or not.
open database for DFT calculating: https://oqmd.org/
play with N2 on Ru (111) surface.
The N-N bond is slightly elongated due to the interaction with the surface.
slab = read('Ru.traj') # Atoms('Ru8', ...)
slab.get_positions() # output all the positions of atoms
Ru4 = slab[4] # Atom('Ru', [x,y,z], ...)
Ru4.position # output the position
It seems N2 molecule rather stable when standing on the top of one Ru atom.
Note: E_ads = E_N2@slab - E_N2 - E_slab
3.1) N2 lying on Ru, after relaxation, the bond length turns to 1.284, even elongated more.
3.2) start from the lying state, the dissociation state with two N atoms staying at two neighbor hollow sites seems more favorable. dE = E_NN - E_lying = -0.114 eV
Ubuntu official website also provides some simple examples: ubuntu official examaples
see also: failure in name resolution
# This is the network config written by 'subiquity'
network:
version: 2
renderer: NetworkManager
ethernets:
enp0s31f6:
dhcp4: no
addresses: [xx.xx.xx.xx/24]
nameservers:
addresses: [10.1.1.9, 8.8.8.8, 8.8.4.4, 114.114.114.114]
enp2s0:
dhcp4: true
For now this setup works well. "NetworkManager" is better than "networkd" on my server. see also: to start or stop "NetworkManager" and "networkd"
Pressing "Tab" key doesn't work for programmable completion when login Dell7920. You may want to check the shell in use first. see also: programmable completion
install "ase" and "gpaw" on Dell7920-ubuntu-server. To install mpi-version "gpaw", one needs to download the source file (link for gpaw-22.8.0.tar.gz, webpage to get source code) and install by
python setup.py build
python setup.py install
"site_config.py" file should be edited before installation. see also, instruction for ubuntu
other tips see also: link for gpaw-setups-0.9.20000, webpage to get gpaw datasets
ssh with no password typed in: copy the "id_rsa.pub" file to the server (cls0), then rename it to "authorized_keys", and "chmod a-rw authorized_keys && chmod u+rw authorized_keys".
try to install cp2k on cls0 and xps8940. not succeed for now. the following command is typed in to build the dependences:
./install_cp2k_toolchain.sh --install-all
2.1) then start from installation of the dependences for gcc
# gmp
./configure --prefix=/home/cp/Downloads/cp2k-2023.1/tools/toolchain/build
make -j8
make install
# mpfr
./configure --with-gmp=/home/cp/Downloads/cp2k-2023.1/tools/toolchain/build --prefix=/home/cp/Downloads/cp2k-2023.1/tools/toolchain/build
make -j8
make install
# mpc
./configure --with-gmp=/home/cp/Downloads/cp2k-2023.1/tools/toolchain/build --with-gmp=/home/cp/Downloads/cp2k-2023.1/tools/toolchain/build --prefix=/home/cp/Downloads/cp2k-2023.1/tools/toolchain/build
make -j8
make install
# isl
./configure --with-gmp=/home/cp/Downloads/cp2k-2023.1/tools/toolchain/build --with-gmp=/home/cp/Downloads/cp2k-2023.1/tools/toolchain/build --with-mpc=/home/cp/Downloads/cp2k-2023.1/tools/toolchain/build --prefix=/home/cp/Downloads/cp2k-2023.1/tools/toolchain/build
make -j8
make install
2.2) vim "~/.bash_cp2k"
build=/home/cp/Downloads/cp2k-2023.1/tools/toolchain/build
PATH=$build/bin:$PATH
LD_LIBRARY_PATH=$build/lib:$LD_LIBRARY_PATH
LD_LIBRARY_PATH=$build/lib64:$LD_LIBRARY_PATH
export PATH
export LD_LIBRARY_PATH
"source ~/.bash_cp2k" to avoid the error of losing libisl.so.23 during compiling gcc. 2.3) install gcc
./configure --with-gmp=/home/cp/Downloads/cp2k-2023.1/tools/toolchain/build --with-gmp=/home/cp/Downloads/cp2k-2023.1/tools/toolchain/build --with-mpc=/home/cp/Downloads/cp2k-2023.1/tools/toolchain/build --with-isl=/home/cp/Downloads/cp2k-2023.1/tools/toolchain/build --prefix=/home/cp/Downloads/cp2k-2023.1/tools/toolchain/build --disable-multilib --enable-languages=c,c++
2.3.1) "enable-languages=c,c++" could be very important. (for now on xps8940, install gcc-10.3 with such "enable" line, c and c++ complier done, while "--enable-languages=c,c++,gfortran" failed)
2.3.2) suddenly found one serious problem about the compatability between the compiler and cp2k. see also cp2k-official-report-compiler-support. gcc-12.2 may cause elpa installation failure.
2.3.3) see also: official installation configuration
It's a good idea to compile gcc without statements of "C_INCLUDE_PATH" in the bash, i.e. source a new empty bash file to configure for gcc path only.
yum install gcc-c++
1.1) "toolchain" downloads the necessary packages of the specific version for the installation. that is to say, just follow it rather than download and install the packages by hand.
./install_cp2k_toolchain.sh --with-gcc=install --with-openmpi=enable --gpu-ver=A100 --enable-cuda --no-check-certificate
after installation of these prerequisites, copy the arch files to the arch folder under the root folder of cp2k, then source and make.
1.1.1) it seems "A100" is close to "RTX 3070" card in graphic acceleration. their cuda arch are separately "sm_80" and "sm_86". see also matching cuda arch and cuda gencode
1.1) latest cuda-12 is installed before compile "elpa". the old cuda-11.4 does not work. (the "cudaErrorUnsupportedPtxVersion" error) see also: (common seen cuda error)[https://blog.csdn.net/Bit_Coders/article/details/113181262]
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。