Skip to content

Commit

Permalink
Merge pull request #6 from david-c-miller/development
Browse files Browse the repository at this point in the history
Development - Update to Version 0.2.0
  • Loading branch information
David Miller authored Jan 26, 2017
2 parents f920002 + 1dce63d commit a143445
Show file tree
Hide file tree
Showing 12 changed files with 369 additions and 249 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -29,3 +29,4 @@
*.app

bin/*
test-output/*
16 changes: 8 additions & 8 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,14 @@

include makefile.include

#############################################
# VERSION (DO NOT EDIT) #
#############################################
# #
FLAGS_BASE += -DVERSION='"0.2.0"' #
# #
#############################################

#########################
# Local Directories #
#########################
Expand All @@ -45,14 +53,6 @@ BINC=$(CC)
BINSUFFIX=$(CSUFFIX)
BINFLAGS=$(CFLAGS)

####################################
# VERSION (DO NOT EDIT) #
####################################
# #
FLAGS_BASE += -DVERSION='"0.1.0"' #
# #
####################################

OFLAG=$(OFLAG_DEBUG)
#specific flags
CFLAGS=$(CFLAGS_DEBUG)
Expand Down
14 changes: 11 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,15 @@ Department of Physics and Astronomy
## Quick Install:

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
+ `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`
Expand All @@ -31,8 +33,8 @@ Other options:
+ `make uninstall`
- removes binary files from INSTALLDIR (whether linked or copied)

You may need to run any of the above as root depending on
local folder privileges.
You may need to run any of the above as root depending on local folder
privileges.

## Information

Expand Down Expand Up @@ -157,7 +159,13 @@ delete all built files including the binary files.
### Git repository

This code is available at:
https://github.com/david-c-miller/cdw-unit-cell-generator.git
[repository](https://github.com/david-c-miller/cdw-unit-cell-generator)

For update to date 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/)

### Disclaimer

Expand Down
44 changes: 30 additions & 14 deletions inc/header.h
Original file line number Diff line number Diff line change
Expand Up @@ -53,36 +53,52 @@ static const double PI = 3.1415926535;
static const double EPS = 10E-5;

/* make sites */
void make_m_site(Location atoms_m[], unsigned num, double orig_lattice[3],\
int supercell[2][2], int randomize, int inversion, unsigned layers);
void make_x_site(Location atomsX[], unsigned num, double orig_lattice[3],\
int supercell[2][2], int inversion, unsigned layers);
void make_m_site(Location atoms_m[], const unsigned num, double orig_lattice[3],\
int supercell[2][2], const int randomize, const int inversion,\
const unsigned layers);
void make_x_site(Location atomsX[], const unsigned num, double orig_lattice[3],\
int supercell[2][2], const int inversion, const unsigned layers);

/* output */
void print_vasp(Location loc_m[], Location loc_x[], unsigned n,\
double lattice[3][3], char * name, char * elem_m, char * elem_x)\
__attribute((deprecated)); /* this function should not be used anymore */

void print_vasp_to_file(Location loc_m[], Location loc_x[], unsigned n,\
double lattice[3][3], char * name, char * elem_m,\
char * elem_x, char * file_name);

void print_xyz(Location loc_m[], Location loc_x[], unsigned n);
void print_xyz_to_file(Location loc_m[], Location loc_x[], unsigned n,\
char * filename) __attribute__((deprecated));

/* these functions should not be used anymore */
void print_vasp(Location loc_m[], Location loc_x[], unsigned n,\
double lattice[3][3], char * name, char * elem_m, char * elem_x)\
__attribute__((deprecated));
void print_xyz(Location loc_m[], Location loc_x[], unsigned n)\
__attribute__((deprecated));

void print_help();
void print_version();
void print_test_start();

/* fractional coordinate generation */
void generate_frac_coord(double frac_loc[][3], unsigned num,\
int supercell[2][2]);
void generate_frac_coord(double frac_loc[][3], const unsigned num,\
int supercell[2][2]);

