mirror of
https://github.com/mveril/qp-demo
synced 2024-08-24 21:41:47 +02:00
Initial commit
This commit is contained in:
commit
fc7644d488
1
.gitignore
vendored
Normal file
1
.gitignore
vendored
Normal file
@ -0,0 +1 @@
|
|||||||
|
quantum_package_static.tar.gz
|
49
Dockerfile
Normal file
49
Dockerfile
Normal file
@ -0,0 +1,49 @@
|
|||||||
|
# For help about how Dockerfiles work, see https://docs.docker.com/engine/reference/builder
|
||||||
|
|
||||||
|
# This image is based from Ubuntu LTS
|
||||||
|
FROM ubuntu:latest
|
||||||
|
LABEL version="0.1" \
|
||||||
|
maintainer.name="Mickaël Véril" \
|
||||||
|
maintainer.email="" \
|
||||||
|
quantum_package.author.name="Anthony Scemama" \
|
||||||
|
quantum_package.author.email="" \
|
||||||
|
quantum_package.url="https://quantumpackage.github.io/qp2" \
|
||||||
|
quantum_package.repo="https://github.com/QuantumPackage/qp2" \
|
||||||
|
laboratory.name="Laboratoire de Chimie et Physique Quantique (LCPQ)" \
|
||||||
|
laboratory.url="http://www.lcpq.ups-tlse.fr/"
|
||||||
|
# Build argument (can be changed at build time see buiild.sh for an example)
|
||||||
|
# This argument define the user name
|
||||||
|
ARG user=user
|
||||||
|
# This argument define timezone for tzdata requierd by qp_run
|
||||||
|
ARG tz=Etc/UTC
|
||||||
|
# We could add another argument to configure the language of the image
|
||||||
|
# enable manpages installation
|
||||||
|
RUN sed -i 's,^path-exclude=/usr/share/man/,#path-exclude=/usr/share/man/,' /etc/dpkg/dpkg.cfg.d/excludes
|
||||||
|
# Install all requierd packages
|
||||||
|
RUN apt-get update && \
|
||||||
|
DEBIAN_FRONTEND=noninteractive apt-get install \
|
||||||
|
python htop vim emacs screen tmux less wget curl tzdata man manpages-posix lsb-release \
|
||||||
|
-y && \
|
||||||
|
apt-get autoremove && apt-get clean
|
||||||
|
# Reconfigure tzdata with the good timezone
|
||||||
|
RUN echo $tz > /etc/timezone && rm -rf /etc/localtime && echo "set mouse=" > ~/.vimrc
|
||||||
|
RUN dpkg-reconfigure -f noninteractive tzdata
|
||||||
|
# ADD user and switch to this user
|
||||||
|
RUN adduser --disabled-password --gecos '' $user
|
||||||
|
USER $user
|
||||||
|
# I don't know why but the USER environment variable is not set so I set it because it's requested for ninja
|
||||||
|
ENV USER=$user
|
||||||
|
# Go to home
|
||||||
|
WORKDIR /home/$user
|
||||||
|
# untar directly static quantum package and examples
|
||||||
|
ADD quantum_package_static.tar.gz .
|
||||||
|
COPY examples examples
|
||||||
|
# move quantum package
|
||||||
|
RUN mv quantum_package_static qp2
|
||||||
|
RUN echo "set -g default-command /home/$user/qp2/bin/qpsh" >> .tmux.conf
|
||||||
|
RUN echo "shell \"/home/$user/qp2/bin/qpsh\"" >> .screenrc
|
||||||
|
# start a qp shell when run
|
||||||
|
# I deleted /home/user because it's not necesary and can be a source of big if user arg is diferent to "user"
|
||||||
|
CMD ["./qp2/bin/qpsh"]
|
||||||
|
|
||||||
|
|
60
Dockerfile.compile
Normal file
60
Dockerfile.compile
Normal file
@ -0,0 +1,60 @@
|
|||||||
|
# For help about how Dockerfiles work, see https://docs.docker.com/engine/reference/builder
|
||||||
|
|
||||||
|
# This image is based from Ubuntu LTS
|
||||||
|
FROM ubuntu:latest
|
||||||
|
LABEL version="0.1" \
|
||||||
|
maintainer.name="Mickaël Véril" \
|
||||||
|
maintainer.email="" \
|
||||||
|
quantum_package.author.name="Anthony Scemama" \
|
||||||
|
quantum_package.author.email="" \
|
||||||
|
quantum_package.url="https://quantumpackage.github.io/qp2" \
|
||||||
|
quantum_package.repo="https://github.com/QuantumPackage/qp2" \
|
||||||
|
laboratory.name="Laboratoire de Chimie et Physique Quantique (LCPQ)" \
|
||||||
|
laboratory.url="http://www.lcpq.ups-tlse.fr/"
|
||||||
|
# Build argument (can be changed at build time see buiild.sh for an example)
|
||||||
|
# This argument define the user name
|
||||||
|
ARG user=user
|
||||||
|
# This argument define timezone for tzdata requierd by qp_run
|
||||||
|
ARG tz=Etc/UTC
|
||||||
|
# We could add another argument to configure the language of the image
|
||||||
|
# Install all requierd packages
|
||||||
|
RUN apt-get update && DEBIAN_FRONTEND=noninteractive apt-get install apt-utils -y
|
||||||
|
RUN DEBIAN_FRONTEND=noninteractive apt-get install \
|
||||||
|
# Git for download quantum package
|
||||||
|
git \
|
||||||
|
# All necessary packages to compile and run quantum package
|
||||||
|
curl wget python gfortran gcc g++ build-essential unzip liblapack-dev pkg-config autoconf zlib1g zlib1g-dev tzdata libgmp-dev \
|
||||||
|
# Other packages for user usage
|
||||||
|
htop vim emacs screen tmux less man -y
|
||||||
|
# Reconfigure tzdata with the good timezone
|
||||||
|
RUN echo $tz > /etc/timezone
|
||||||
|
RUN rm -rf /etc/localtime
|
||||||
|
RUN dpkg-reconfigure -f noninteractive tzdata
|
||||||
|
# ADD user and switch to this user
|
||||||
|
RUN adduser --disabled-password --gecos '' $user
|
||||||
|
USER $user
|
||||||
|
# I don't know why but the USER environment variable is not set so I set it because it's requested for ninja
|
||||||
|
ENV USER=$user
|
||||||
|
# Go to home
|
||||||
|
WORKDIR /home/$user
|
||||||
|
# Download quantum package
|
||||||
|
RUN git clone https://github.com/QuantumPackage/qp2
|
||||||
|
# Go to quantum package
|
||||||
|
WORKDIR /home/$user/qp2
|
||||||
|
# Configure
|
||||||
|
RUN TRAVIS=1 ./configure -i all -c config/gfortran.cfg
|
||||||
|
# source don't work with /bin/sh (used by the run command so I use bash)
|
||||||
|
# Compile the code
|
||||||
|
RUN /bin/bash -c "source quantum_package.rc ; ninja"
|
||||||
|
# Run tests
|
||||||
|
RUN /bin/bash -c "source quantum_package.rc ; qp_test -a"
|
||||||
|
# Return to the user directory
|
||||||
|
WORKDIR /home/$user/
|
||||||
|
# Add source to bashrc
|
||||||
|
RUN echo "source /home/$user/quantum_package/quantum_package.rc" >> ~/.bashrc
|
||||||
|
## start a login shell when run
|
||||||
|
#CMD ["/bin/bash","--login"]
|
||||||
|
# start a qpsh when run
|
||||||
|
CMD ["/bin/bash","--login", "-c", "qpsh"]
|
||||||
|
|
||||||
|
|
28
Makefile
Normal file
28
Makefile
Normal file
@ -0,0 +1,28 @@
|
|||||||
|
IMAGE = qp2
|
||||||
|
NETWORK = demo-net
|
||||||
|
|
||||||
|
default:
|
||||||
|
docker build -t $(IMAGE) .
|
||||||
|
|
||||||
|
no-cache:
|
||||||
|
docker build -t $(IMAGE) --no-cache .
|
||||||
|
|
||||||
|
compile:
|
||||||
|
docker build -t $(IMAGE) -f Dockerfile.compile .
|
||||||
|
|
||||||
|
compile-no-cache:
|
||||||
|
docker build -t $(IMAGE) -f Dockerfile.compile --no-cache . .
|
||||||
|
|
||||||
|
network:
|
||||||
|
docker network create -o "com.docker.network.bridge.enable_icc"="false" $(NETWORK)
|
||||||
|
|
||||||
|
network-clean:
|
||||||
|
docker network rm $(NETWORK)
|
||||||
|
|
||||||
|
image-clean:
|
||||||
|
docker image rm $(IMAGE)
|
||||||
|
|
||||||
|
clean: network-clean image-clean
|
||||||
|
|
||||||
|
test:
|
||||||
|
docker run -h qp-demo --rm -it $(IMAGE)
|
2
examples/1_hcn/README
Normal file
2
examples/1_hcn/README
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
Everything is explained in the run.qpsh script.
|
||||||
|
Open it with a text editor.
|
7
examples/1_hcn/hcn.xyz
Normal file
7
examples/1_hcn/hcn.xyz
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
3
|
||||||
|
HCN Geo: Experiment Mult: 1 symmetry: 14
|
||||||
|
C 0.0 0.0 0.0
|
||||||
|
H 0.0 0.0 1.064
|
||||||
|
N 0.0 0.0 -1.156
|
||||||
|
|
||||||
|
|
42
examples/1_hcn/run.qpsh
Executable file
42
examples/1_hcn/run.qpsh
Executable file
@ -0,0 +1,42 @@
|
|||||||
|
#!/usr/bin/env qpsh
|
||||||
|
|
||||||
|
# This first tutorial consists in obtaining the FCI energy of the HCN molecule.
|
||||||
|
# You can execute the commands interactively or you can execute this script.
|
||||||
|
#
|
||||||
|
# In interactive sessions, don't hesitate to use tab-completion with qp
|
||||||
|
# commands.
|
||||||
|
#
|
||||||
|
# To know what a qp command does, you can use qp man, for example:
|
||||||
|
#
|
||||||
|
# qp man qp_edit
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
# 1. Create the EZFIO database, with the STO-6G* basis set:
|
||||||
|
|
||||||
|
qp create_ezfio -b sto-6g_star hcn.xyz
|
||||||
|
|
||||||
|
# 2. Run the Hartree-Fock calculation:
|
||||||
|
|
||||||
|
qp run scf | tee scf.out
|
||||||
|
|
||||||
|
# 3. Set the core MOs as frozen:
|
||||||
|
|
||||||
|
qp set_frozen_core
|
||||||
|
|
||||||
|
# 4. Run the selected Full-CI:
|
||||||
|
|
||||||
|
qp run fci | tee fci.out
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
# To see all the possible control parameters, you can do
|
||||||
|
#
|
||||||
|
# qp edit
|
||||||
|
#
|
||||||
|
# which will open a virtual input file in a text editor.
|
||||||
|
# The choice of the editor can be set via the EDITOR environment variable:
|
||||||
|
#
|
||||||
|
# export EDITOR=vim
|
||||||
|
#
|
||||||
|
|
2
examples/2_h2o2/README
Normal file
2
examples/2_h2o2/README
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
Everything is explained in the run.qpsh script.
|
||||||
|
Open it with a text editor.
|
11
examples/2_h2o2/h2o2.zmt
Normal file
11
examples/2_h2o2/h2o2.zmt
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
o
|
||||||
|
o 1 oo
|
||||||
|
h 1 ho 2 hoo
|
||||||
|
h 2 ho 1 hoo 3 dih
|
||||||
|
|
||||||
|
oo 1.475
|
||||||
|
ho 0.95
|
||||||
|
hoo 94.8
|
||||||
|
dih 119.8
|
||||||
|
|
||||||
|
|
33
examples/2_h2o2/run.qpsh
Executable file
33
examples/2_h2o2/run.qpsh
Executable file
@ -0,0 +1,33 @@
|
|||||||
|
#!/usr/bin/env qpsh
|
||||||
|
|
||||||
|
# This second tutorial consists in obtaining the FCI energy of the
|
||||||
|
# H2O2 molecule. The geometry is given here in z-matrix format.
|
||||||
|
#
|
||||||
|
# To accelerate the convergence, instead of using Hartree-Fock MOs
|
||||||
|
# we will use CISD natural orbitals.
|
||||||
|
|
||||||
|
# 1. Create the EZFIO database, with the 6-31g basis set:
|
||||||
|
|
||||||
|
qp create_ezfio -b sto-6g_star h2o2.zmt
|
||||||
|
|
||||||
|
# 2. Run the Hartree-Fock calculation:
|
||||||
|
|
||||||
|
qp run scf | tee scf.out
|
||||||
|
|
||||||
|
# 3. Set the core MOs as frozen:
|
||||||
|
|
||||||
|
qp set_frozen_core
|
||||||
|
|
||||||
|
# 4. Run a CISD
|
||||||
|
|
||||||
|
qp run cisd | tee cisd.out
|
||||||
|
|
||||||
|
# 5. Obtain the natural orbitals of the CISD, and use them from now on
|
||||||
|
|
||||||
|
qp run save_natorb
|
||||||
|
|
||||||
|
# 6. Run the selected FCI with the CISD natural orbitals
|
||||||
|
|
||||||
|
qp run fci | tee fci.out
|
||||||
|
|
||||||
|
|
2
examples/3_n2/README
Normal file
2
examples/3_n2/README
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
Everything is explained in the run.qpsh script.
|
||||||
|
Open it with a text editor.
|
3
examples/3_n2/n2.zmt
Normal file
3
examples/3_n2/n2.zmt
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
n
|
||||||
|
n 1 1.0976
|
||||||
|
|
49
examples/3_n2/run.qpsh
Executable file
49
examples/3_n2/run.qpsh
Executable file
@ -0,0 +1,49 @@
|
|||||||
|
#!/usr/bin/env qpsh
|
||||||
|
|
||||||
|
# In this third tutorial, we will compute the ground state and the lowest
|
||||||
|
# singly excited of N2.
|
||||||
|
|
||||||
|
# 1. Create the EZFIO database, with the def2-svp basis set:
|
||||||
|
|
||||||
|
qp create_ezfio -b def2-svp n2.zmt
|
||||||
|
|
||||||
|
# 2. Run the Hartree-Fock calculation:
|
||||||
|
|
||||||
|
qp run scf | tee scf.out
|
||||||
|
|
||||||
|
# 3. Set the core MOs as frozen:
|
||||||
|
|
||||||
|
qp set_frozen_core
|
||||||
|
|
||||||
|
# 4. Request for two states
|
||||||
|
|
||||||
|
qp set determinants n_states 2
|
||||||
|
|
||||||
|
# 5. Run a CIS
|
||||||
|
|
||||||
|
qp run cis
|
||||||
|
|
||||||
|
# 6. Truncate the wave function to the 2 most important determinants : the
|
||||||
|
# Hartree-Fock and one a singly excited determinant (spin symmetry will
|
||||||
|
# be automatically restored in the next calculation)
|
||||||
|
|
||||||
|
qp edit -n 2
|
||||||
|
|
||||||
|
# 7. Set the CIS wave function as the starting trial wave function
|
||||||
|
|
||||||
|
qp set determinants read_wf True
|
||||||
|
|
||||||
|
# 8. To avoid collapsing to the ground state and a doubly excited state,
|
||||||
|
# force to use a state-following algorithm
|
||||||
|
|
||||||
|
qp set davidson state_following True
|
||||||
|
|
||||||
|
# 9. Terminate when we have 50000 determinants
|
||||||
|
|
||||||
|
qp set determinants n_det_max 50*10**3
|
||||||
|
|
||||||
|
# 10. Run the selected FCI calculation
|
||||||
|
|
||||||
|
qp run fci | tee fci.out
|
||||||
|
|
||||||
|
|
79
run.sh
Executable file
79
run.sh
Executable file
@ -0,0 +1,79 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
# Add a timeout to a existing container
|
||||||
|
DockerTimeout() {
|
||||||
|
docker events -f event=start -f type=container -f container=$1 | head -n 0
|
||||||
|
timeout $2 docker wait $1>/dev/null
|
||||||
|
if [ $? -eq 124 ] ; then
|
||||||
|
docker kill $1> /dev/null
|
||||||
|
return 1
|
||||||
|
else
|
||||||
|
return 0
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
# Create an interactive docker container for an image and echo it's ID (use docker start command to start the container)
|
||||||
|
DockerCreate() {
|
||||||
|
docker create -h qp-demo -l demo --network=demo-net --rm -it $1
|
||||||
|
}
|
||||||
|
DockerGetNextID() {
|
||||||
|
docker ps -aq -f ancestor="$1" -f "label=demo" -f status=created --no-trunc | tail -n 1
|
||||||
|
}
|
||||||
|
|
||||||
|
# Count the number of container for a specific image
|
||||||
|
DockerCountCont() {
|
||||||
|
docker ps -f ancestor="$1" -f "label=demo" -q | wc -l
|
||||||
|
}
|
||||||
|
# Selected image
|
||||||
|
image=scemama/qp2
|
||||||
|
# Time limit for the container in the format of the timeout command
|
||||||
|
timeout=10m
|
||||||
|
# Number of container that running at the same time
|
||||||
|
contlimit=4
|
||||||
|
allocated=false
|
||||||
|
printwaitmessage=true
|
||||||
|
allowRun=true
|
||||||
|
|
||||||
|
cont=$(DockerCreate $image)
|
||||||
|
trap "docker rm $cont" EXIT INT TERM
|
||||||
|
echo "Your ID is : $cont"
|
||||||
|
# Until a container is started
|
||||||
|
until $allocated
|
||||||
|
do
|
||||||
|
# If the limit is reached
|
||||||
|
if [ $(DockerCountCont $image) -ge $contlimit ] ; then
|
||||||
|
allowRun=false
|
||||||
|
# Get the next container in the queue
|
||||||
|
nextcont=$(DockerGetNextID $image)
|
||||||
|
# print the message only one time
|
||||||
|
if $printwaitmessage ; then
|
||||||
|
echo Maximum number of sessions reached. Please wait for allocation...
|
||||||
|
fi
|
||||||
|
printwaitmessage=false
|
||||||
|
# Wait the die of a container
|
||||||
|
docker events -f event=die -f event=destroy -f type=container -f image=$image -f "label=demo" | head -n 0
|
||||||
|
if [ "$nextcont" == "$cont" ]; then
|
||||||
|
allowRun=true
|
||||||
|
fi
|
||||||
|
# Sleep because is's needed by docker for a good count of containers
|
||||||
|
else
|
||||||
|
if $allowRun ; then
|
||||||
|
allocated=true
|
||||||
|
# If there it's permited by the container number limit allocate a container and get it's ID
|
||||||
|
echo -e "Session allocated."
|
||||||
|
# Count the number of container available
|
||||||
|
aval=$(expr $(expr $contlimit - $(DockerCountCont $image) - 1))
|
||||||
|
[[ "$aval" -lt 0 ]] && aval=0
|
||||||
|
# Show it to the user
|
||||||
|
echo "There are $aval sessions left available"
|
||||||
|
if [ $# -eq 0 ] || [ "$1" != "unlimited" ] ; then
|
||||||
|
# Apply a timout only if the argument ulimited is not given to the script
|
||||||
|
DockerTimeout $cont $timeout &
|
||||||
|
fi
|
||||||
|
# start the container in interactive mode and attach it to the terminal
|
||||||
|
trap "docker kill $cont" EXIT INT TERM
|
||||||
|
docker start -a -i $cont
|
||||||
|
trap - EXIT INT TERM
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
done
|
Loading…
Reference in New Issue
Block a user