diff --git a/.gitignore b/.gitignore
index 445c19e..84c4200 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,32 +1,27 @@
+*~
+*.tar.gz
+
# Compiled Object files
-*.slo
-*.lo
*.o
-*.obj
-
-# Precompiled Headers
-*.gch
-*.pch
-
-# Compiled Dynamic libraries
-*.so
-*.dylib
-*.dll
-
-# Fortran module files
-*.mod
-*.smod
-
-# Compiled Static libraries
-*.lai
-*.la
*.a
-*.lib
-
-# Executables
-*.exe
-*.out
-*.app
+# Binary related files
+gmon.out
bin/*
-test-output/*
+
+# autoconf/automake files
+.deps
+.dirstamp
+aclocal.m4
+autom4te.cache
+config.log
+config.status
+compile
+configure
+depcomp
+install-sh
+INSTALL
+Makefile
+Makefile.in
+missing
+
diff --git a/AUTHORS b/AUTHORS
new file mode 100644
index 0000000..e69de29
diff --git a/COPYING b/COPYING
new file mode 120000
index 0000000..88798ab
--- /dev/null
+++ b/COPYING
@@ -0,0 +1 @@
+/usr/share/automake-1.15/COPYING
\ No newline at end of file
diff --git a/ChangeLog b/ChangeLog
new file mode 100644
index 0000000..e69de29
diff --git a/Makefile b/Makefile
deleted file mode 100644
index c5da243..0000000
--- a/Makefile
+++ /dev/null
@@ -1,120 +0,0 @@
-#!/usr/bin/make
-
-# Copyright (C) 2016-2017 David C. Miller
-
-# This file is part of TMD CDW Unit Cell Generator
-
-# TMD CDW Unit Cell Generatort is free software: you can redistribute it
-# and/or modify it under the terms of the GNU Lesser General Public
-# License as published by the Free Software Foundation, either version
-# 3 of the License, or (at your option) any later version.
-
-# TMD CDW Unit Cell Generator is distributed in the hope that it will be
-# useful, but WITHOUT ANY WARRANTY; without even the implied warranty
-# of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU Lesser General Public License for more details.
-
-# You should have received a copy of the GNU Lesser General Public
-# License along with TMD CDW Unit Cell Generator. If not, see
-# .
-
-#makefile
-#defines all rules and should NOT be edited
-#except as necessary
-
-include makefile.include
-
-#############################################
-# VERSION (DO NOT EDIT) #
-#############################################
-# #
-FLAGS_BASE += -DVERSION='"0.2.0"' #
-# #
-#############################################
-
-#########################
-# Local Directories #
-#########################
-
-#intentionally blank
-DIRLIST =
-
-#code directories
-ODIR = obj
-BDIR = bin
-IDIR = inc
-SDIR = src
-
-DIRLIST += $(ODIR) $(BDIR) $(IDIR) $(SDIR)
-
-CSUFFIX=.c
-
-BINC=$(CC)
-BINSUFFIX=$(CSUFFIX)
-BINFLAGS=$(CFLAGS)
-
-OFLAG=$(OFLAG_DEBUG)
-#specific flags
-CFLAGS=$(CFLAGS_DEBUG)
-
-#working directory
-MAINDIR:=$(shell dirname $(realpath $(lastword $(MAKEFILE_LIST))))
-
-_OBJ = $(patsubst %.o,%$(CSUFFIX).o,$(_COBJ))
-
-DEPS = $(patsubst %,$(IDIR)/%,$(_DEPS))
-OBJ = $(patsubst %,$(ODIR)/%,$(_OBJ))
-
-#build
-BIN = $(patsubst %,$(BDIR)/%,$(_BIN))
-
-##########################################################################
-# Do not change anything below here (unless you know what you're doing) #
-##########################################################################
-
-.PRECIOUS: $(ODIR)/%$(CSUFFIX).o\
-
-.PHONY: all
-all: $(BIN)
-
-#prog
-$(ODIR)/%$(CSUFFIX).o: $(SDIR)/%$(CSUFFIX) $(DEPS) $(CLASS)
- $(CC) -c -o $@ $< $(FLAGS_BASE) $(OFLAG) $(CFLAGS)
-
-$(BDIR)/%: $(OBJ) $(ODIR)/%$(BINSUFFIX).o
- $(BINC) $^ $(FLAGS_BASE) $(OFLAG) $(LDFLAGS) $(BINFLAGS) -o $@
-
-#clean up
-CLEAN_CMD = rm -f *~;
-RESET_CMD =
-CLEAN_CMD += rm -f $(ODIR)/* $(IDIR)/*~ $(SDIR)/*~;
-RESET_CMD += rm -f $(BDIR)/*;
-
-.PHONY: clean reset dir
-clean:
- $(CLEAN_CMD)
-
-reset: clean
- $(RESET_CMD)
-
-dir:
- mkdir -p $(DIRLIST)
-
-#force specific flags
-.PHONY: debug final install uninstall link
-debug: dir reset
- make all CFLAGS="$(CFLAGS_DEBUG)" OFLAG="$(OFLAG_DEBUG)"
-
-final: dir reset
- make all CFLAGS="$(CFLAGS_FINAL)" OFLAG="$(OFLAG_FINAL)"
-
-#install and make links in default bin directory
-link: uninstall
- ln -s $(MAINDIR)/bin/* $(INSTALLDIR)/
-
-install: final uninstall
- cp $(MAINDIR)/bin/* $(INSTALLDIR)/
-
-uninstall:
- cd $(INSTALLDIR)/ && rm -f $(_BIN);
- cd $(MAINDIR);
diff --git a/Makefile.am b/Makefile.am
new file mode 100644
index 0000000..0eeabfc
--- /dev/null
+++ b/Makefile.am
@@ -0,0 +1,80 @@
+SUFFIXES = .c .h
+
+WARN_FLAGS = -Wall -Wextra -pedantic $(WARN_EXTRA)
+L_FLAGS = -lm
+
+AM_CFLAGS = $(WARN_FLAGS) -std=c99
+LDADD = $(L_FLAGS)
+
+bin_PROGRAMS = bin/generateTMDSuperCell
+bin_generateTMDSuperCell_SOURCES = src/generateTMDSuperCell.c src/tmd_functions.c src/printing.c\
+ src/fractional.c src/atomic_sites.c src/structure.c\
+ src/testing.c src/elements.h src/header.h
+
+
+debug:
+ make clean; make "CFLAGS=$(AM_CFLAGS) $(ERROR_FLAG) $(O_FLAG_0)";
+
+optim:
+ make clean; make "CFLAGS=$(AM_CFLAGS) $(O_FLAG_3)";
+
+.PHONY : debug optim
+
+#extra flags
+
+O_FLAG_0 = -g3 -pg -O0
+O_FLAG_1 = -g1 -pg -O1
+O_FLAG_2 = -O2
+O_FLAG_3 = -O3
+
+WARN_EXTRA = \
+-Wfloat-equal\
+-Wunused\
+-Wunknown-pragmas\
+-Wwrite-strings\
+-Winit-self\
+-Wcast-align\
+-Wcast-qual\
+-Wpointer-arith\
+-Wstrict-aliasing\
+-Wmissing-declarations\
+-Wmissing-include-dirs\
+-Wno-unused-parameter\
+-Wuninitialized\
+-Wcast-align\
+-Wcast-qual\
+-Wdisabled-optimization\
+-Wformat=2\
+-Wredundant-decls\
+-Wshadow\
+-Wstrict-overflow=4\
+-Wswitch-default\
+-Wundef\
+-Wno-unused\
+-Wsign-conversion\
+-Wmissing-format-attribute\
+-Wtype-limits\
+-Wconversion\
+-Wsign-compare\
+-Wmissing-field-initializers\
+-Wno-multichar\
+-Winline\
+$(GCC_WARN_EXTRA)
+
+GCC_WARN_EXTRA=\
+-Wsuggest-attribute=pure\
+-Wsuggest-attribute=const\
+-Wsuggest-attribute=noreturn\
+-Wlogical-op
+
+GCC_NEW_WARN_EXTRA=\
+-Wmaybe-uninitialized\
+-Wsuggest-attribute=format\
+-Wnarrowing
+
+ERROR_FLAG=\
+-Werror\
+-Wno-error=unused-parameter\
+-Wno-error=unused-variable\
+-Wno-error=pedantic
+
diff --git a/NEWS b/NEWS
new file mode 100644
index 0000000..e69de29
diff --git a/README.md b/README.md
index 0af354c..ba19d01 100644
--- a/README.md
+++ b/README.md
@@ -12,29 +12,21 @@ Department of Physics and Astronomy
Try the following:
-+ change INSTALLDIR (typically a folder in PATH like /usr/local/bin)
- - this is defined in makefile.include or can be passed through make
++ `./configure`
++ `make`
+ `make install`
- - this will run `make reset`, `make all`, and then install the binary files in
- the INSTALLDIR
Other options:
-+ `make dir`
- - run this or manually make the necessary directories (./bin and ./obj)
-+ `make final`
- - final binary files will be in ./bin
-+ `make link`
- - will create symbolic links in INSTALLDIR for the binary files
-+ `make all`
- - will make binary files using the debug optimization options (for distributed
- versions there is a chance that `make all` runs `make final` and `make debug`
- runs this case)
++ `make debug`
+ - runs make with '-O0' optimization flag and '-pg -g3' debug flags
++ `make optim`
+ - runs make with '-O3' optimization flag
+ `make uninstall`
- - removes binary files from INSTALLDIR (whether linked or copied)
+ - removes binary files from install directory
You may need to run any of the above as root depending on local folder
-privileges.
+privileges. Additonally, see `./configure --help` for more options.
## Information
@@ -54,57 +46,50 @@ Use of this program involves calling the binary and giving it all the arguments
necessary for output. The order and style of inputs is given in the help for the
program (just call the binary without any arguments). They are also given below:
-All options below must be specified in the following order:
-
- 1. Lattice parameter a (in Angstroms)
- 2. Lattice parameter c (in Angstroms)
- 3. Super cell length a'
- 4. Super cell length a''
- 5. Super cell length b'
- 6. Super cell length b''
- 7. Layers (Bulk = 0, Monolayer = 1)
- 8. 1T (T) or 2H (F)
- 9. Randomize coordinates (T/F)
- 10. Element M (use atomic number)
- 11. Element X (use atomic number)
-
-The following options are optional and can be given after the options above:
-
- 12. Logical for Strain (T/F)
- 13. Strain a axis (T/F)
- 14. Strain b axis (T/F)
- 15. Strain c axis (T/F)
+All of the options in the first section below must be specified in the following
+order:
+
+ 1. Lattice parameter a (in Angstroms)
+ 2. Lattice parameter c (in Angstroms)
+ 3. Super cell length a'
+ 4. Super cell length a''
+ 5. Super cell length b'
+ 6. Super cell length b''
+ 7. Layers (Bulk = 0, Monolayer = 1)
+ 8. 1T (T) or 2H (F)
+ 9. Randomize coordinates (T/F)
+ 10. Element M (use atomic number)
+ 11. Element X (use atomic number)
+
+The following options are not required but allow generation of additional unit
+cells with strain added along different axes:
+
+ 12. Logical for Strain (T/F)
+ 13. Strain a axis (T/F)
+ 14. Strain b axis (T/F)
+ 15. Strain c axis (T/F)
In addition to those options above, the following two options can be added after
-to specify the amount of strain:
-
- 16. Minimum strain (%)
- 17. Maximum strain (%)
+to specify the amount of strain:
+
+ 16. Minimum strain (%)
+ 17. Maximum strain (%)
The a', a'', b', and b'' parameters are the two-vectors that specify the
super-cell size. These describe how the super-cell is constructed in terms of
the original a and b lattice parameters (where b is at 120 degrees to a for the
hexagonal primitive cell). This allows for not only typical super cells. For
example a 3x3 super cell would be (3,0) x (0,3). More complex cells like the
-Star of David distortion in TaS2 are also possible where the \sqrt(13)x\sqrt(13)
+Star of David distortion in TaS2 are also possible where the $\sqrt{13}x\sqrt{13}$
cell is given by (4,1) x (-1,3) which results in the proper angle between the
super cell and the primitive cell.
-### Bugs
-Please report bugs to me (`mill2723 at msu dot edu`) with the subject "TMD CDW
-Coordinate Generator - Bug" and a description of the relevant information about
-how to replicate the bug. Please include: the program being run, version
-information, an attached input and output file (if possible), the results of
-stdout and stderr, and a description of what you expected.
-
-I will try to take a look at it as soon as possible and get back to you with a
-fix or a patch.
### Compiling and Installing
This program was designed to be compiled with the GNU C Compiler (gcc) and GNU
-Make. It can also use the clang processor. It also uses some simple bash
+Make. Additionally It can also use the clang processor. It also uses some simple bash
commands. It *should* work on any Linux/UNIX system that can meet these
requirements but I can offer no guarantees. I suspect (but have not tested) that
this could be compiled on Cygwin or any other system with a C compiler if one so
@@ -115,64 +100,78 @@ and ./inc).
Currently I have used this on Ubuntu 16.04, and CentOS 6.6.
-Dependencies:
+Dependencies (with earliest tested version):
-+ GNU gcc 4.4.7 **or** Clang 3.5.2
-+ GNU Make 3.81 (again, this is what I have run it with but I suspect it would
-work with an earlier version)
-+ GNU bash 4.1.2 (same as above)
++ GNU gcc 4.6.4
++ GNU Make 4.1
++ GNU bash 4.1.2
++ GNU automake 1.15
++ GNU autoconf 2.69
-Also, this does compile with the C90 ISO standards. This includes using the gcc
-`-ansi` option. If you wish to compile without this dependency there should be
+Also, this does compile with the C99 ISO standards. This includes using the gcc
+`-std=c99` option. If you wish to compile without this dependency there should be
no problems. This is mostly to ensure better portability. Additionally, one may
-wish to remove the `WARN_FLAG` variable from the makefile or at least turnoff
-`-Werror`.
+wish to remove the `WARN_FLAG` variable from the makefile.
Also, the code was written on an x64 system but there shouldn't be many
dependencies if any. If you do compile and run this code on a widely different
system (or perhaps just a very popular system) than what has been described
please let me know so I can add it to this document.
-To install:
+It should be possible to compile this code with older version of gcc or with
+Clang by removing certain warning flags.
-(a) Modify the makefile.include file to match your desired settings. This may
-include changing the compiler, flags, install directory, or programs to be
-compiled. Again, I can make no guareentees about the operation of the program
-without using the default settings on a system that it has been tested on.
+To install:
+(a) Run `./configure` with any additonal options (see `./configure --help` for
+details). Use `--prefix=/path/to/install/root` to change the root directory for
+the install. By default `make install` will install the binary file to
+'/usr/local/bin'.
(b) Run `make`
-
(c) Assuming everything went smoothly run `make install` (you may need to run
-this as root or use sudo depending on the installation directory). I was also
-verify that there is nothing in the install directory with an identical name to
-one of the binaries being added. The makefile *will* overwrite it.
+this as root or use sudo depending on the installation directory).
- To uninstall simply run `make uninstall`
-- The install script only makes a link from the binary directory to the bin/
- directory for the local compilation. Thus, if you recompile, there is no need
- to re-install. If you would rather the binary files are copied, use `make
- final`
-Other: `make clean` will delete any extraneous files and `make reset` will
-delete all built files including the binary files.
+Other: `make mostlyclean` will delete any extraneous files while `make clean`
+will remove all files generated by `make`
### Git repository
This code is available at:
[repository](https://github.com/david-c-miller/cdw-unit-cell-generator)
-For update to date releases see:
+For releases see:
[releases](https://github.com/david-c-miller/cdw-unit-cell-generator/releases)
For other information go to:
[cdw-unit-cell-generator](https://david-c-miller.github.io/cdw-unit-cell-generator/)
+### Bug Reports
+
+Please reports all bugs in the GitHub
+[Issues](https://github.com/david-c-miller/cdw-unit-cell-generator/issues)
+section. This way others can view the bugs. If there is no response there you
+can try sending me an email with the subject "Bug - CDW Unit Cell Generator"
+along with a thorough description of the bug. Please include the following:
++ output files
++ full printout of stdout and stderr
++ version
++ any other potentially useful information
++ description of what you expected and what went wrong
+
+I will try to take a look at it as soon as possible and get back to you with a
+fix or a patch.
+
### Disclaimer
I wrote this to be a useful program for computational work done with VASP. There
are other tools out there as well and I cannot promise compatability with them
or that my code will produce identical results. Please verify the results and
-output on your own.
+output on your own. Additionally, this project is partially done in my free time
+so I make no guarantees about the time line for fixes or additional
+features. Likely the best way to fix something is to modify the code yourself
+and make a pull request.
### License
diff --git a/_config.yml b/_config.yml
deleted file mode 100644
index c741881..0000000
--- a/_config.yml
+++ /dev/null
@@ -1 +0,0 @@
-theme: jekyll-theme-slate
\ No newline at end of file
diff --git a/autogen.sh b/autogen.sh
new file mode 100755
index 0000000..6ae0d58
--- /dev/null
+++ b/autogen.sh
@@ -0,0 +1,6 @@
+#!/bin/sh
+
+aclocal
+autoconf
+automake -a
+./configure
diff --git a/configure.ac b/configure.ac
new file mode 100644
index 0000000..b01cad4
--- /dev/null
+++ b/configure.ac
@@ -0,0 +1,12 @@
+AC_INIT(
+ [TMD Unit Cell Generator],
+ [0.3.0],
+ [https://github.com/david-c-miller/cdw-unit-cell-generator/issues],
+ [generateTMDSuperCell],
+ [https://github.com/david-c-miller/cdw-unit-cell-generator])
+
+AM_INIT_AUTOMAKE([subdir-objects foreign])
+AC_PROG_CC
+AC_PROG_INSTALL
+AC_CONFIG_FILES([Makefile])
+AC_OUTPUT
diff --git a/makefile.include b/makefile.include
deleted file mode 100644
index 006ed04..0000000
--- a/makefile.include
+++ /dev/null
@@ -1,105 +0,0 @@
-#!/usr/bin/make
-
-# Copyright (C) 2016-2017 David C. Miller
-
-# This file is part of TMD CDW Unit Cell Generator
-
-# TMD CDW Unit Cell Generatort is free software: you can redistribute it
-# and/or modify it under the terms of the GNU Lesser General Public
-# License as published by the Free Software Foundation, either version
-# 3 of the License, or (at your option) any later version.
-
-# TMD CDW Unit Cell Generator is distributed in the hope that it will be
-# useful, but WITHOUT ANY WARRANTY; without even the implied warranty
-# of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU Lesser General Public License for more details.
-
-# You should have received a copy of the GNU Lesser General Public
-# License along with TMD CDW Unit Cell Generator. If not, see
-# .
-
-#makefile include file
-#this file should be edited for an indivdiual system
-
-######################
-# Compilers #
-######################
-#change these to match your system settings
-CC=gcc
-#CC=clang
-
-#general flags for all compilers
-#debug flags are used by default
-#use make final to use the final flags
-FLAGS_BASE=-I$(IDIR) -I$(SDIR) -Wall -Wextra -pedantic\
- -Werror -Wno-error=unused-parameter -Wno-error=unused-variable\
- -Wno-error=pedantic
-#-ansi
-OFLAG_DEBUG=-O0 -g3 -pg $(WARN_FLAG)
-#-fpack-struct=4
-OFLAG_FINAL=-O3 $(WARN_FLAG) -Wno-error=strict-overflow
-WARN_FLAG=\
--Wfloat-equal\
--Wnarrowing\
--Wunused\
--Wunknown-pragmas\
--Wwrite-strings\
--Winit-self\
--Wcast-align\
--Wcast-qual\
--Wpointer-arith\
--Wstrict-aliasing\
--Wmissing-declarations\
--Wmissing-include-dirs\
--Wno-unused-parameter\
--Wuninitialized\
--Wcast-align\
--Wcast-qual\
--Wdisabled-optimization\
--Wformat=2\
--Wredundant-decls\
--Wshadow\
--Wstrict-overflow=4\
--Wswitch-default\
--Wundef\
--Wno-unused\
--Wsign-conversion\
--Wmissing-format-attribute\
--Wtype-limits\
--Wconversion\
--Wsign-compare\
--Wmissing-field-initializers\
--Wno-multichar\
--Winline\
-$(GCC_FLAGS)
-
-GCC_FLAGS=\
--Wsuggest-attribute=pure\
--Wsuggest-attribute=const\
--Wsuggest-attribute=noreturn\
--Wsuggest-attribute=format\
--Wmaybe-uninitialized\
--Wlogical-op\
-
-#library include flags
-LDFLAGS= -lm
-
-CFLAGS_BASE=-std=c90
-CFLAGS_DEBUG=$(CFLAGS_BASE)
-CFLAGS_FINAL=$(CFLAGS_BASE)
-
-########################################################
-# The following is defined on a project specific basis #
-########################################################
-#these definitions should NOT contain file suffix
-_BIN = generateTMDSuperCell
-
-#all future definitions SHOULD include file suffix
-#header files and object files
-_DEPS = elements.h header.h
-
-#object (.o) files to be built
-_COBJ = tmd_functions.o printing.o fractional.o atomic_sites.o structure.o testing.o
-
-#change to the local of desired installation (default is /usr/local/bin)
-INSTALLDIR:=/mnt/home/mill2723/local/bin
diff --git a/script-test-output.sh b/script-test-output.sh
deleted file mode 100755
index edd0e62..0000000
--- a/script-test-output.sh
+++ /dev/null
@@ -1,9 +0,0 @@
-#!/bin/bash
-
-cd test-output
-../bin/generateTMDSuperCell -t
-
-# check with diff if the test files generated are the same
-# as the provided and verified files
-
-# need to make the verified files
diff --git a/src/atomic_sites.c b/src/atomic_sites.c
index 106b885..8d6f137 100644
--- a/src/atomic_sites.c
+++ b/src/atomic_sites.c
@@ -55,7 +55,9 @@ void make_m_site\
/* used for randomization of coordinates */
double r1 = 0, r2 = 0;
/* scale of randomization (default is 3%) */
- double scale = orig_lattice[0] * 0.03;
+ double min_scale = orig_lattice[0] * 0.01;
+ double max_scale = orig_lattice[0] * 0.04;
+ int sign = 1;
unsigned ii;
@@ -72,11 +74,19 @@ void make_m_site\
if (randomize)
{
/*
- generates are random double between -1.0 and 1.0 and scales it
- using the scale variable (default 3%
+ generates a random value in [-b,-a] U [a,b] where a is a
+ minimum scaling and b is a maximum scaling
*/
- r1 = (((1.0*rand()/RAND_MAX)*2.0)-1.0)*scale;
- r2 = (((1.0*rand()/RAND_MAX)*2.0)-1.0)*scale;
+
+ /* first we get a value between min_scale and max_scale */
+ r1 = ( (1.0*rand()/RAND_MAX)*(max_scale-min_scale) ) + min_scale;
+ r2 = ( (1.0*rand()/RAND_MAX)*(max_scale-min_scale) ) + min_scale;
+
+ /* gets a random value of either -1 or 1 to switch r1 and r2 */
+ sign = get_sign(((1.0*rand()/RAND_MAX)-0.5));
+ r1 = r1*sign;
+ sign = get_sign(((1.0*rand()/RAND_MAX)-0.5));
+ r2 = r2*sign;
}
/*
diff --git a/inc/elements.h b/src/elements.h
similarity index 100%
rename from inc/elements.h
rename to src/elements.h
diff --git a/inc/header.h b/src/header.h
similarity index 98%
rename from inc/header.h
rename to src/header.h
index fa6b767..51830f0 100644
--- a/inc/header.h
+++ b/src/header.h
@@ -95,6 +95,8 @@ double get_lattice_vector_angle(const int a, const int b);
double dtor(double deg) __attribute__ ((const));
int atob(char a) __attribute__ ((pure));
+int get_sign(const double value) __attribute__((const));
+
/* test suite related functions */
void test_print_vasp_monolayer();
void test_print_vasp_bulk();
diff --git a/src/printing.c b/src/printing.c
index e6e92b7..bc22d72 100644
--- a/src/printing.c
+++ b/src/printing.c
@@ -27,33 +27,46 @@
as well as the help printed to terminal.
***********************************************************************/
-/* VERSION DO NOT EDIT */
+/* DO NOT EDIT */
+/* VERSION */
#ifndef VERSION
-#define VERSION "0.0.0-error"
+#define VERSION "version-error"
#endif
-/* VERSION DO NOT EDIT */
+/* PACKAGE NAME */
+#ifndef PACKAGE_NAME
+#define PACKAGE_NAME "TMD Unit Cell Generator"
+#endif
+/* URL */
+#ifndef PACKAGE_URL
+#define PACKAGE_URL "https://github.com/david-c-miller/cdw-unit-cell-generator"
+#endif
+/* BUG REPORT */
+#ifndef PACKAGE_BUGREPORT
+#define PACKAGE_BUGREPORT "https://github.com/david-c-miller/cdw-unit-cell-generator/issues"
+#endif
+/* DO NOT EDIT */
#include "header.h"
void print_xyz(Location loc_m[], Location loc_x[], unsigned n)
{
unsigned j;
- fprintf(stdout,"%d\n",3*n);
- fprintf(stdout,"c-cdw-TaS2 super cell SQRT(13)xSQRT(13)x1 (in angstroms)\n");
+ fprintf(stdout,"%d\n",3*n);
+ fprintf(stdout,"c-cdw-TaS2 super cell SQRT(13)xSQRT(13)x1 (in angstroms)\n");
for (j = 0; j < n; j++)
{
- fprintf(stdout,"Ta %.4f %.4f %.4f\n",\
- loc_m[j].x, loc_m[j].y,loc_m[j].z);
- fprintf(stdout,"S %.4f %.4f %.4f\n",\
- loc_x[j].x, loc_x[j].y,loc_x[j].z);
- fprintf(stdout,"S %.4f %.4f %.4f\n",\
- loc_x[j+n].x, loc_x[j+n].y,loc_x[j+n].z);
+ fprintf(stdout,"Ta %.4f %.4f %.4f\n",\
+ loc_m[j].x, loc_m[j].y,loc_m[j].z);
+ fprintf(stdout,"S %.4f %.4f %.4f\n",\
+ loc_x[j].x, loc_x[j].y,loc_x[j].z);
+ fprintf(stdout,"S %.4f %.4f %.4f\n",\
+ loc_x[j+n].x, loc_x[j+n].y,loc_x[j+n].z);
}
}
void print_vasp_to_file(Location loc_m[], Location loc_x[], unsigned n,\
- double lattice[3][3], char * name, char * elemM,\
- char * elemX, char * file_name)
+ double lattice[3][3], char * name, char * elemM,\
+ char * elemX, char * file_name)
{
FILE * fp;
unsigned i;
@@ -65,7 +78,7 @@ void print_vasp_to_file(Location loc_m[], Location loc_x[], unsigned n,\
for (i = 0; i < 3; i++)
fprintf(fp," %.9f %.9f %.9f\n", \
- lattice[i][0], lattice[i][1], lattice[i][2]);
+ lattice[i][0], lattice[i][1], lattice[i][2]);
/* print Element types and number of each element */
fprintf(fp," %s %s\n",elemM,elemX);
@@ -86,50 +99,52 @@ void print_help()
{
print_version();
- fprintf(stdout,"Used to generate various sized unit cells for\n");
- fprintf(stdout,"1T and 2H trilayers of transition metal \n");
- fprintf(stdout,"dichalcogenides (TMD) with the MX2 structure.\n");
- fprintf(stdout,"\n");
-
- fprintf(stdout,"All options below must be specified in the\n");
- fprintf(stdout,"following order:\n");
- fprintf(stdout,"\t(1) Lattice parameter a\n");
- fprintf(stdout,"\t(2) Lattice parameter c\n");
- fprintf(stdout,"\t(3) Super cell length a\'\n");
- fprintf(stdout,"\t(4) Super cell length a\'\'\n");
- fprintf(stdout,"\t(5) Super cell length b\'\n");
- fprintf(stdout,"\t(6) Super cell length b\'\'\n");
- fprintf(stdout,"\t(7) Layers (0 for Bulk)\n");
- fprintf(stdout,"\t(8) 1T (T) or 2H (F)\n");
- fprintf(stdout,"\t(9) Randomize coordinates (T/F)\n");
- fprintf(stdout,"\t(10) Element M (use atomic number)\n");
- fprintf(stdout,"\t(11) Element X (use atomic number)\n");
-
- fprintf(stdout,"\n");
- fprintf(stdout,"The following options are optional, however\n");
- fprintf(stdout,"12-15 must be specified together and 16-17\n");
- fprintf(stdout,"must be specified together:\n");
- fprintf(stdout,"\t(12) Logical for Strain (T/F)\n");
- fprintf(stdout,"\t(13) Strain a axis (T/F)\n");
- fprintf(stdout,"\t(14) Strain b axis (T/F)\n");
- fprintf(stdout,"\t(15) Strain c axis (T/F)\n");
- fprintf(stdout,"\t(16) Minimum strain (%%)\n");
- fprintf(stdout,"\t(17) Maximum strain (%%)\n");
- fprintf(stdout,"\n");
+ fprintf(stdout,"Used to generate various sized unit cells for\n");
+ fprintf(stdout,"1T and 2H trilayers of transition metal \n");
+ fprintf(stdout,"dichalcogenides (TMD) with the MX2 structure.\n");
+ fprintf(stdout,"\n");
+
+ fprintf(stdout,"All options below must be specified in the\n");
+ fprintf(stdout,"following order:\n");
+ fprintf(stdout,"\t(1) Lattice parameter a\n");
+ fprintf(stdout,"\t(2) Lattice parameter c\n");
+ fprintf(stdout,"\t(3) Super cell length a\'\n");
+ fprintf(stdout,"\t(4) Super cell length a\'\'\n");
+ fprintf(stdout,"\t(5) Super cell length b\'\n");
+ fprintf(stdout,"\t(6) Super cell length b\'\'\n");
+ fprintf(stdout,"\t(7) Layers (0 for Bulk)\n");
+ fprintf(stdout,"\t(8) 1T (T) or 2H (F)\n");
+ fprintf(stdout,"\t(9) Randomize coordinates (T/F)\n");
+ fprintf(stdout,"\t(10) Element M (use atomic number)\n");
+ fprintf(stdout,"\t(11) Element X (use atomic number)\n");
+
+ fprintf(stdout,"\n");
+ fprintf(stdout,"The following options are optional, however\n");
+ fprintf(stdout,"12-15 must be specified together and 16-17\n");
+ fprintf(stdout,"must be specified together:\n");
+ fprintf(stdout,"\t(12) Logical for Strain (T/F)\n");
+ fprintf(stdout,"\t(13) Strain a axis (T/F)\n");
+ fprintf(stdout,"\t(14) Strain b axis (T/F)\n");
+ fprintf(stdout,"\t(15) Strain c axis (T/F)\n");
+ fprintf(stdout,"\t(16) Minimum strain (%%)\n");
+ fprintf(stdout,"\t(17) Maximum strain (%%)\n");
+ fprintf(stdout,"\n");
}
void print_version()
{
- fprintf(stdout,"TMD CDW Unit Cell Generator %s\n",VERSION);
- fprintf(stdout,"Copyright (C) 2016-2017 David C. Miller\n");
- fprintf(stdout,"\n");
- fprintf(stdout,"Code written by David C. Miller (mill2723 at msu dot edu)\n");
- fprintf(stdout,"\n");
- fprintf(stdout,"This code is licensed under the GNU LGPL License\n");
- fprintf(stdout,"For details see \n");
- fprintf(stdout,"There is NO warranty; not even for MERCHANTABILITY or\n");
- fprintf(stdout,"FITNESS FOR A PARTICULAR PURPOSE.\n");
- fprintf(stdout,"\n");
+ fprintf(stdout,"%s %s\n",PACKAGE_NAME, VERSION);
+ fprintf(stdout,"Copyright (C) 2016-2017 David C. Miller\n");
+ fprintf(stdout,"\n");
+ fprintf(stdout,"Code written by David C. Miller (mill2723 at msu dot edu)\n");
+ fprintf(stdout,"Available at: <%s>\n",PACKAGE_URL);
+ fprintf(stdout,"Send bug reports to: <%s>\n",PACKAGE_BUGREPORT);
+ fprintf(stdout,"\n");
+ fprintf(stdout,"This code is licensed under the GNU LGPL License\n");
+ fprintf(stdout,"For details see \n");
+ fprintf(stdout,"There is NO warranty; not even for MERCHANTABILITY or\n");
+ fprintf(stdout,"FITNESS FOR A PARTICULAR PURPOSE.\n");
+ fprintf(stdout,"\n");
}
void print_test_start()
@@ -137,18 +152,18 @@ void print_test_start()
print_version();
/*fprintf(stdout,"\n\n"); */
- fprintf(stdout,"---------------------------------------------------\n");
- fprintf(stdout,"Test Suite Output for TMD CDW Unit Cell Generator\n");
- fprintf(stdout,"---------------------------------------------------\n");
- fprintf(stdout,"Test Output Starting...\n");
- fprintf(stdout,"\n");
- fprintf(stdout,"Starting VASP Monolayer Test\n");
+ fprintf(stdout,"---------------------------------------------------\n");
+ fprintf(stdout,"Test Suite Output for %s\n",PACKAGE_NAME);
+ fprintf(stdout,"---------------------------------------------------\n");
+ fprintf(stdout,"Test Output Starting...\n");
+ fprintf(stdout,"\n");
+ fprintf(stdout,"Starting VASP Monolayer Test\n");
test_print_vasp_monolayer();
- fprintf(stdout,"VASP Monolayer Test Output Complete (Comparison Pending...)\n");
+ fprintf(stdout,"VASP Monolayer Test Output Complete (Comparison Pending...)\n");
- fprintf(stdout,"Starting VASP Bulk Test\n");
+ fprintf(stdout,"Starting VASP Bulk Test\n");
test_print_vasp_bulk();
- fprintf(stdout,"VASP Bulk Test Output Complete (Comparison Pending...)\n");
+ fprintf(stdout,"VASP Bulk Test Output Complete (Comparison Pending...)\n");
}
diff --git a/src/tmd_functions.c b/src/tmd_functions.c
index 1facad0..f5f75ca 100644
--- a/src/tmd_functions.c
+++ b/src/tmd_functions.c
@@ -48,3 +48,11 @@ int atob(char a)
else if ( (a == 'f') || (a == 'F') ) return 0;
else exit(-1);
}
+
+int get_sign(const double value)
+{
+ if (value < 0)
+ return -1;
+ else
+ return 1;
+}