/* structure generation functions */
int make_structure(double orig_lattice[3], int supercell[2][2],\
int inversion, int randomize, unsigned layers,\
AtomicSymbol elem_m, AtomicSymbol elem_x, int strained,\
int strain_axis[3], int strain_min, int strain_max);
const int inversion, const int randomize, const unsigned layers, \
const AtomicSymbol elem_m, const AtomicSymbol elem_x,\
const int strained, int strain_axis[3], const int strain_min, \
const int strain_max);

/* additional functions used throughout the code */
double get_lattice_vector_angle(const int a, const int b);

double dtor(double deg) __attribute__ ((const));
int atob(char a) __attribute__ ((pure));

/* test suite related functions */
void test_print_vasp_monolayer();
void test_print_vasp_bulk();
void test_print_xyz_monolayer();
void test_print_xyz_bulk();

#endif
5 changes: 3 additions & 2 deletions makefile.include
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,8 @@ CC=gcc
#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
-Werror -Wno-error=unused-parameter -Wno-error=unused-variable\
-Wno-error=pedantic
#-ansi
OFLAG_DEBUG=-O0 -g3 -pg $(WARN_FLAG)
#-fpack-struct=4
Expand Down Expand Up @@ -98,7 +99,7 @@ _BIN = generateTMDSuperCell
_DEPS = elements.h header.h

#object (.o) files to be built
_COBJ = tmd_functions.o printing.o fractional.o atomic_sites.o structure.o
_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
9 changes: 5 additions & 4 deletions script-test-output.sh
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
#!/bin/bash

cd test-output
../bin/generateTMDSuperCell 10 10 1 0 0 1 0 F F 1 2
../bin/generateTMDSuperCell 10 10 1 0 0 1 1 F F 1 2
../bin/generateTMDSuperCell -t

../bin/generateTMDSuperCell 10 10 1 0 0 1 0 T F 1 2
../bin/generateTMDSuperCell 10 10 1 0 0 1 1 T F 1 2
# check with diff if the test files generated are the same
# as the provided and verified files

