mirror of
https://github.com/arcan1s/moldyn.git
synced 2025-07-16 07:10:00 +00:00
Edited documentation
This commit is contained in:
@ -1,7 +1,8 @@
|
||||
cmake_minimum_required (VERSION 2.8)
|
||||
|
||||
cmake_policy(SET CMP0011 NEW)
|
||||
cmake_policy(SET CMP0003 OLD)
|
||||
cmake_policy(SET CMP0011 NEW)
|
||||
cmake_policy(SET CMP0015 NEW)
|
||||
|
||||
# set project name
|
||||
set (PROJECT envir)
|
||||
@ -28,4 +29,4 @@ set (LIBRARIES)
|
||||
set (TARGETS "")
|
||||
set (HEADERS "")
|
||||
|
||||
add_subdirectory (src)
|
||||
add_subdirectory (${${PROJECT}_SOURCE_DIR})
|
@ -1,4 +1,4 @@
|
||||
envir - program for search environment for chosen molecule by geometric criterion
|
||||
envir - program that searchs environment for chosen molecule by geometric criterion
|
||||
Version: 1.0.1
|
||||
License: GPL
|
||||
|
||||
|
65
envir/about.dox
Normal file
65
envir/about.dox
Normal file
@ -0,0 +1,65 @@
|
||||
/*!
|
||||
* @mainpage envir
|
||||
* @image latex ./logo.png
|
||||
*
|
||||
* @section intro_sec Introduction
|
||||
*
|
||||
* <b>About this program</b>:
|
||||
* <ul>
|
||||
* <li>Program that searchs environment for chosen molecule by geometric criterion
|
||||
* </ul>
|
||||
*
|
||||
* <b>Developer</b>:
|
||||
* <ul>
|
||||
* <li>Evgeniy Alekseev aka arcanis <pre><esalexeev (at) gmail (dot) com></pre>
|
||||
*</ul>
|
||||
* <b>License</b>:
|
||||
* <ul>
|
||||
* <li>GPL
|
||||
* </ul>
|
||||
*
|
||||
* @section How-To-Use How to use
|
||||
* Usage:
|
||||
* <pre>
|
||||
* envir -i FILENAME -c X,Y,Z -o FILEMANE [ -n NUM_OF_MOLECULE ] [ -r RADIUS ]
|
||||
* [ -l LOGFILE] [ -q ] [ -h ]
|
||||
*
|
||||
* Parametrs:
|
||||
* -i - input file with coordinates
|
||||
* -c - cell size (float), A
|
||||
* -o - output file with coordinates
|
||||
* -n - number of molecule for search (integer). Default is 1
|
||||
* -r - radius of environment (float). Default is 6.0
|
||||
* -l - log enable
|
||||
* -q - quiet enable
|
||||
* -h - show this help and exit
|
||||
* </pre>
|
||||
*
|
||||
* @page Install
|
||||
*
|
||||
* @section Requirements Requirements
|
||||
* The application statgen requires the following external stuff:
|
||||
* - cmake >= 2.8
|
||||
* - gcc >= 4.8
|
||||
*
|
||||
* @section How-To How to install
|
||||
*
|
||||
* @subsection Linux Linux
|
||||
* @code
|
||||
* mkdir build && cd build
|
||||
* cmake -DCMAKE_INSTALL_PREFIX=/usr -DCMAKE_BUILD_TYPE=Release ../
|
||||
* make
|
||||
* make install
|
||||
* @endcode
|
||||
*
|
||||
* @subsection Windows Windows
|
||||
* @code
|
||||
* create project file using 'cmake'
|
||||
* compile project
|
||||
* @endcode
|
||||
* You may also download compiled executable file for Win_x86.
|
||||
*
|
||||
* @page Changelog
|
||||
* V.1.0.1 (2013-07-27)
|
||||
* * initial release
|
||||
*/
|
@ -1,22 +1,32 @@
|
||||
# set directories
|
||||
set (${PROJECT}_BINARY_DIR bin)
|
||||
set (${PROJECT}_SOURCE_DIR src:include)
|
||||
set (${PROJECT}_SOURCE_DIR src)
|
||||
set (${PROJECT}_INCLUDE_DIR include)
|
||||
set (${PROJECT}_LIB_DIR lib)
|
||||
|
||||
set (CMAKE_INCLUDE_PATH ${${PROJECT}_SOURCE_DIR})
|
||||
set (CMAKE_LIBRARY_PATH ${${PROJECT}_LIB_DIR})
|
||||
# include_path
|
||||
include_directories (${${PROJECT}_INCLUDE_DIR}/${PROJECT}
|
||||
${${PROJECT}_SOURCE_DIR})
|
||||
# library path
|
||||
link_directories (${${PROJECT}_LIB_DIR})
|
||||
# executable path
|
||||
set (EXECUTABLE_OUTPUT_PATH ${${PROJECT}_BINARY_DIR})
|
||||
|
||||
# verbose
|
||||
set (CMAKE_VERBOSE_MAKEFILE ON)
|
||||
|
||||
# flags
|
||||
if ( WITH_DEBUG_MODE )
|
||||
ADD_DEFINITIONS ( -DDEBUG_MODE=1 )
|
||||
add_definitions ( -DDEBUG_MODE=1 )
|
||||
endif ()
|
||||
|
||||
if ( CMAKE_COMPILER_IS_GNUCXX )
|
||||
set (ADD_CXX_FLAGS "-Wall")
|
||||
set (CMAKE_CXX_FLAGS "-O0 ${ADD_CXX_FLAGS}")
|
||||
set (CMAKE_CXX_FLAGS_DEBUG "-g -O0")
|
||||
set (CMAKE_CXX_FLAGS_RELEASE "-O3 -DNDEBUG")
|
||||
elseif ( MSVC )
|
||||
set (ADD_CXX_FLAGS "/W4")
|
||||
set (CMAKE_CXX_FLAGS "${ADD_CXX_FLAGS}")
|
||||
else ()
|
||||
message (STATUS "Flags not enabled")
|
||||
message ("Unknown compiler")
|
||||
endif ()
|
1889
envir/envir.doxygen
Normal file
1889
envir/envir.doxygen
Normal file
File diff suppressed because it is too large
Load Diff
BIN
envir/envir.pdf
Normal file
BIN
envir/envir.pdf
Normal file
Binary file not shown.
BIN
envir/logo.png
Executable file
BIN
envir/logo.png
Executable file
Binary file not shown.
After Width: | Height: | Size: 3.4 KiB |
@ -3,59 +3,27 @@ set ("${PROJECT}_VERSION_MINOR" 0)
|
||||
set ("${PROJECT}_VERSION_PATCH" 1)
|
||||
set ("${PROJECT}_VERSION" ${${PROJECT}_VERSION_MAJOR}.${${PROJECT}_VERSION_MINOR}.${${PROJECT}_VERSION_PATCH})
|
||||
|
||||
message (STATUS ${${PROJECT}_VERSION})
|
||||
message (STATUS "${PROJECT}: Version ${${PROJECT}_VERSION}")
|
||||
|
||||
## set files
|
||||
# main files
|
||||
set (MAIN_SOURCES main)
|
||||
# not public srcs
|
||||
set (PRIVATE_CLASSES add_main
|
||||
coords
|
||||
envir_search
|
||||
messages
|
||||
print_struct
|
||||
set_center)
|
||||
# headers only files
|
||||
SET (HEADERS_ONLY)
|
||||
# public srcs
|
||||
set (PUBLIC_CLASSES)
|
||||
# public headers
|
||||
set (PUBLIC_HEADERS)
|
||||
# shared libraries
|
||||
# set files
|
||||
aux_source_directory (. SOURCES)
|
||||
|
||||
# set library
|
||||
if (CMAKE_COMPILER_IS_GNUCXX)
|
||||
set (ADDITIONAL_LIB m)
|
||||
else ()
|
||||
set (ADDITIONAL_LIB)
|
||||
endif()
|
||||
set (SOURCES)
|
||||
|
||||
# append list
|
||||
foreach (class ${PRIVATE_CLASSES})
|
||||
LIST (APPEND SOURCES ${class}.c)
|
||||
LIST (APPEND HEADERS ${class}.h)
|
||||
endforeach ()
|
||||
|
||||
foreach (class ${HEADERS_ONLY})
|
||||
LIST (APPEND HEADERS ${class}.h)
|
||||
endforeach ()
|
||||
|
||||
foreach (class ${PUBLIC_CLASSES})
|
||||
LIST (APPEND SOURCES ${class}.c)
|
||||
LIST (APPEND HEADERS ../include/${PROJECT}/${class}.h)
|
||||
LIST (APPEND PUBLIC_HEADERS ../include/${PROJECT}/${class}.h)
|
||||
endforeach ()
|
||||
|
||||
# message
|
||||
message (STATUS "SOURCES: ${SOURCES}")
|
||||
|
||||
# link libraries and compile
|
||||
add_executable (${PROJECT} ${MAIN_SOURCES} ${SOURCES})
|
||||
add_executable (${PROJECT} ${SOURCES})
|
||||
target_link_libraries (${PROJECT} ${ADDITIONAL_LIB})
|
||||
|
||||
# install properties
|
||||
INSTALL (TARGETS ${PROJECT}
|
||||
DESTINATION bin)
|
||||
INSTALL (TARGETS ${PROJECT} DESTINATION bin)
|
||||
if (ADD_INCLUDE)
|
||||
INSTALL (FILES ${PUBLIC_HEADERS}
|
||||
DESTINATION include/${PROJECT})
|
||||
INSTALL (FILES ${PUBLIC_HEADERS} DESTINATION include/${PROJECT})
|
||||
endif ()
|
@ -1,4 +1,5 @@
|
||||
/* Additional library for main.c (envir)
|
||||
/**
|
||||
* @file
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
@ -6,7 +7,25 @@
|
||||
#include "messages.h"
|
||||
|
||||
|
||||
/**
|
||||
* @fn error_checking
|
||||
*/
|
||||
int error_checking (const float *cell, const char *input, const char *output)
|
||||
/**
|
||||
* @brief function that checks errors in input variables
|
||||
* @code
|
||||
* error_checking (cell, input, output);
|
||||
* @endcode
|
||||
*
|
||||
* @param cell massive of cell size
|
||||
* @param input first trajectory step
|
||||
* @param output last trajectory step
|
||||
*
|
||||
* @return 11 - error in 'cell'
|
||||
* @return 12 - error in 'input'
|
||||
* @return 13 - error in 'output'
|
||||
* @return 0 - exit without errors
|
||||
*/
|
||||
{
|
||||
if ((cell[0] == 0.0) || (cell[1] == 0.0) || (cell[2] == 0.0))
|
||||
return 11;
|
||||
@ -19,8 +38,26 @@ int error_checking (const float *cell, const char *input, const char *output)
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @fn print_message
|
||||
*/
|
||||
int print_message (const int quiet, FILE *std_output, const int log, FILE *f_log,
|
||||
const int mode, const char *str)
|
||||
/**
|
||||
* @brief function that prints message in log and stdout
|
||||
* @code
|
||||
* print_message (quiet, stdout, log, f_log, 0, str);
|
||||
* @endcode
|
||||
*
|
||||
* @param quiet status of quiet-mode
|
||||
* @param std_output stdout
|
||||
* @param log status of log-mode
|
||||
* @param f_log log file
|
||||
* @param mode number of message in "messages.c"
|
||||
* @param str additional text in message
|
||||
*
|
||||
* @return 0 - exit without errors
|
||||
*/
|
||||
{
|
||||
if ((quiet != 1) && (std_output != stderr))
|
||||
message (0, mode, str, std_output);
|
||||
@ -31,8 +68,28 @@ int print_message (const int quiet, FILE *std_output, const int log, FILE *f_log
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @fn set_defaults
|
||||
*/
|
||||
int set_defaults (float *cell, char *input, int *log, int *num_of_mol, char *output,
|
||||
int *quiet, float *rad)
|
||||
/**
|
||||
* @brief function for set default values of variables
|
||||
* @code
|
||||
* set_defaults (cell, &from, input, &log, &max_depth, &num_of_inter, output, &to,
|
||||
* &type_inter, &quiet);
|
||||
* @endcode
|
||||
*
|
||||
* @param cell massive of cell size
|
||||
* @param input mask of trajectory files
|
||||
* @param log status of log-mode
|
||||
* @param num_of_mol number of molecule
|
||||
* @param output output file name
|
||||
* @param quiet status of quiet-mode
|
||||
* @param rad radius of environment sphere
|
||||
*
|
||||
* @return 0 - exit without errors
|
||||
*/
|
||||
{
|
||||
int i;
|
||||
|
||||
|
@ -1,6 +1,20 @@
|
||||
/**
|
||||
* @file
|
||||
*/
|
||||
|
||||
#ifndef ADD_MAIN_H
|
||||
#define ADD_MAIN_H
|
||||
|
||||
/**
|
||||
* @fn error_checking
|
||||
*/
|
||||
/**
|
||||
* @fn print_message
|
||||
*/
|
||||
/**
|
||||
* @fn set_defaults
|
||||
*/
|
||||
|
||||
int error_checking (const float *, const char *, const char *);
|
||||
int print_message (const int, FILE *, const int, FILE *, const int, const char *);
|
||||
int set_defaults (float *, char *, int *, int *, char *, int *, float *);
|
||||
|
@ -1,52 +1,67 @@
|
||||
/* Library for reading coordinates from input file
|
||||
*
|
||||
* Usage:
|
||||
* reading_coords (mode, filename, type_interaction, labels,
|
||||
* cell, &number_of_molecules, &number_of_atoms, true_label_molecule,
|
||||
* label_molecule, type_atoms, coords, char_type_atoms)
|
||||
/**
|
||||
* @file
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
|
||||
/**
|
||||
* @fn reading_coords
|
||||
*/
|
||||
int reading_coords (const int mode, const char *filename, const int type_inter,
|
||||
const int *label_atom, const float *cell, int *num_mol,
|
||||
int *num_atoms, int *true_label_mol, int *label_mol,
|
||||
int *type_atoms, float *coords, char *ch_type_atoms)
|
||||
/* filename - name of file with coordinates
|
||||
* type_inter - type interaction (number of molecules for interaction)
|
||||
* (number of molecules in aglomerate for agl)
|
||||
* label_atom - types of atom for interaction
|
||||
* (molecules in aglomerate for agl)
|
||||
* cell - cell dimension
|
||||
* num_mol - number of molecules for writing coordinates
|
||||
* num_atoms - number of atoms for writing coordinates
|
||||
* true_label_mol - massive of true numbers of molecule for atoms
|
||||
* label_mol - massive of numbers of molecule for atoms
|
||||
* type_atoms - massive of atom types for atoms
|
||||
* coords - massive of coordinates
|
||||
* ch_type_atoms - massive of char types for atoms
|
||||
/**
|
||||
* @brief function that reads coordinates from special file format
|
||||
* @code
|
||||
* reading_coords (0, filename, type_inter, label_atom, cell, &num_mol, &num_atoms,
|
||||
* true_label_mol, label_mol, type_atoms, coords, ch_type_atoms);
|
||||
* @endcode
|
||||
*
|
||||
* @param mode mode of reading; '1' is statgen, '2' is envir or
|
||||
* frad, '3' is agl
|
||||
* @param filename input file name
|
||||
* @param type_inter number of needed atoms
|
||||
* (number of needed molecules)
|
||||
* @param label_atom massive of needed atom types
|
||||
* (massive of needed molecules)
|
||||
* @param cell massive of cell size
|
||||
* @param num_mol number of molecules
|
||||
* @param num_atoms number of atoms
|
||||
* @param true_label_mol massive of true numbers of molecule for atoms
|
||||
* @param label_mol massive of numbers of molecule for atoms
|
||||
* @param type_atoms massive of atom types
|
||||
* @param coords massive of coordinates
|
||||
* @param ch_type_atoms massive of char atom types
|
||||
*
|
||||
* @return 1 - file $filename does not exist
|
||||
* @return 2 - unknown mode
|
||||
* @return 0 - exit without errors
|
||||
*/
|
||||
{
|
||||
char at_symb[32], file_string[256];
|
||||
int atoms, cur_at_num, cur_at_type, cur_mol, i, j, tr_num_atoms, ref_mol, x, y;
|
||||
float cur_coords[3], *not_tr_coords, ref[3];
|
||||
FILE *inp;
|
||||
/* cur_*, at_symb - temp variables
|
||||
* file_string - temp string variable
|
||||
* atoms - total number of atoms in system
|
||||
* tr_num_atoms - number of translated atoms for writing coordinates (m.b. 8*num_atoms)
|
||||
* ref_mol - number of molecule for reference
|
||||
* not_tr_coords - not translated coordinates
|
||||
* ref - coordinates of reference molecule
|
||||
* inp - file with input data
|
||||
|
||||
/* cur_* temp variables
|
||||
* at_symb temp variable
|
||||
* file_string temp string variable
|
||||
* atoms total number of atoms in system
|
||||
* tr_num_atoms number of translated atoms (must be 8*num_atoms)
|
||||
* ref_mol number of molecule for reference in translation
|
||||
* not_tr_coords massive of not translated coordinates
|
||||
* ref massive of coordinates of reference molecule
|
||||
* inp input file
|
||||
*/
|
||||
|
||||
/// <b>Work blocks</b>
|
||||
|
||||
*num_atoms = 0;
|
||||
*num_mol = 0;
|
||||
|
||||
// Reading file
|
||||
/// <pre> reading file </pre>
|
||||
inp = fopen (filename, "r");
|
||||
if (inp == NULL)
|
||||
return 1;
|
||||
@ -61,10 +76,11 @@ int reading_coords (const int mode, const char *filename, const int type_inter,
|
||||
sscanf (file_string, "%i%s%f%f%f%i%i", &cur_at_num, at_symb, &cur_coords[0],
|
||||
&cur_coords[1], &cur_coords[2], &cur_at_type, &cur_mol);
|
||||
|
||||
// reading variables according to selected mode
|
||||
switch (mode)
|
||||
{
|
||||
case 0:
|
||||
// for statgen
|
||||
// mode == 0 (selected atoms)
|
||||
for (j=0; j<type_inter; j++)
|
||||
if (cur_at_type == label_atom[j])
|
||||
{
|
||||
@ -85,7 +101,7 @@ int reading_coords (const int mode, const char *filename, const int type_inter,
|
||||
}
|
||||
break;
|
||||
case 1:
|
||||
// for envir and frad
|
||||
// mode == 1 (all atoms)
|
||||
not_tr_coords[3**num_atoms+0] = cur_coords[0];
|
||||
not_tr_coords[3**num_atoms+1] = cur_coords[1];
|
||||
not_tr_coords[3**num_atoms+2] = cur_coords[2];
|
||||
@ -104,7 +120,7 @@ int reading_coords (const int mode, const char *filename, const int type_inter,
|
||||
*num_atoms = *num_atoms + 1;
|
||||
break;
|
||||
case 2:
|
||||
// for agl
|
||||
// mode == 2 (selected molecules)
|
||||
for (j=0; j<type_inter; j++)
|
||||
if (cur_mol == label_atom[j])
|
||||
{
|
||||
@ -126,18 +142,18 @@ int reading_coords (const int mode, const char *filename, const int type_inter,
|
||||
*num_atoms = *num_atoms + 1;
|
||||
}
|
||||
break;
|
||||
default: return 1;
|
||||
default: return 2;
|
||||
}
|
||||
}
|
||||
fclose (inp);
|
||||
|
||||
// Translation
|
||||
/// <pre> translation </pre>
|
||||
tr_num_atoms = *num_atoms;
|
||||
for (i=0; i<*num_atoms; i++)
|
||||
for (j=0; j<3; j++)
|
||||
coords[3*i+j] = not_tr_coords[3*i+j];
|
||||
|
||||
// Assign initial value to reference coordinates
|
||||
// assign initial value to reference coordinates
|
||||
ref_mol = label_mol[0];
|
||||
for (i=0; i<3; i++)
|
||||
ref[i] = coords[3*0+i];
|
||||
@ -154,7 +170,7 @@ int reading_coords (const int mode, const char *filename, const int type_inter,
|
||||
for (x=0; x<3; x++)
|
||||
{
|
||||
if (ref[x] >= 0.0)
|
||||
// if xyz >= 0.0 A
|
||||
// if xyz >= 0.0 A
|
||||
{
|
||||
for (j=0; j<3; j++)
|
||||
if (j == x)
|
||||
@ -167,7 +183,7 @@ int reading_coords (const int mode, const char *filename, const int type_inter,
|
||||
tr_num_atoms++;
|
||||
}
|
||||
else
|
||||
// if xyz < 0.0 A
|
||||
// if xyz < 0.0 A
|
||||
{
|
||||
for (j=0; j<3; j++)
|
||||
if (j == x)
|
||||
@ -186,7 +202,7 @@ int reading_coords (const int mode, const char *filename, const int type_inter,
|
||||
for (y=x+1; y<3; y++)
|
||||
{
|
||||
if ((ref[x] >= 0.0) && (ref[y] >= 0.0))
|
||||
// if xyz and xyz >= 0.0 A
|
||||
// if xyz and xyz >= 0.0 A
|
||||
{
|
||||
for (j=0; j<3; j++)
|
||||
if ((j == x) || (j == y))
|
||||
@ -200,7 +216,7 @@ int reading_coords (const int mode, const char *filename, const int type_inter,
|
||||
}
|
||||
|
||||
if ((ref[x] < 0.0) && (ref[y] < 0.0))
|
||||
// if xyz and xyz < 0.0 A
|
||||
// if xyz and xyz < 0.0 A
|
||||
{
|
||||
for (j=0; j<3; j++)
|
||||
if ((j == x) || (j == y))
|
||||
@ -216,7 +232,7 @@ int reading_coords (const int mode, const char *filename, const int type_inter,
|
||||
|
||||
for (y=0; y<3; y++)
|
||||
if ((ref[x] < 0.0) && (ref[y] >= 0.0))
|
||||
// if xyz OR xyz >= 0.0
|
||||
// if xyz OR xyz >= 0.0
|
||||
{
|
||||
for (j=0; j<3; j++)
|
||||
{
|
||||
@ -235,7 +251,7 @@ int reading_coords (const int mode, const char *filename, const int type_inter,
|
||||
}
|
||||
|
||||
if ((ref[0] >= 0.0) && (ref[1] >= 0.0) && (ref[2] >= 0.0))
|
||||
// if x and y and z >= 0.0 A
|
||||
// if x and y and z >= 0.0 A
|
||||
{
|
||||
coords[3*tr_num_atoms+0] = not_tr_coords[3*i+0] - cell[0];
|
||||
coords[3*tr_num_atoms+1] = not_tr_coords[3*i+1] - cell[1];
|
||||
@ -247,7 +263,7 @@ int reading_coords (const int mode, const char *filename, const int type_inter,
|
||||
}
|
||||
|
||||
if ((ref[0] >= 0.0) && (ref[1] >= 0.0) && (ref[2] < 0.0))
|
||||
// if x and y >= 0.0 A and z < 0.0 A
|
||||
// if x and y >= 0.0 A and z < 0.0 A
|
||||
{
|
||||
coords[3*tr_num_atoms+0] = not_tr_coords[3*i+0] - cell[0];
|
||||
coords[3*tr_num_atoms+1] = not_tr_coords[3*i+1] - cell[1];
|
||||
@ -259,7 +275,7 @@ int reading_coords (const int mode, const char *filename, const int type_inter,
|
||||
}
|
||||
|
||||
if ((ref[0] >= 0.0) && (ref[1] < 0.0) && (ref[2] >= 0.0))
|
||||
// if x and z >= 0.0 A and y < 0.0 A
|
||||
// if x and z >= 0.0 A and y < 0.0 A
|
||||
{
|
||||
coords[3*tr_num_atoms+0] = not_tr_coords[3*i+0] - cell[0];
|
||||
coords[3*tr_num_atoms+1] = not_tr_coords[3*i+1] + cell[1];
|
||||
@ -271,7 +287,7 @@ int reading_coords (const int mode, const char *filename, const int type_inter,
|
||||
}
|
||||
|
||||
if ((ref[0] < 0.0) && (ref[1] >= 0.0) && (ref[2] >= 0.0))
|
||||
// if y and z >= 0.0 A and x < 0.0 A
|
||||
// if y and z >= 0.0 A and x < 0.0 A
|
||||
{
|
||||
coords[3*tr_num_atoms+0] = not_tr_coords[3*i+0] + cell[0];
|
||||
coords[3*tr_num_atoms+1] = not_tr_coords[3*i+1] - cell[1];
|
||||
@ -283,7 +299,7 @@ int reading_coords (const int mode, const char *filename, const int type_inter,
|
||||
}
|
||||
|
||||
if ((ref[0] < 0.0) && (ref[1] < 0.0) && (ref[2] >= 0.0))
|
||||
// if x and y < 0.0 A and z >= 0.0 A
|
||||
// if x and y < 0.0 A and z >= 0.0 A
|
||||
{
|
||||
coords[3*tr_num_atoms+0] = not_tr_coords[3*i+0] + cell[0];
|
||||
coords[3*tr_num_atoms+1] = not_tr_coords[3*i+1] + cell[1];
|
||||
@ -295,7 +311,7 @@ int reading_coords (const int mode, const char *filename, const int type_inter,
|
||||
}
|
||||
|
||||
if ((ref[0] < 0.0) && (ref[1] >= 0.0) && (ref[2] < 0.0))
|
||||
// if x and z < 0.0 A and y >= 0.0 A
|
||||
// if x and z < 0.0 A and y >= 0.0 A
|
||||
{
|
||||
coords[3*tr_num_atoms+0] = not_tr_coords[3*i+0] + cell[0];
|
||||
coords[3*tr_num_atoms+1] = not_tr_coords[3*i+1] - cell[1];
|
||||
@ -307,7 +323,7 @@ int reading_coords (const int mode, const char *filename, const int type_inter,
|
||||
}
|
||||
|
||||
if ((ref[0] >= 0.0) && (ref[1] < 0.0) && (ref[2] < 0.0))
|
||||
// if x >= 0.0 A and y and z < 0.0 A
|
||||
// if x >= 0.0 A and y and z < 0.0 A
|
||||
{
|
||||
coords[3*tr_num_atoms+0] = not_tr_coords[3*i+0] - cell[0];
|
||||
coords[3*tr_num_atoms+1] = not_tr_coords[3*i+1] + cell[1];
|
||||
@ -319,7 +335,7 @@ int reading_coords (const int mode, const char *filename, const int type_inter,
|
||||
}
|
||||
|
||||
if ((ref[0] < 0.0) && (ref[1] < 0.0) && (ref[2] < 0.0))
|
||||
// if x and y and z < 0.0 A
|
||||
// if x and y and z < 0.0 A
|
||||
{
|
||||
coords[3*tr_num_atoms+0] = not_tr_coords[3*i+0] + cell[0];
|
||||
coords[3*tr_num_atoms+1] = not_tr_coords[3*i+1] + cell[1];
|
||||
@ -331,7 +347,7 @@ int reading_coords (const int mode, const char *filename, const int type_inter,
|
||||
}
|
||||
}
|
||||
|
||||
// free memory
|
||||
/// <pre> free memory </pre>
|
||||
free (not_tr_coords);
|
||||
|
||||
return 0;
|
||||
|
@ -1,6 +1,14 @@
|
||||
/**
|
||||
* @file
|
||||
*/
|
||||
|
||||
#ifndef COORDS_H
|
||||
#define COORDS_H
|
||||
|
||||
/**
|
||||
* @fn reading_coords
|
||||
*/
|
||||
|
||||
int reading_coords (const int, const char *, const int, const int *,
|
||||
const float *, int *, int *, int *, int *, int *, float *,
|
||||
char *);
|
||||
|
@ -1,3 +1,7 @@
|
||||
/**
|
||||
* @file
|
||||
*/
|
||||
|
||||
/* Library for search environment
|
||||
*
|
||||
* Usage:
|
||||
@ -8,19 +12,32 @@
|
||||
#include <math.h>
|
||||
|
||||
|
||||
/**
|
||||
* @fn search_envir
|
||||
*/
|
||||
int search_envir (const int num_of_mol, const int num_mol, const float *centr_coords,
|
||||
const double rad, int *needed_mol, int *num_needed_mol)
|
||||
/* num_of_mol - number of molecule for search
|
||||
* num_mol - number of molecules for writing coordinates
|
||||
* centr_coords - massive of centered coordinates
|
||||
* rad - criterion
|
||||
* needed_mol - massive of needed molecules
|
||||
* num_needed_mol - number of needed molecules
|
||||
/**
|
||||
* @brief function that searchs environment
|
||||
* @code
|
||||
* search_envir (number_of_molecule, num_mol, centr_coords, rad, needed_mol,
|
||||
* &num_needed_mol);
|
||||
* @endcode
|
||||
*
|
||||
* @param num_of_mol number of molecule
|
||||
* @param num_mol number of molecules
|
||||
* @param centr_coords massive of centered coordinates
|
||||
* @param rad radius of environment sphere
|
||||
* @param needed_mol massive of number of needed molecules
|
||||
* @param num_needed_mol number of needed molecules
|
||||
*
|
||||
* @return 0 - exit without errors
|
||||
*/
|
||||
{
|
||||
float r;
|
||||
int i;
|
||||
/* r - radius
|
||||
|
||||
/* r radius
|
||||
*/
|
||||
|
||||
*num_needed_mol = 0;
|
||||
|
@ -1,6 +1,14 @@
|
||||
/**
|
||||
* @file
|
||||
*/
|
||||
|
||||
#ifndef ENVIR_SEARCH_H
|
||||
#define ENVIR_SEARCH_H
|
||||
|
||||
/**
|
||||
* @fn search_envir
|
||||
*/
|
||||
|
||||
int search_envir (const int, const int, const float *, const double, int *, int *);
|
||||
|
||||
#endif /* ENVIR_SEARCH_H */
|
@ -1,3 +1,7 @@
|
||||
/**
|
||||
* @file
|
||||
*/
|
||||
|
||||
#include <math.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
@ -11,7 +15,16 @@
|
||||
#include "set_center.h"
|
||||
|
||||
|
||||
/**
|
||||
* @fn main
|
||||
*/
|
||||
int main(int argc, char *argv[])
|
||||
/**
|
||||
* @return 1 - error in error_checking
|
||||
* @return 2 - input file does not exist
|
||||
* @return 3 - memory error
|
||||
* @return 0 - exit without errors
|
||||
*/
|
||||
{
|
||||
char tmp_str[2048];
|
||||
int error, i, j, *tmp_int;
|
||||
@ -21,25 +34,26 @@ int main(int argc, char *argv[])
|
||||
float cell[3], *centr_coords, *coords, rad;
|
||||
int *label_mol, log, num_atoms, num_mol, num_needed_mol, num_of_mol,
|
||||
*needed_mol, quiet, *true_label_mol;
|
||||
/* ch_type_atoms - massive of char types for atoms
|
||||
* input - input file name
|
||||
* logfile - log file name
|
||||
* output - output file name
|
||||
|
||||
/* ch_type_atoms massive of char atom types
|
||||
* input input file name
|
||||
* logfile log file name
|
||||
* output output file name
|
||||
*
|
||||
* cell - cell dimension
|
||||
* centr_coords - massive of coordinates of center molecules
|
||||
* coords - massive of coordinates
|
||||
* rad - criterion
|
||||
* cell massive of cell size
|
||||
* centr_coords massive of centered coordinates
|
||||
* coords massive of coordinates
|
||||
* rad radius of environment sphere
|
||||
*
|
||||
* label_mol - massive of numbers of molecule for atoms
|
||||
* log - status of log-mode
|
||||
* num_atoms - number of atoms for writing coordinates
|
||||
* num_mol - number of molecules for writing coordinates
|
||||
* num_needed_mol - number of needed molecules
|
||||
* num_of_mol - number of molecule for search
|
||||
* needed_mol - massive of needed molecules
|
||||
* quiet - status of quiet-mode
|
||||
* true_label_mol - massive of true numbers of molecule for atoms
|
||||
* label_mol massive of numbers of molecule for atoms
|
||||
* log status of log-mode
|
||||
* num_atoms number of atoms
|
||||
* num_mol number of molecules
|
||||
* num_needed_mol number of needed molecules
|
||||
* num_of_mol number of molecule
|
||||
* needed_mol massive of number of needed molecules
|
||||
* quiet status of quiet-mode
|
||||
* true_label_mol massive of true numbers of molecule for atoms
|
||||
*/
|
||||
|
||||
set_defaults (cell, input, &log, &num_of_mol, output, &quiet, &rad);
|
||||
@ -68,44 +82,44 @@ int main(int argc, char *argv[])
|
||||
return 0;
|
||||
}
|
||||
else if ((argv[i][0] == '-') && (argv[i][1] == 'i'))
|
||||
// input file
|
||||
// input file
|
||||
{
|
||||
strcpy (input, argv[i+1]);
|
||||
i++;
|
||||
}
|
||||
else if ((argv[i][0] == '-') && (argv[i][1] == 'c'))
|
||||
// cell size
|
||||
// cell size
|
||||
{
|
||||
sscanf (argv[i+1], "%f,%f,%f", &cell[0], &cell[1], &cell[2]);
|
||||
i++;
|
||||
}
|
||||
else if ((argv[i][0] == '-') && (argv[i][1] == 'o'))
|
||||
// output file
|
||||
// output file
|
||||
{
|
||||
strcpy (output, argv[i+1]);
|
||||
i++;
|
||||
}
|
||||
else if ((argv[i][0] == '-') && (argv[i][1] == 'n'))
|
||||
// number of molecule
|
||||
// number of molecule
|
||||
{
|
||||
sscanf (argv[i+1], "%i", &num_of_mol);
|
||||
i++;
|
||||
}
|
||||
else if ((argv[i][0] == '-') && (argv[i][1] == 'r'))
|
||||
// radius of environment
|
||||
// radius of environment
|
||||
{
|
||||
sscanf (argv[i+1], "%f", &rad);
|
||||
i++;
|
||||
}
|
||||
else if ((argv[i][0] == '-') && (argv[i][1] == 'l'))
|
||||
// log mode
|
||||
// log mode
|
||||
{
|
||||
log = 1;
|
||||
strcpy (logfile, argv[i+1]);
|
||||
i++;
|
||||
}
|
||||
else if ((argv[i][0] == '-') && (argv[i][1] == 'q'))
|
||||
// quiet mode
|
||||
// quiet mode
|
||||
{
|
||||
quiet = 1;
|
||||
}
|
||||
@ -127,14 +141,14 @@ int main(int argc, char *argv[])
|
||||
|
||||
print_message (quiet, stdout, log, f_log, 2, argv[0]);
|
||||
|
||||
// processing
|
||||
// initial variables
|
||||
// processing
|
||||
// initial variables
|
||||
print_message (quiet, stdout, log, f_log, 3, input);
|
||||
f_inp = fopen (input, "r");
|
||||
if (f_inp == NULL)
|
||||
{
|
||||
print_message (quiet, stderr, log, f_log, 18, input);
|
||||
return 1;
|
||||
return 2;
|
||||
}
|
||||
fscanf (f_inp, "%i", &num_atoms);
|
||||
fclose (f_inp);
|
||||
@ -143,7 +157,7 @@ int main(int argc, char *argv[])
|
||||
label_mol = (int *) malloc (8 * num_atoms * sizeof (int));
|
||||
tmp_int = (int *) malloc (8 * num_atoms * sizeof (int));
|
||||
true_label_mol = (int *) malloc (num_atoms * sizeof (int));
|
||||
// error checking
|
||||
// error checking
|
||||
if ((ch_type_atoms == NULL) ||
|
||||
(coords == NULL) ||
|
||||
(label_mol == NULL) ||
|
||||
@ -151,7 +165,7 @@ int main(int argc, char *argv[])
|
||||
(true_label_mol == NULL))
|
||||
{
|
||||
print_message (quiet, stderr, log, f_log, 19, argv[0]);
|
||||
return 17;
|
||||
return 3;
|
||||
}
|
||||
sprintf (tmp_str, "%6cInput file: '%s';\n%6cOutput file: '%s';\n%6cLog: %i;\n\
|
||||
%6cQuiet: %i;\n%6cCell size: %.4f, %.4f, %.4f;\n%6cSelect molecule: %i;\n\
|
||||
@ -161,7 +175,7 @@ int main(int argc, char *argv[])
|
||||
|
||||
print_message (quiet, stdout, log, f_log, 6, argv[0]);
|
||||
|
||||
// reading coordinates
|
||||
// reading coordinates
|
||||
print_message (quiet, stdout, log, f_log, 7, input);
|
||||
error = reading_coords (1, input, tmp_int, tmp_int, cell, &num_mol, &num_atoms,
|
||||
true_label_mol, label_mol, tmp_int, coords, ch_type_atoms);
|
||||
@ -173,15 +187,15 @@ int main(int argc, char *argv[])
|
||||
' ', num_mol, ' ', num_atoms);
|
||||
print_message (quiet, stdout, log, f_log, 8, tmp_str);
|
||||
}
|
||||
// error checking
|
||||
// error checking
|
||||
if ((centr_coords == NULL) ||
|
||||
(needed_mol == NULL))
|
||||
{
|
||||
print_message (quiet, stderr, log, f_log, 19, argv[0]);
|
||||
return 17;
|
||||
return 3;
|
||||
}
|
||||
|
||||
// analyze
|
||||
// analyze
|
||||
if (error == 0)
|
||||
{
|
||||
error = set_center (num_atoms, num_mol, label_mol, coords, centr_coords);
|
||||
@ -203,7 +217,7 @@ int main(int argc, char *argv[])
|
||||
print_message (quiet, stdout, log, f_log, 13, argv[0]);
|
||||
|
||||
print_message (quiet, stdout, log, f_log, 15, argv[0]);
|
||||
// free memory
|
||||
// free memory
|
||||
free (ch_type_atoms);
|
||||
free (centr_coords);
|
||||
free (coords);
|
||||
|
@ -1,16 +1,27 @@
|
||||
/* Library for printing messages at output
|
||||
*
|
||||
* Usage:
|
||||
* message (log, mode, text, output)
|
||||
/**
|
||||
* @file
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <time.h>
|
||||
|
||||
|
||||
/**
|
||||
* @fn message
|
||||
*/
|
||||
int message (const int log, const int mode, const char *text, FILE *output)
|
||||
/* mode - number of message
|
||||
* text - additional text
|
||||
/**
|
||||
* @brief function that prints messages to output
|
||||
* @code
|
||||
* message (log, mode, text, output);
|
||||
* @endcode
|
||||
*
|
||||
* @param log equal to 1 if print to logfile
|
||||
* @param mode number of message
|
||||
* @param text additional text
|
||||
* @param output output file (may be stdout)
|
||||
*
|
||||
* @return 0 - exit without errors
|
||||
*/
|
||||
{
|
||||
char out[4096];
|
||||
@ -18,6 +29,7 @@ int message (const int log, const int mode, const char *text, FILE *output)
|
||||
if (log == 1)
|
||||
{
|
||||
char time_str[256];
|
||||
|
||||
time_t t = time (NULL);
|
||||
struct tm* aTm = localtime (&t);
|
||||
sprintf (time_str, "[%04d-%02d-%02d %02d:%02d:%02d] [%2i]: ", aTm->tm_year+1900,
|
||||
|
@ -1,6 +1,14 @@
|
||||
/**
|
||||
* @file
|
||||
*/
|
||||
|
||||
#ifndef MESSAGES_H
|
||||
#define MESSAGES_H
|
||||
|
||||
/**
|
||||
* @fn message
|
||||
*/
|
||||
|
||||
int message (const int, const int, const char *, FILE *);
|
||||
|
||||
#endif /* MESSAGES_H */
|
@ -1,3 +1,7 @@
|
||||
/**
|
||||
* @file
|
||||
*/
|
||||
|
||||
/* Library for printing structure to pdb file
|
||||
*
|
||||
* Usage:
|
||||
@ -8,23 +12,37 @@
|
||||
#include <stdio.h>
|
||||
|
||||
|
||||
/**
|
||||
* @fn print_structure
|
||||
*/
|
||||
int print_structure (const char *output, const int num_needed_mol, const int *needed_mol,
|
||||
const int num_atoms, const int *label_mol, const char *ch_type_atoms,
|
||||
const float *coords)
|
||||
/* output - output file name
|
||||
* num_needed_mol - number of needed molecules
|
||||
* needed_mol - massive of needed molecules
|
||||
* num_atoms - number of atoms
|
||||
* label_mol - massive of numbers of molecule for atoms
|
||||
* ch_type_atoms - massive of char types for atoms
|
||||
* coords - massive of coordinates
|
||||
/**
|
||||
* @brief function that prints structure to pdb file
|
||||
* @code
|
||||
* print_structure (output, num_needed_mol, needed_mol, num_atoms, label_mol,
|
||||
* char_type_atoms, coords);
|
||||
* @endcode
|
||||
*
|
||||
* @param output output file name
|
||||
* @param num_needed_mol number of needed molecules
|
||||
* @param needed_mol massive of number of needed molecules
|
||||
* @param num_atoms number of atoms
|
||||
* @param label_mol massive of numbers of molecule for atoms
|
||||
* @param ch_type_atoms massive of char atom types
|
||||
* @param coords massive of coordinates
|
||||
*
|
||||
* @return 0 - exit without errors
|
||||
*/
|
||||
{
|
||||
int cur_atom, cur_atom_num, cur_mol, i, j;
|
||||
FILE *f_out;
|
||||
/* cur_atom - current atom
|
||||
* cur_atom_num - true atom number
|
||||
* cur_mol - current molecule
|
||||
|
||||
/* cur_atom current atom
|
||||
* cur_atom_num true atom number
|
||||
* cur_mol current molecule
|
||||
* f_out output file
|
||||
*/
|
||||
|
||||
cur_atom = 1;
|
||||
|
@ -1,6 +1,14 @@
|
||||
/**
|
||||
* @file
|
||||
*/
|
||||
|
||||
#ifndef PRINT_STRUCTURE_H
|
||||
#define PRINT_STRUCTURE_H
|
||||
|
||||
/**
|
||||
* @fn print_structure
|
||||
*/
|
||||
|
||||
int print_structure (const char *, const int, const int *, const int, const int *,
|
||||
const char *, const float *);
|
||||
|
||||
|
@ -1,3 +1,7 @@
|
||||
/**
|
||||
* @file
|
||||
*/
|
||||
|
||||
/* Library for search center mass of molecules
|
||||
*
|
||||
* Usage:
|
||||
@ -6,18 +10,30 @@
|
||||
*/
|
||||
|
||||
|
||||
/**
|
||||
* @fn set_center
|
||||
*/
|
||||
int set_center (const int num_atoms, const int num_mol, const int *label_mol,
|
||||
const float *coords, float *centr_coords)
|
||||
/* num_atoms - number of atoms for writing coordinates
|
||||
* num_mol - number of molecules for writing coordinates
|
||||
* label_mol - massive of numbers of molecule for atoms
|
||||
* coords - massive of coordinates
|
||||
* coords - massive of coordinates of center molecules
|
||||
/**
|
||||
* @brief function that searchs center mass of molecules
|
||||
* @code
|
||||
* set_center (num_of_atoms, num_of_molecules, label_molecules, coords, centr_coords);
|
||||
* @endcode
|
||||
*
|
||||
* @param num_atoms number of atoms
|
||||
* @param num_mol number of molecules
|
||||
* @param label_mol massive of numbers of molecule for atoms
|
||||
* @param coords massive of coordinates
|
||||
* @param centr_coords massive of centered coordinates
|
||||
*
|
||||
* @return 0 - exit without errors
|
||||
*/
|
||||
{
|
||||
int at_in_mol, cur_mol, i, j, k;
|
||||
/* at_int_mol - number of atoms in molecule
|
||||
* cur_mol - current molecule
|
||||
|
||||
/* at_int_mol number of atoms in molecule
|
||||
* cur_mol current molecule
|
||||
*/
|
||||
|
||||
for (i=0; i<8*num_mol; i++)
|
||||
|
@ -1,6 +1,14 @@
|
||||
/**
|
||||
* @file
|
||||
*/
|
||||
|
||||
#ifndef SET_CENTER_H
|
||||
#define SET_CENTER_H
|
||||
|
||||
/**
|
||||
* @fn set_center
|
||||
*/
|
||||
|
||||
int set_center (const int, const int, const int *, const float *, float *);
|
||||
|
||||
#endif /* SET_CENTER_H */
|
Reference in New Issue
Block a user