# need to make the verified files
89 changes: 45 additions & 44 deletions src/atomic_sites.c
Original file line number Diff line number Diff line change
Expand Up @@ -48,15 +48,16 @@
which holds an x, y, and z coordinate along with the atomic symbol) size num
*/
void make_m_site\
(Location atoms_m[], unsigned num, double orig_lattice[3],\
int supercell[2][2], int randomize, int inversion, unsigned layers)
(Location atoms_m[], const unsigned num, double orig_lattice[3],\
int supercell[2][2], const int randomize, const int inversion,\
const unsigned layers)
{
/* used for randomization of coordinates */
double r1 = 0, r2 = 0;
/* scale of randomization (default is 3%) */
double scale = orig_lattice[0] * 0.03;

unsigned n;
unsigned ii;

/* fractional location of atom within supercell */
double (*frac_loc)[3];
Expand All @@ -66,7 +67,7 @@ void make_m_site\
generate_frac_coord(frac_loc, num, supercell);

srand((unsigned)(time(NULL)));
for (n = 0; n < num; n++)
for (ii = 0; ii < num; ii++)
{
if (randomize)
{
Expand All @@ -86,50 +87,50 @@ void make_m_site\
if (!(inversion) && !(layers == 1))
{
/* itr 0 */
atoms_m[n].x = (frac_loc[n][0] * orig_lattice[0])\
- (frac_loc[n][1]*0.5*orig_lattice[0]) + r1;
atoms_m[ii].x = (frac_loc[ii][0] * orig_lattice[0])\
- (frac_loc[ii][1]*0.5*orig_lattice[0]) + r1;

atoms_m[n].y = (sqrt(3.0)*0.5*frac_loc[n][1] * orig_lattice[1]) +r2;
atoms_m[ii].y = (sqrt(3.0)*0.5*frac_loc[ii][1] * orig_lattice[1]) +r2;

atoms_m[n].z = 0.25 * orig_lattice[2];
atoms_m[ii].z = 0.25 * orig_lattice[2];

/* itr 1 */
atoms_m[n+num].x = (frac_loc[n][0] * orig_lattice[0])\
- (frac_loc[n][1]*0.5*orig_lattice[0]) + r1;
atoms_m[ii+num].x = (frac_loc[ii][0] * orig_lattice[0])\
- (frac_loc[ii][1]*0.5*orig_lattice[0]) + r1;

atoms_m[n+num].y = (sqrt(3.0)*0.5*frac_loc[n][1] * orig_lattice[1]) +r2;
atoms_m[ii+num].y = (sqrt(3.0)*0.5*frac_loc[ii][1] * orig_lattice[1]) +r2;

atoms_m[n+num].z = 0.75 * orig_lattice[2];
atoms_m[ii+num].z = 0.75 * orig_lattice[2];
}
else
{
atoms_m[n].x = (frac_loc[n][0] * orig_lattice[0])\
- (frac_loc[n][1]*0.5*orig_lattice[0]) + r1;
atoms_m[ii].x = (frac_loc[ii][0] * orig_lattice[0])\
- (frac_loc[ii][1]*0.5*orig_lattice[0]) + r1;

atoms_m[n].y = (sqrt(3.0)*0.5*frac_loc[n][1] * orig_lattice[1]) +r2;
atoms_m[ii].y = (sqrt(3.0)*0.5*frac_loc[ii][1] * orig_lattice[1]) +r2;

atoms_m[n].z = 0.5 * orig_lattice[2];
atoms_m[ii].z = 0.5 * orig_lattice[2];
}
}

free (frac_loc);
}/* end of makeMSite(...) */

void make_x_site
(Location atomsX[], unsigned num, double orig_lattice[3],\
int supercell[2][2], int inversion, unsigned layers)
(Location atomsX[], const unsigned num, double orig_lattice[3],\
int supercell[2][2], const int inversion, const unsigned layers)
{
/* correction vector for displacement of X atoms relative to M sites */
double correction[2][2];

unsigned n;
unsigned ii;
/* fractional location of atom within supercell */
double (*frac_loc)[3];

frac_loc = malloc(sizeof(double[3])*num);
generate_frac_coord(frac_loc, num, supercell);

for (n = 0; n < num; n++)
for (ii = 0; ii < num; ii++)
{
/* generates the correction vectors for 1T and 2H phases */
if (inversion)
Expand All @@ -150,54 +151,54 @@ void make_x_site
if (!(inversion) && !(layers == 1))
{
/* itr = 0 */
atomsX[n].x = ((frac_loc[n][0] + correction[0][0]) * orig_lattice[0])\
- ((frac_loc[n][1] + correction[0][1])*0.5*orig_lattice[0]);
atomsX[ii].x = ((frac_loc[ii][0] + correction[0][0]) * orig_lattice[0])\
- ((frac_loc[ii][1] + correction[0][1])*0.5*orig_lattice[0]);

atomsX[n].y = (frac_loc[n][1] + correction[0][1])\
atomsX[ii].y = (frac_loc[ii][1] + correction[0][1])\
*sqrt(3)*0.5*orig_lattice[1];

atomsX[n].z = 0.125 * orig_lattice[2];
atomsX[ii].z = 0.125 * orig_lattice[2];

/* itr = 1 */
atomsX[n+num].x = ((frac_loc[n][0] + correction[1][0]) * orig_lattice[0]) \
- ((frac_loc[n][1] + correction[1][1])*0.5*orig_lattice[0]);
atomsX[ii+num].x = ((frac_loc[ii][0] + correction[1][0]) * orig_lattice[0]) \
- ((frac_loc[ii][1] + correction[1][1])*0.5*orig_lattice[0]);

atomsX[n+num].y = (frac_loc[n][1] + correction[1][1])\
atomsX[ii+num].y = (frac_loc[ii][1] + correction[1][1])\
*sqrt(3)*0.5*orig_lattice[1];

atomsX[n+num].z = 0.375 * orig_lattice[2];
atomsX[ii+num].z = 0.375 * orig_lattice[2];

/* itr = 2 */
atomsX[n+2*num].x = ((frac_loc[n][0] - correction[0][0]) * orig_lattice[0])\
- ((frac_loc[n][1] - correction[0][1])*0.5*orig_lattice[0]);
atomsX[ii+2*num].x = ((frac_loc[ii][0] - correction[0][0]) * orig_lattice[0])\
- ((frac_loc[ii][1] - correction[0][1])*0.5*orig_lattice[0]);

atomsX[n+2*num].y = (frac_loc[n][1] - correction[0][1])\
atomsX[ii+2*num].y = (frac_loc[ii][1] - correction[0][1])\
*sqrt(3)*0.5*orig_lattice[1];

atomsX[n+2*num].z = 0.625 * orig_lattice[2];
atomsX[ii+2*num].z = 0.625 * orig_lattice[2];

/* itr = 3 */
atomsX[n+3*num].x = ((frac_loc[n][0] - correction[1][0]) * orig_lattice[0])\
- ((frac_loc[n][1] - correction[1][1])*0.5*orig_lattice[0]);
atomsX[ii+3*num].x = ((frac_loc[ii][0] - correction[1][0]) * orig_lattice[0])\
- ((frac_loc[ii][1] - correction[1][1])*0.5*orig_lattice[0]);

atomsX[n+3*num].y = (frac_loc[n][1] - correction[1][1])\
atomsX[ii+3*num].y = (frac_loc[ii][1] - correction[1][1])\
*sqrt(3)*0.5*orig_lattice[1];

atomsX[n+3*num].z = 0.875 * orig_lattice[2];
atomsX[ii+3*num].z = 0.875 * orig_lattice[2];
}
else
{
/* itr = 0 */
atomsX[n].x = ((frac_loc[n][0] + correction[0][0]) * orig_lattice[0])\
- ((frac_loc[n][1] + correction[0][1])*0.5*orig_lattice[0]);
atomsX[n].y = (frac_loc[n][1] + correction[0][1]) * sqrt(3)*0.5*orig_lattice[1];
atomsX[n].z = 0.75 * orig_lattice[2];
atomsX[ii].x = ((frac_loc[ii][0] + correction[0][0]) * orig_lattice[0])\
- ((frac_loc[ii][1] + correction[0][1])*0.5*orig_lattice[0]);
atomsX[ii].y = (frac_loc[ii][1] + correction[0][1]) * sqrt(3)*0.5*orig_lattice[1];
atomsX[ii].z = 0.75 * orig_lattice[2];

/* itr = 1 */
atomsX[n+num].x = ((frac_loc[n][0] + correction[1][0]) * orig_lattice[0]) \
- ((frac_loc[n][1] + correction[1][1])*0.5*orig_lattice[0]);
atomsX[n+num].y = (frac_loc[n][1] + correction[1][1]) * sqrt(3)*0.5*orig_lattice[1];
atomsX[n+num].z = 0.25 * orig_lattice[2];
atomsX[ii+num].x = ((frac_loc[ii][0] + correction[1][0]) * orig_lattice[0]) \
- ((frac_loc[ii][1] + correction[1][1])*0.5*orig_lattice[0]);
atomsX[ii+num].y = (frac_loc[ii][1] + correction[1][1]) * sqrt(3)*0.5*orig_lattice[1];
atomsX[ii+num].z = 0.25 * orig_lattice[2];
}

}
Expand Down
2 changes: 1 addition & 1 deletion src/fractional.c
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@
*/

void generate_frac_coord\
(double frac_loc[][3], unsigned num, int supercell[2][2])
(double frac_loc[][3], const unsigned num, int supercell[2][2])
{
unsigned xmax = 0, ymax = 0, count = 0, ix, jy, kk;
double min_angle;
Expand Down
Loading

0 comments on commit a143445

Please sign in to comment.