/************************************************************************************************************* The MIT License Copyright (C) 2006-2019 David Dubbeldam, Sofia Calero, Thijs Vlugt, Donald E. Ellis, and Randall Q. Snurr. D.Dubbeldam@uva.nl http://www.uva.nl/profiel/d/u/d.dubbeldam/d.dubbeldam.html scaldia@upo.es http://www.upo.es/raspa/ t.j.h.vlugt@tudelft.nl http://homepage.tudelft.nl/v9k6y don-ellis@northwestern.edu http://dvworld.northwestern.edu/ snurr@northwestern.edu http://zeolites.cqe.northwestern.edu/ Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. **************************************************************************************************************/ #ifdef HAVE_CONFIG_H #include #endif #include #include #include #include #include #include #include #include #include #include #include #include "constants.h" #include "molecule.h" #include "framework.h" #include "framework_energy.h" #include "simulation.h" #include "ewald.h" #include "potentials.h" #include "utils.h" #include "input.h" #include "output.h" #include "cbmc.h" #include "mc_moves.h" #include "grids.h" #include "spacegroup.h" #include "thermo_baro_stats.h" #include "scattering_factors.h" #include "internal_force.h" #include "minimization.h" #include "rigid.h" extern bool STREAM; extern char *INPUT_CRYSTAL; CRYSTALLOGRAPHIC_STATISTICS *crystallographic_stats; int CorrectNetChargeOnPseudoAtom; REAL CorrectNetChargeOnPseudoAtomValue; VECTOR *UnitCellSize; INT_VECTOR3 *NumberOfUnitCells; REAL_MATRIX3x3 *UnitCellBox; REAL_MATRIX3x3 *InverseUnitCellBox; int *Lowenstein; int AsymmetricIons; int SpaceGroupIons; REAL CutOffIons; FRAMEWORK_COMPONENT *Framework; // list of frameworks int CurrentFramework; // global variable: the current framework int RemoveBondNeighboursFromLongRangeInteraction; // remove 1-2 interactions only between atoms in a defined bond int RemoveBendNeighboursFromLongRangeInteraction; // remove 1-2 interactions only between atoms in a defined bend int RemoveTorsionNeighboursFromLongRangeInteraction; // remove 1-3 interactions only between atoms in a defined torsion int Remove12NeighboursFromVDWInteraction; // remove 1-2 neighbor interaction from VDW interaction int Remove13NeighboursFromVDWInteraction; // remove 1-3 neighbor interaction from VDW interaction int Remove14NeighboursFromVDWInteraction; // remove 1-4 neighbor interaction from VDW interaction int Remove12NeighboursFromChargeChargeInteraction; // remove 1-2 neighbor interaction from charge-charge interaction int Remove13NeighboursFromChargeChargeInteraction; // remove 1-3 neighbor interaction from charge-charge interaction int Remove14NeighboursFromChargeChargeInteraction; // remove 1-4 neighbor interaction from charge-charge interaction int Remove11NeighboursFromChargeBondDipoleInteraction; // remove 1-1 neighbor interaction from charge-bonddipole interaction int Remove12NeighboursFromChargeBondDipoleInteraction; // remove 1-2 neighbor interaction from charge-bonddipole interaction int Remove13NeighboursFromChargeBondDipoleInteraction; // remove 1-3 neighbor interaction from charge-bonddipole interaction int Remove14NeighboursFromChargeBondDipoleInteraction; // remove 1-4 neighbor interaction from charge-bonddipole interaction int Remove12NeighboursFromBondDipoleBondDipoleInteraction; // remove 1-2 neighbor interaction from bonddipole-bonddipole interaction int Remove13NeighboursFromBondDipoleBondDipoleInteraction; // remove 1-3 neighbor interaction from bonddipole-bonddipole interaction int Remove14NeighboursFromBondDipoleBondDipoleInteraction; // remove 1-4 neighbor interaction from bonddipole-bonddipole interaction int InternalFrameworkLennardJonesInteractions; int ImproperTorsionScanType; int NumberOfSingleSubstitutionRules; char (*SubstitutionSingleFrameworkAtom)[3][256]; int (*SubstitutionSingleFrameworkAtomTypes)[3]; int NumberOfRandomSubstitutions; int NumberOfSubstitutionRules; char (*SubstitutionFrameworkAtoms)[3][256]; int (*SubstitutionFrameworkAtomTypes)[3]; int NumberOfSubstitutions; int (*ListOfAtomSubstitutions)[3]; int NumberOfModificationRules; int *ModificationRuleType; char (*ModifyFrameworkAtoms)[10][256]; int (*ModifyFrameworkAtomTypes)[10]; int NumberOfForbiddenConnectivityRules; char (*ForbiddenConnectivityAtoms)[3][256]; int (*ForbiddenConnectivityTypes)[3]; void AllocateFrameworkCellList(void) { int i; if((Framework[CurrentSystem].FrameworkModel!=NONE)&&(UseCellLists[CurrentSystem])) { Framework[CurrentSystem].CellListHead=(int**)calloc(Framework[CurrentSystem].NumberOfFrameworks,sizeof(int*)); Framework[CurrentSystem].CellList=(int**)calloc(Framework[CurrentSystem].NumberOfFrameworks,sizeof(int*)); for(i=0;i1e-10) PseudoAtoms[i].HasCharges=TRUE; type=Framework[CurrentSystem].Atoms[f1][j].Type; if(type==i) { total_charge+=charge; total_count+=1.0; } } } PseudoAtoms[i].Charge1=total_charge/total_count; } else { if(fabs(PseudoAtoms[i].Charge1)>1e-10) PseudoAtoms[i].HasCharges=TRUE; } } } void AddAsymmetricAtom(FRAMEWORK_ASYMMETRIC_ATOM atom) { int nr_atoms; nr_atoms=Framework[CurrentSystem].NumberOfAsymmetricAtoms[CurrentFramework]; Framework[CurrentSystem].AtomsAsymmetric[CurrentFramework]=(FRAMEWORK_ASYMMETRIC_ATOM*)realloc(Framework[CurrentSystem].AtomsAsymmetric[CurrentFramework], (nr_atoms+1)*sizeof(FRAMEWORK_ASYMMETRIC_ATOM)); if(!Framework[CurrentSystem].AtomsAsymmetric[CurrentFramework]) { printf("Memory reallocation error of 'Framework[CurrentSystem].AtomsAsymmetric[CurrentFramework]' in file %s line %d\n", __FILE__, __LINE__); exit(-1); } Framework[CurrentSystem].AtomsAsymmetric[CurrentFramework][nr_atoms]=atom; Framework[CurrentSystem].NumberOfAsymmetricAtoms[CurrentFramework]++; } void RemoveQuotesAroundString(char *string) { if(string[0]=='\'') { memmove(&string[0],&string[1],strlen(string)); if(string[strlen(string)-1]=='\'') string[strlen(string)-1]='\0'; } if(string[0]=='\"') { memmove(&string[0],&string[1],strlen(string)); if(string[strlen(string)-1]=='\"') string[strlen(string)-1]='\0'; } } void SetBoundaryCondition(int system, REAL eps_angle, REAL eps_length, REAL alpha, REAL beta, REAL gamma, REAL A, REAL B, REAL C) { if((fabs(alpha-90.0)>eps_angle)||(fabs(beta-90.0)>eps_angle)||(fabs(gamma-90.0)>eps_angle)) BoundaryCondition[system]=TRICLINIC; else if((fabs(A-B)>eps_length)||(fabs(A-C)>eps_length)||(fabs(B-C)>eps_length)) BoundaryCondition[system]=RECTANGULAR; else BoundaryCondition[system]=CUBIC; } void SetBoundaryConditionFromSystem(int system, REAL eps_angle, REAL eps_length) { SetBoundaryCondition(system, eps_angle, eps_length, AlphaAngle[system]*RAD2DEG, BetaAngle[system]*RAD2DEG, GammaAngle[system]*RAD2DEG, BoxProperties[system].ax, BoxProperties[system].ay, BoxProperties[system].az ); } /********************************************************************************************************* * Name | ReadFrameworkDefinitionCIF * * ----------------------------------------------------------------------------------------------------- * * Function | reads a CIF-file and expands the structure to 'P1' (no symmetry) * * Parameters | - * * Note | The CIF specification can be found online: http://www.iucr.org/resources/cif/spec * * | and S.R. Hall, F.H. Allen, and I.D. Brown, Acta Cryst. A47, 655-685, 1991. * * | The definition is based on the free format STAR procedure. Not many CIF-file closely * * | follow this format striclty. Therefore the reading of CIF-files can be challenging. * *********************************************************************************************************/ // 'keyword': first string a line with spaces in front removed and separated to the second string by a space. // 'arguments': the part following a 'keyword', // The routine implemented here only parses a subset of the CIF-file (only the needed data is processed). // There are two groups of data, 1) single lines, and 2) looped data. // // The single lines are e.g. '_cell_length_a', '_cell_length_b', '_cell_length_c', '_cell_angle_alpha', // '_cell_angle_beta', '_cell_angle_gamma', '_symmetry_space_group_name_Hall', '_symmetry_space_group_name_H-M', // and '_symmetry_Int_Tables_number'. These can be parsed without difficulty. This input routine requires that // the argument follow these 'data names' is on the same line. // // The looped data are blocks of data items that are repeated in a list. The first command of such a list is "loop_", eg. // // loop_ // _atom_site_label // _atom_site_type_symbol // _atom_site_fract_x // _atom_site_fract_y // _atom_site_fract_z // C1 C 0.3671(3) 0.1045(3) 0.2279(5) // H1 H 0.3756 0.0732 0.2106 0.131 // C2 C 0.3282(3) 0.1718(3) 0.2500 // // However, we never parse the loop-command here. Instead we check for whether the first keyword starts with // '_atom_type_' or '_atom_site_' or '_symmetry_equiv_pos'. This is all the data we require for simulations. // The block is parsed as follows. Take for example '_atom_site_'. We keep on reading keywords until it does not // start with '_atom_site_' anymore. For each keyword we keep track of whether it is the first, second, third, etc. // This is because the order of the keyword is also the order in which the data is later provided. After this // part we know how many elements there should be read in and what each element means. The routine here assumes the // elements per line should correspond to the amount of "_atom_site" commands. Also unknown commands are allowed // starting with '_atom_site' (they are simply not used). The elements are read in string by string seperated by // white spaces. White spaces in front are always removed. If the first character is a ' or " symbol, then we need // to find the corresponding closing symbol and treat the found string as one element (with white spaces inside). // e.g. // // loop_ // _atom_type_symbol // _atom_type_scat_source // C 'International Tables Vol C Tables 4.2.6.8 and 6.1.1.4' // // The listed items are parsed until a 'loop_' statement of the next block is encountered or a command (starting // with '_' is found. // Note that after a full line of elements is read, the data is stored in the appropriate RASPA structures. // Note that comment lines starting with '#' are skipped. // Note that empty lines are skipped. // Restrictions: 1) a single (quoted) term needs to be a single line // 2) a new list of data items needs to start at a new line void ReadFrameworkDefinitionCIF(void) { #define MAX_CIF_LINE_SIZE 1024 #define MAX_NUMBER_OF_CIF_TERMS 55 enum{ATOM_SITE_LABEL,ATOM_SITE_TYPE_SYMBOL,ATOM_SITE_FRACT_X,ATOM_SITE_FRACT_Y,ATOM_SITE_FRACT_Z, ATOM_SITE_U_ISO_OR_EQUIV,ATOM_SITE_ADP_TYPE,ATOM_SITE_OCCUPANCY,ATOM_SITE_SYMMETRY_MULTIPLICITY, ATOM_SITE_CALC_FLAG,ATOM_SITE_REFINEMENT_FLAG,ATOM_SITE_DISORDER_ASSEMBLY,ATOM_SITE_DISORDER_GROUP, ATOM_SITE_ANISO_LABEL,ATOM_SITE_ANISO_U_11,ATOM_SITE_ANISO_U_22,ATOM_SITE_ANISO_U_33, ATOM_SITE_ANISO_U_23,ATOM_SITE_ANISO_U_13,ATOM_SITE_ANISO_U_12,ATOM_SITE_THERMAL_DISPLACE_TYPE, ATOM_SITE_CHARGE,ATOM_SITE_POLARIZATION,ATOM_SITE_ANISOTROPIC_TYPE,ATOM_SITE_ANISOTROPIC_DISPLACEMENT, ATOM_SITE_PRINT_TO_PDB,ATOM_SITE_HYBRIDIZATION, CITATION_ID,CITATION_AUTHOR_NAME,CITATION_COORDINATE_LINKAGE,CITATION_TITLE,CITATION_COUNTRY,CITATION_PAGE_FIRST,CITATION_PAGE_LAST, CITATION_YEAR,CITATION_JOURNAL_ABBREV,CITATION_JOURNAL_VOLUME,CITATION_JOURNAL_ISSUE,CITATION_JOURNAL_ID_ASTM, CITATION_JOURNAL_ID_ISSN,CITATION_BOOKTITLE,CITATION_BOOK_PUBLISHER,CITATION_BOOK_ID_ISBN,CITATION_SPECIAL_DETAILS, ATOM_TYPE_SYMBOL,ATOM_TYPE_DESCRIPTION,ATOM_TYPE_OXIDATION_NUMBER,ATOM_TYPE_NUMBER_IN_CELL, ATOM_TYPE_SCAT_DISPERSION_REAL,ATOM_TYPE_SCAT_DISPERSION_IMAG,ATOM_TYPE_SCAT_SOURCE, ATOM_TYPE_RADIUS_BOND,ATOM_TYPE_RADIUS_CONTACT, SYMMETRY_EQUIV_POS_SITE_ID,SYMMETRY_EQUIV_POS_AS_XYZ}; int i,n; char buffer[256]; char line[MAX_CIF_LINE_SIZE],keyword[MAX_CIF_LINE_SIZE],arguments[MAX_CIF_LINE_SIZE]; FILE *FilePtr; int NumberOfAtomTypeElementsInBlock; int NumberOfAtomSiteElementsInBlock; int CifBlockData[MAX_NUMBER_OF_CIF_TERMS]; char *arg_pointer; char SpaceGroup[192][32]; int nr_sg_elements; REAL A,B,C; REAL alpha,beta,gamma; REAL tempd,det; PSEUDO_ATOM CurrentPseudoAtom; FRAMEWORK_ASYMMETRIC_ATOM CurrentAsymmetricAtom; CITATION_INFORMATION CitationInformation; char *LoopCondition; int FoundSpaceGroupSymmetryElements; int FoundSpaceGroupHall; int FoundSpaceGroupHermannMauguinString; int FoundSpaceGroupIntTables; char FoundSpaceGroupOption[32]; char string1[32]; char *p; int DefinedInLoop,PositionDefined; int OriginalNumberOfPseudoAtoms; VECTOR pos; int BoolChargeDefinedInCIFFile; // unless later '_atom_site_charge' is used, the charges are assumed not present in the CIF-file BoolChargeDefinedInCIFFile=FALSE; // set the number of pseudo-atoms before reading in the CIF-file OriginalNumberOfPseudoAtoms=NumberOfPseudoAtoms; FoundSpaceGroupSymmetryElements=0; FoundSpaceGroupHall=0; FoundSpaceGroupHermannMauguinString=0; FoundSpaceGroupIntTables=0; Framework[CurrentSystem].SpaceGroupIdentifier[CurrentFramework]=0; Framework[CurrentSystem].NumberOfAsymmetricAtoms[CurrentFramework]=0; Framework[CurrentSystem].NumberOfAtoms[CurrentFramework]=0; NumberOfAtomTypeElementsInBlock=0; NumberOfAtomSiteElementsInBlock=0; strcpy(FoundSpaceGroupOption,""); if (STREAM) { #ifdef __unix__ if (!(FilePtr=fmemopen((void *)INPUT_CRYSTAL, strlen(INPUT_CRYSTAL), "r"))) { printf("Error reading streamed CIF molecule."); exit(1); } #else fprintf(stderr, "Streaming only allowed on POSIX systems (for now)\n."); exit(1); #endif } else { // first try to open the framework-file in the current directory, // and next from the repository sprintf(buffer,"%s.%s", Framework[CurrentSystem].Name[CurrentFramework], "cif"); if(!(FilePtr=fopen(buffer,"r"))) { sprintf(buffer,"%s/share/raspa/structures/cif/%s.%s", RASPA_DIRECTORY, Framework[CurrentSystem].Name[CurrentFramework], "cif"); if(!(FilePtr=fopen(buffer,"r"))) { fprintf(stderr, "Error: file %s does not exist.\n",buffer); exit(1); } } } // read one line of data, and parse in 'keyword' and 'arguments' // LoopCondition is TRUE when data can be read and FALSE when end-of-file is reached LoopCondition=fgets(line,MAX_CIF_LINE_SIZE,FilePtr); strcpy(keyword,""); strcpy(arguments,""); sscanf(line,"%s%[^\n]",keyword,arguments); strcpy(CitationInformation.CitationId,""); strcpy(CitationInformation.CitationAuthorName,""); strcpy(CitationInformation.CitationCoordinateLinkage,""); strcpy(CitationInformation.CitationTitle,""); strcpy(CitationInformation.CitationCountry,""); strcpy(CitationInformation.CitationPageFirst,""); strcpy(CitationInformation.CitationPageFirst,""); strcpy(CitationInformation.CitationYear,""); strcpy(CitationInformation.CitationJournalAbbrev,""); strcpy(CitationInformation.CitationJournalVolume,""); strcpy(CitationInformation.CitationJournalIssue,""); strcpy(CitationInformation.CitationJournalID_ASTM,""); strcpy(CitationInformation.CitationJournalID_ISSN,""); strcpy(CitationInformation.CitationBookTitle,""); strcpy(CitationInformation.CitationBookPublisher,""); strcpy(CitationInformation.CitationBookID_ISBN,""); strcpy(CitationInformation.CitationSpecialDetails,""); do { // read loop citation info // ==================================== if(strncasecmp(keyword,"_citation_",strlen("_citation_"))==0) { NumberOfAtomSiteElementsInBlock=0; DefinedInLoop=TRUE; // assume as default: citations are in loop for(i=0;i0)&&(arguments[0]!='_')) { DefinedInLoop=FALSE; RemoveQuotesAroundString(arguments); strcpy(CitationInformation.CitationId,arguments); } else NumberOfAtomSiteElementsInBlock++; } else if(strncasecmp(keyword,"_citation_author_name",strlen("_citation_author_name"))==0) { CifBlockData[CITATION_AUTHOR_NAME]=NumberOfAtomSiteElementsInBlock; if((strlen(arguments)>0)&&(arguments[0]!='_')) { DefinedInLoop=FALSE; RemoveQuotesAroundString(arguments); strcpy(CitationInformation.CitationAuthorName,arguments); } else NumberOfAtomSiteElementsInBlock++; } else if(strncasecmp(keyword,"_citation_coordinate_linkage",strlen("_citation_coordinate_linkage"))==0) { CifBlockData[CITATION_COORDINATE_LINKAGE]=NumberOfAtomSiteElementsInBlock; if((strlen(arguments)>0)&&(arguments[0]!='_')) { DefinedInLoop=FALSE; RemoveQuotesAroundString(arguments); strcpy(CitationInformation.CitationCoordinateLinkage,arguments); } else NumberOfAtomSiteElementsInBlock++; } else if(strncasecmp(keyword,"_citation_title",strlen("_citation_title"))==0) { CifBlockData[CITATION_TITLE]=NumberOfAtomSiteElementsInBlock; if((strlen(arguments)>0)&&(arguments[0]!='_')) { DefinedInLoop=FALSE; RemoveQuotesAroundString(arguments); strcpy(CitationInformation.CitationTitle,arguments); } else NumberOfAtomSiteElementsInBlock++; } else if(strncasecmp(keyword,"_citation_country",strlen("_citation_country"))==0) { CifBlockData[CITATION_COUNTRY]=NumberOfAtomSiteElementsInBlock; if((strlen(arguments)>0)&&(arguments[0]!='_')) { DefinedInLoop=FALSE; RemoveQuotesAroundString(arguments); strcpy(CitationInformation.CitationCountry,arguments); } else NumberOfAtomSiteElementsInBlock++; } else if(strncasecmp(keyword,"_citation_page_first",strlen("_citation_page_first"))==0) { CifBlockData[CITATION_PAGE_FIRST]=NumberOfAtomSiteElementsInBlock; if((strlen(arguments)>0)&&(arguments[0]!='_')) { DefinedInLoop=FALSE; RemoveQuotesAroundString(arguments); strcpy(CitationInformation.CitationPageFirst,arguments); } else NumberOfAtomSiteElementsInBlock++; } else if(strncasecmp(keyword,"_citation_page_last",strlen("_citation_page_last"))==0) { CifBlockData[CITATION_PAGE_LAST]=NumberOfAtomSiteElementsInBlock; if((strlen(arguments)>0)&&(arguments[0]!='_')) { DefinedInLoop=FALSE; RemoveQuotesAroundString(arguments); strcpy(CitationInformation.CitationPageLast,arguments); } else NumberOfAtomSiteElementsInBlock++; } else if(strncasecmp(keyword,"_citation_year",strlen("_citation_year"))==0) { CifBlockData[CITATION_YEAR]=NumberOfAtomSiteElementsInBlock; if((strlen(arguments)>0)&&(arguments[0]!='_')) { DefinedInLoop=FALSE; RemoveQuotesAroundString(arguments); strcpy(CitationInformation.CitationYear,arguments); } else NumberOfAtomSiteElementsInBlock++; } else if(strncasecmp(keyword,"_citation_journal_abbrev",strlen("_citation_journal_abbrev"))==0) { CifBlockData[CITATION_JOURNAL_ABBREV]=NumberOfAtomSiteElementsInBlock; if((strlen(arguments)>0)&&(arguments[0]!='_')) { DefinedInLoop=FALSE; RemoveQuotesAroundString(arguments); strcpy(CitationInformation.CitationJournalAbbrev,arguments); } else NumberOfAtomSiteElementsInBlock++; } else if(strncasecmp(keyword,"_citation_journal_volume",strlen("_citation_journal_volume"))==0) { CifBlockData[CITATION_JOURNAL_VOLUME]=NumberOfAtomSiteElementsInBlock; if((strlen(arguments)>0)&&(arguments[0]!='_')) { DefinedInLoop=FALSE; RemoveQuotesAroundString(arguments); strcpy(CitationInformation.CitationJournalVolume,arguments); } else NumberOfAtomSiteElementsInBlock++; } else if(strncasecmp(keyword,"_citation_journal_issue",strlen("_citation_journal_issue"))==0) { CifBlockData[CITATION_JOURNAL_ISSUE]=NumberOfAtomSiteElementsInBlock; if((strlen(arguments)>0)&&(arguments[0]!='_')) { DefinedInLoop=FALSE; RemoveQuotesAroundString(arguments); strcpy(CitationInformation.CitationJournalIssue,arguments); } else NumberOfAtomSiteElementsInBlock++; } else if(strncasecmp(keyword,"_citation_journal_id_ASTM",strlen("_citation_journal_id_ASTM"))==0) { CifBlockData[CITATION_JOURNAL_ID_ASTM]=NumberOfAtomSiteElementsInBlock; if((strlen(arguments)>0)&&(arguments[0]!='_')) { DefinedInLoop=FALSE; RemoveQuotesAroundString(arguments); strcpy(CitationInformation.CitationJournalID_ASTM,arguments); } else NumberOfAtomSiteElementsInBlock++; } else if(strncasecmp(keyword,"_citation_journal_id_ISSN",strlen("_citation_journal_id_ISSN"))==0) { CifBlockData[CITATION_JOURNAL_ID_ISSN]=NumberOfAtomSiteElementsInBlock; if((strlen(arguments)>0)&&(arguments[0]!='_')) { DefinedInLoop=FALSE; RemoveQuotesAroundString(arguments); strcpy(CitationInformation.CitationJournalID_ISSN,arguments); } else NumberOfAtomSiteElementsInBlock++; } else if(strncasecmp(keyword,"_citation_book_title",strlen("_citation_book_title"))==0) { CifBlockData[CITATION_BOOKTITLE]=NumberOfAtomSiteElementsInBlock; if((strlen(arguments)>0)&&(arguments[0]!='_')) { DefinedInLoop=FALSE; RemoveQuotesAroundString(arguments); strcpy(CitationInformation.CitationBookTitle,arguments); } else NumberOfAtomSiteElementsInBlock++; } else if(strncasecmp(keyword,"_citation_book_publisher",strlen("_citation_book_publisher"))==0) { CifBlockData[CITATION_BOOK_PUBLISHER]=NumberOfAtomSiteElementsInBlock; if((strlen(arguments)>0)&&(arguments[0]!='_')) { DefinedInLoop=FALSE; strcpy(CitationInformation.CitationBookPublisher,arguments); } else NumberOfAtomSiteElementsInBlock++; } else if(strncasecmp(keyword,"_citation_book_id_ISBN",strlen("_citation_book_id_ISBN"))==0) { CifBlockData[CITATION_BOOK_ID_ISBN]=NumberOfAtomSiteElementsInBlock; if((strlen(arguments)>0)&&(arguments[0]!='_')) { DefinedInLoop=FALSE; strcpy(CitationInformation.CitationBookID_ISBN,arguments); } else NumberOfAtomSiteElementsInBlock++; } else if(strncasecmp(keyword,"_citation_special_details",strlen("_citation_special_details"))==0) { CifBlockData[CITATION_SPECIAL_DETAILS]=NumberOfAtomSiteElementsInBlock; if((strlen(arguments)>0)&&(arguments[0]!='_')) { DefinedInLoop=FALSE; RemoveQuotesAroundString(arguments); strcpy(CitationInformation.CitationSpecialDetails,arguments); } else NumberOfAtomSiteElementsInBlock++; } // check if another data name follows // if so, copy the 'arguments' to 'line' // otherwise read 'line' from the file if((strlen(arguments)>0)&&(arguments[0]=='_')) strcpy(line,arguments); else LoopCondition=fgets(line,MAX_CIF_LINE_SIZE,FilePtr); // split the new line into 'keyword' and 'arguments' TrimStringInPlace(line); strcpy(keyword,""); strcpy(arguments,""); sscanf(line,"%s%[^\n]",keyword,arguments); // skip comments if(keyword[0]=='#') { strcpy(keyword,""); strcpy(arguments,""); } } // continue when new keyword starts with '_atom_type_', also continue when empty line while(((strncasecmp(keyword,"_citation_",strlen("_citation_"))==0)||(strlen(keyword)==0))&&LoopCondition); if(!DefinedInLoop) { Framework[CurrentSystem].CitationInformation[CurrentFramework]=(CITATION_INFORMATION*)calloc( (Framework[CurrentSystem].NumberOfCitations[CurrentFramework]+1),sizeof(CITATION_INFORMATION)); Framework[CurrentSystem].CitationInformation[CurrentFramework][Framework[CurrentSystem].NumberOfCitations[CurrentFramework]]=CitationInformation; Framework[CurrentSystem].NumberOfCitations[CurrentFramework]++; } else do { // loop over data items if(strlen(keyword)>0) { arg_pointer=line; // remove spaces TrimStringInPlace(arg_pointer); strcpy(CitationInformation.CitationId,""); strcpy(CitationInformation.CitationAuthorName,""); strcpy(CitationInformation.CitationCoordinateLinkage,""); strcpy(CitationInformation.CitationTitle,""); strcpy(CitationInformation.CitationCountry,""); strcpy(CitationInformation.CitationPageFirst,""); strcpy(CitationInformation.CitationPageFirst,""); strcpy(CitationInformation.CitationYear,""); strcpy(CitationInformation.CitationJournalAbbrev,""); strcpy(CitationInformation.CitationJournalVolume,""); strcpy(CitationInformation.CitationJournalIssue,""); strcpy(CitationInformation.CitationJournalID_ASTM,""); strcpy(CitationInformation.CitationJournalID_ISSN,""); strcpy(CitationInformation.CitationBookTitle,""); strcpy(CitationInformation.CitationBookPublisher,""); strcpy(CitationInformation.CitationBookID_ISBN,""); strcpy(CitationInformation.CitationSpecialDetails,""); for(i=0;i0) NumberOfAtomSiteElementsInBlock++; // check if another data name follows // if so, copy the 'arguments' to 'line' // otherwise read 'line' from the file TrimStringInPlace(arguments); if((strlen(arguments)>0)&&(arguments[0]=='_')) strcpy(line,arguments); else LoopCondition=fgets(line,MAX_CIF_LINE_SIZE,FilePtr); // split the new line into 'keyword' and 'arguments' TrimStringInPlace(line); strcpy(keyword,""); strcpy(arguments,""); sscanf(line,"%s%[^\n]",keyword,arguments); // skip comments if(keyword[0]=='#') { strcpy(keyword,""); strcpy(arguments,""); } } // continue when new keyword starts with '_atom_type_', also continue when empty line while(((strncasecmp(keyword,"_atom_type_",strlen("_atom_type_"))==0)||(strlen(keyword)==0))&&LoopCondition); do { // loop over data items if(strlen(keyword)>0) { arg_pointer=line; // remove spaces TrimStringInPlace(arg_pointer); strcpy(CurrentPseudoAtom.Name,""); strcpy(CurrentPseudoAtom.PrintToPDBName,""); strcpy(CurrentPseudoAtom.ChemicalElement,""); strcpy(CurrentPseudoAtom.ScatteringSource,""); CurrentPseudoAtom.Occupancy=1.0; CurrentPseudoAtom.FrameworkAtom=TRUE; CurrentPseudoAtom.PrintToPDB=TRUE; CurrentPseudoAtom.ScatteringType=0; CurrentPseudoAtom.AnomalousScatteringType=0; CurrentPseudoAtom.TemperatureFactor=0.0; CurrentPseudoAtom.AnisotropicTemperatureFactor.ax=0.0; CurrentPseudoAtom.AnisotropicTemperatureFactor.ay=0.0; CurrentPseudoAtom.AnisotropicTemperatureFactor.az=0.0; CurrentPseudoAtom.AnisotropicTemperatureFactor.bx=0.0; CurrentPseudoAtom.AnisotropicTemperatureFactor.by=0.0; CurrentPseudoAtom.AnisotropicTemperatureFactor.bz=0.0; CurrentPseudoAtom.AnisotropicTemperatureFactor.cx=0.0; CurrentPseudoAtom.AnisotropicTemperatureFactor.cy=0.0; CurrentPseudoAtom.AnisotropicTemperatureFactor.cz=0.0; CurrentPseudoAtom.ScatteringDispersionImaginary=0.0; CurrentPseudoAtom.ScatteringDispersionImaginary=0.0; CurrentPseudoAtom.Mass=0.0; CurrentPseudoAtom.Charge1=0.0; CurrentPseudoAtom.Polarization.ax=CurrentPseudoAtom.Polarization.ay=CurrentPseudoAtom.Polarization.az=0.0; CurrentPseudoAtom.Polarization.bx=CurrentPseudoAtom.Polarization.by=CurrentPseudoAtom.Polarization.bz=0.0; CurrentPseudoAtom.Polarization.cx=CurrentPseudoAtom.Polarization.cy=CurrentPseudoAtom.Polarization.cz=0.0; CurrentPseudoAtom.HasCharges=TRUE; CurrentPseudoAtom.IsPolarizable=FALSE; CurrentPseudoAtom.Interaction=TRUE; CurrentPseudoAtom.Radius=0.0; CurrentPseudoAtom.Connectivity=0; CurrentPseudoAtom.TinkerType=0; CurrentPseudoAtom.AnisotropicCorrection=FALSE; CurrentPseudoAtom.AnisotropicDisplacement=0.0; CurrentPseudoAtom.AnisotropicType=0.0; for(i=0;i0) NumberOfAtomSiteElementsInBlock++; // check if another data name follows // if so, copy the 'arguments' to 'line' // otherwise read 'line' from the file TrimStringInPlace(arguments); if((strlen(arguments)>0)&&(arguments[0]=='_')) strcpy(line,arguments); else LoopCondition=fgets(line,MAX_CIF_LINE_SIZE,FilePtr); // split the new line into 'keyword' and 'arguments' strcpy(keyword,""); strcpy(arguments,""); sscanf(line,"%s%[^\n]",keyword,arguments); // skip comments if(keyword[0]=='#') { strcpy(keyword,""); strcpy(arguments,""); } } while(((strncasecmp(keyword,"_atom_site_",strlen("_atom_site_"))==0)||(strlen(keyword)==0))&&LoopCondition); do { // loop over data items if(strlen(keyword)>0) { arg_pointer=line; // remove spaces TrimStringInPlace(arg_pointer); strcpy(CurrentPseudoAtom.Name,""); strcpy(CurrentPseudoAtom.PrintToPDBName,""); strcpy(CurrentPseudoAtom.ChemicalElement,""); strcpy(CurrentPseudoAtom.OxidationStateString,""); CurrentPseudoAtom.OxidationState=0.0; strcpy(CurrentPseudoAtom.ScatteringSource,"na"); CurrentPseudoAtom.Occupancy=1.0; CurrentPseudoAtom.FrameworkAtom=TRUE; CurrentPseudoAtom.PrintToPDB=TRUE; CurrentPseudoAtom.ScatteringType=0; CurrentPseudoAtom.AnomalousScatteringType=0; CurrentPseudoAtom.TemperatureFactor=0.0; CurrentPseudoAtom.AnisotropicTemperatureFactor.ax=0.0; CurrentPseudoAtom.AnisotropicTemperatureFactor.ay=0.0; CurrentPseudoAtom.AnisotropicTemperatureFactor.az=0.0; CurrentPseudoAtom.AnisotropicTemperatureFactor.bx=0.0; CurrentPseudoAtom.AnisotropicTemperatureFactor.by=0.0; CurrentPseudoAtom.AnisotropicTemperatureFactor.bz=0.0; CurrentPseudoAtom.AnisotropicTemperatureFactor.cx=0.0; CurrentPseudoAtom.AnisotropicTemperatureFactor.cy=0.0; CurrentPseudoAtom.AnisotropicTemperatureFactor.cz=0.0; CurrentPseudoAtom.ScatteringDispersionImaginary=0.0; CurrentPseudoAtom.ScatteringDispersionImaginary=0.0; CurrentPseudoAtom.Mass=0.0; CurrentPseudoAtom.Charge1=0.0; CurrentPseudoAtom.ChargeDefinitionType=CHARGE_NOT_DEFINED; // charge not yet known CurrentPseudoAtom.Polarization.ax=CurrentPseudoAtom.Polarization.ay=CurrentPseudoAtom.Polarization.az=0.0; CurrentPseudoAtom.Polarization.bx=CurrentPseudoAtom.Polarization.by=CurrentPseudoAtom.Polarization.bz=0.0; CurrentPseudoAtom.Polarization.cx=CurrentPseudoAtom.Polarization.cy=CurrentPseudoAtom.Polarization.cz=0.0; CurrentPseudoAtom.HasCharges=TRUE; CurrentPseudoAtom.IsPolarizable=FALSE; CurrentPseudoAtom.Interaction=TRUE; CurrentPseudoAtom.Radius=0.0; CurrentPseudoAtom.Connectivity=0; CurrentPseudoAtom.TinkerType=0; CurrentPseudoAtom.AnisotropicCorrection=FALSE; CurrentPseudoAtom.AnisotropicDisplacement=0.0; CurrentPseudoAtom.AnisotropicType=0.0; CurrentPseudoAtom.HasVDWInteraction=TRUE; CurrentPseudoAtom.Hybridization=HYBRIDIZATION_UNINITIALIZED; CurrentAsymmetricAtom.Position.x=0.0; CurrentAsymmetricAtom.Position.y=0.0; CurrentAsymmetricAtom.Position.z=0.0; CurrentAsymmetricAtom.Charge=0.0; PositionDefined=TRUE; for(i=0;i=2) { strcat(CurrentPseudoAtom.OxidationStateString,string1); p+=n; } strcpy(string1,""); sscanf(p,"%s",string1); // 'Name' consists of the chemical-element part concatenated with the oxydation state strcpy(CurrentPseudoAtom.Name,CurrentPseudoAtom.ChemicalElement); strcat(CurrentPseudoAtom.Name,CurrentPseudoAtom.OxidationStateString); } } else if(i==CifBlockData[ATOM_SITE_TYPE_SYMBOL]) { // must match '_atom_type_symbol' sscanf(keyword,"%[a-zA-Z]%n",CurrentPseudoAtom.ChemicalElement,&n); p=keyword+n; n=0; strcpy(string1,""); string1[2]='\0'; while(sscanf(p,"%[0-9]%[+-]%n",&string1[0],&string1[1],&n)>=2) { strcat(CurrentPseudoAtom.OxidationStateString,string1); p+=n; } // 'Name' consists of the chemical-element part concatenated with the oxydation state strcpy(CurrentPseudoAtom.PrintToPDBName,CurrentPseudoAtom.ChemicalElement); CurrentPseudoAtom.OxidationState=atoi(CurrentPseudoAtom.OxidationStateString); } else if(i==CifBlockData[ATOM_SITE_FRACT_X]) { if(sscanf(keyword,"%lf",&pos.x)==0) PositionDefined=FALSE; if(Framework[CurrentSystem].RestrictFrameworkAtomsToBox) { pos.x-=(REAL)NINT(pos.x); if(pos.x<0) pos.x+=1.0; } CurrentAsymmetricAtom.Position.x=pos.x; } else if(i==CifBlockData[ATOM_SITE_FRACT_Y]) { if(sscanf(keyword,"%lf",&pos.y)==0) PositionDefined=FALSE; if(Framework[CurrentSystem].RestrictFrameworkAtomsToBox) { pos.y-=(REAL)NINT(pos.y); if(pos.y<0) pos.y+=1.0; } CurrentAsymmetricAtom.Position.y=pos.y; } else if(i==CifBlockData[ATOM_SITE_FRACT_Z]) { if(sscanf(keyword,"%lf",&pos.z)==0) PositionDefined=FALSE; if(Framework[CurrentSystem].RestrictFrameworkAtomsToBox) { pos.z-=(REAL)NINT(pos.z); if(pos.z<0) pos.z+=1.0; } CurrentAsymmetricAtom.Position.z=pos.z; } else if(i==CifBlockData[ATOM_SITE_CHARGE]) { if(UseChargesFromCIFFile) { // set the charge to the asymmetric atom and to the pseudo-atom sscanf(keyword,"%lf",&CurrentAsymmetricAtom.Charge); CurrentPseudoAtom.Charge1=CurrentAsymmetricAtom.Charge; CurrentPseudoAtom.ChargeDefinitionType=CHARGE_ATOM_FROM_STRUCTURE_FILE; } } else if(i==CifBlockData[ATOM_SITE_POLARIZATION]) { sscanf(keyword,"%lf",&tempd); CurrentPseudoAtom.Polarization.ax=tempd; CurrentPseudoAtom.Polarization.by=tempd; CurrentPseudoAtom.Polarization.cz=tempd; } else if(i==CifBlockData[ATOM_SITE_ANISOTROPIC_TYPE]) { if(strncmp(keyword,"relative",MAX2(strlen(keyword),strlen("relative")))==0) CurrentPseudoAtom.AnisotropicType=RELATIVE; if(strncmp(keyword,"absolute",MAX2(strlen(keyword),strlen("absolute")))==0) CurrentPseudoAtom.AnisotropicType=ABSOLUTE; } else if(i==CifBlockData[ATOM_SITE_ANISOTROPIC_DISPLACEMENT]) { sscanf(keyword,"%lf",&CurrentPseudoAtom.AnisotropicDisplacement); } else if(i==CifBlockData[ATOM_SITE_PRINT_TO_PDB]) { if(strncmp(keyword,"yes",MAX2(strlen(keyword),strlen("yes")))==0) CurrentPseudoAtom.PrintToPDB=TRUE; if(strncmp(keyword,"no",MAX2(strlen(keyword),strlen("no")))==0) CurrentPseudoAtom.PrintToPDB=FALSE; } else if(i==CifBlockData[ATOM_SITE_U_ISO_OR_EQUIV]) { } else if(i==CifBlockData[ATOM_SITE_THERMAL_DISPLACE_TYPE]) { } else if(i==CifBlockData[ATOM_SITE_ADP_TYPE]) { } else if(i==CifBlockData[ATOM_SITE_OCCUPANCY]) { } else if(i==CifBlockData[ATOM_SITE_SYMMETRY_MULTIPLICITY]) { } else if(i==CifBlockData[ATOM_SITE_CALC_FLAG]) { } else if(i==CifBlockData[ATOM_SITE_REFINEMENT_FLAG]) { } else if(i==CifBlockData[ATOM_SITE_DISORDER_ASSEMBLY]) { } else if(i==CifBlockData[ATOM_SITE_DISORDER_GROUP]) { } else if(i==CifBlockData[ATOM_SITE_ANISO_LABEL]) { } else if(i==CifBlockData[ATOM_SITE_ANISO_U_11]) { } else if(i==CifBlockData[ATOM_SITE_ANISO_U_22]) { } else if(i==CifBlockData[ATOM_SITE_ANISO_U_33]) { } else if(i==CifBlockData[ATOM_SITE_ANISO_U_23]) { } else if(i==CifBlockData[ATOM_SITE_ANISO_U_13]) { } else if(i==CifBlockData[ATOM_SITE_ANISO_U_12]) { } else if(i==CifBlockData[ATOM_SITE_HYBRIDIZATION]) { if(strncmp(keyword,"sp3",MAX2(strlen(keyword),strlen("sp3")))==0) CurrentPseudoAtom.Hybridization=SP3; if(strncmp(keyword,"sp2",MAX2(strlen(keyword),strlen("sp2")))==0) CurrentPseudoAtom.Hybridization=SP2; if(strncmp(keyword,"sp1",MAX2(strlen(keyword),strlen("sp1")))==0) CurrentPseudoAtom.Hybridization=SP; if(strncmp(keyword,"sp",MAX2(strlen(keyword),strlen("sp")))==0) CurrentPseudoAtom.Hybridization=SP; } else fprintf(stderr, "unknown: %s\n",keyword); } if(sscanf(arg_pointer,"%s%n",keyword,&n)==1) fprintf(stderr, "Warning Too many data items found in loop_ _atom_site_, excess data ignored\n"); // _atom_site_type_symbol not set, get symbol from _atom_site_label component 0 if(strlen(CurrentPseudoAtom.ChemicalElement)==0) { sscanf(CurrentPseudoAtom.Name,"%[a-zA-Z]",CurrentPseudoAtom.ChemicalElement); strcpy(CurrentPseudoAtom.PrintToPDBName,CurrentPseudoAtom.ChemicalElement); } // no label-name set for the atom if(strlen(CurrentPseudoAtom.Name)==0) { sscanf(CurrentPseudoAtom.ChemicalElement,"%[a-zA-Z]",CurrentPseudoAtom.Name); strcpy(CurrentPseudoAtom.PrintToPDBName,CurrentPseudoAtom.Name); } // chemical element set, remove oxidation state to get element for use in pdb sscanf(CurrentPseudoAtom.ChemicalElement,"%[a-zA-Z]",CurrentPseudoAtom.PrintToPDBName); CurrentPseudoAtom.Mass=GetAtomicMass(CurrentPseudoAtom.PrintToPDBName); CurrentPseudoAtom.Radius=GetCovalentRadius(CurrentPseudoAtom.PrintToPDBName); if(CurrentPseudoAtom.Polarization.ax<1e-8) // if not yet set, look up in table CurrentPseudoAtom.Polarization.ax=GetAtomPolarization(CurrentPseudoAtom.ChemicalElement)/COULOMBIC_CONVERSION_FACTOR; if(CurrentPseudoAtom.Polarization.by<1e-8) // if not yet set, look up in table CurrentPseudoAtom.Polarization.by=GetAtomPolarization(CurrentPseudoAtom.ChemicalElement)/COULOMBIC_CONVERSION_FACTOR; if(CurrentPseudoAtom.Polarization.cz<1e-8) // if not yet set, look up in table CurrentPseudoAtom.Polarization.cz=GetAtomPolarization(CurrentPseudoAtom.ChemicalElement)/COULOMBIC_CONVERSION_FACTOR; if((!ComputePolarization)||((fabs(CurrentPseudoAtom.Polarization.ax)<1e-10)&&(fabs(CurrentPseudoAtom.Polarization.by)<1e-10)&&(fabs(CurrentPseudoAtom.Polarization.cz)<1e-10))) CurrentPseudoAtom.IsPolarizable=FALSE; else CurrentPseudoAtom.IsPolarizable=TRUE; // for polarizable atoms which have zero charge, the inclusion is still needed to // compute the electric-field at that position if((fabs(CurrentPseudoAtom.Charge1)<1e-10)&&(!CurrentPseudoAtom.IsPolarizable)) CurrentPseudoAtom.HasCharges=FALSE; else CurrentPseudoAtom.HasCharges=TRUE; if(fabs(CurrentPseudoAtom.AnisotropicDisplacement)<1e-10) CurrentPseudoAtom.AnisotropicCorrection=FALSE; else CurrentPseudoAtom.AnisotropicCorrection=TRUE; // only add when the pseudo-atom type is not yet present // this means that the 'pseudo_atoms.def' file has precedence over the cif-file settings CurrentAsymmetricAtom.Type=AddPseudoAtom(CurrentPseudoAtom); // 1) pseudo-atom already exist -> charge from the pseudo-atom to the asymmetric atom // 2) pseudo-atom from CIF is new -> the new pseudo-atom has been filled in with the charge from the cif-file // 3) if e.g. 'O2' is new, and then another 'O2' is read, then the charge is taken from CIF-file // MODIFIED !! //if((CurrentAsymmetricAtom.Type0)&&(arguments[0]!='_')) { DefinedInLoop=FALSE; RemoveQuotesAroundString(arguments); strcpy(SpaceGroup[nr_sg_elements++],arguments); } else NumberOfAtomSiteElementsInBlock++; } // check if another data name follows // if so, copy the 'arguments' to 'line' // otherwise read 'line' from the file TrimStringInPlace(arguments); if((strlen(arguments)>0)&&(arguments[0]=='_')) strcpy(line,arguments); else LoopCondition=fgets(line,MAX_CIF_LINE_SIZE,FilePtr); strcpy(keyword,""); strcpy(arguments,""); sscanf(line,"%s%[^\n]",keyword,arguments); // skip comments if(keyword[0]=='#') { strcpy(keyword,""); strcpy(arguments,""); } } // also continue when empty line while(((strncasecmp(keyword,"_symmetry_equiv_pos",strlen("_symmetry_equiv_pos"))==0)||(strlen(keyword)==0))&&LoopCondition); if(DefinedInLoop) { nr_sg_elements=0; do { // loop over data items if(strlen(keyword)>0) { arg_pointer=line; // remove spaces TrimStringInPlace(arg_pointer); for(i=0;i0)&&(arguments[0]=='_')) strcpy(line,arguments); else LoopCondition=fgets(line,MAX_CIF_LINE_SIZE,FilePtr); strcpy(keyword,""); strcpy(arguments,""); sscanf(line,"%s%[^\n]",keyword,arguments); // skip comments if(keyword[0]=='#') { strcpy(keyword,""); strcpy(arguments,""); } } while(LoopCondition); fclose(FilePtr); // Preference of finding spacegroups: Hall > Symmetry elements > HM symbol > IT number if(FoundSpaceGroupHall>=1) Framework[CurrentSystem].SpaceGroupIdentifier[CurrentFramework]=FoundSpaceGroupHall; else if(FoundSpaceGroupSymmetryElements>=1) Framework[CurrentSystem].SpaceGroupIdentifier[CurrentFramework]=FoundSpaceGroupSymmetryElements; else { if(FoundSpaceGroupHermannMauguinString>=1) Framework[CurrentSystem].SpaceGroupIdentifier[CurrentFramework]=FoundSpaceGroupHermannMauguinString; else if(FoundSpaceGroupIntTables>=1) Framework[CurrentSystem].SpaceGroupIdentifier[CurrentFramework]=FoundSpaceGroupIntTables; else { fprintf(stderr, "ERROR in cif-file: no proper space group definition found\n"); exit(0); } if(strlen(FoundSpaceGroupOption)>0) { Framework[CurrentSystem].SpaceGroupIdentifier[CurrentFramework]=AdjustForNonStandardCIFOption(Framework[CurrentSystem].SpaceGroupIdentifier[CurrentFramework],FoundSpaceGroupOption); fprintf(stderr, "After adjustement: %d\n",Framework[CurrentSystem].SpaceGroupIdentifier[CurrentFramework]); } } // convert angles from degrees to radians // determine boundary conditions from angles if(BoundaryCondition[CurrentSystem]==UNINITIALIZED_BOUNDARY_CONDITION) { SetBoundaryCondition(CurrentSystem, 0.001, 0.00001, alpha, beta, gamma, A, B, C); } AlphaAngle[CurrentSystem]=alpha*DEG2RAD; BetaAngle[CurrentSystem]=beta*DEG2RAD; GammaAngle[CurrentSystem]=gamma*DEG2RAD; UnitCellSize[CurrentSystem].x=A; UnitCellSize[CurrentSystem].y=B; UnitCellSize[CurrentSystem].z=C; // first vector UnitCellBox[CurrentSystem].ax=A; UnitCellBox[CurrentSystem].ay=0.0; UnitCellBox[CurrentSystem].az=0.0; // second vector UnitCellBox[CurrentSystem].bx=B*cos(GammaAngle[CurrentSystem]); UnitCellBox[CurrentSystem].by=B*sin(GammaAngle[CurrentSystem]); UnitCellBox[CurrentSystem].bz=0.0; // third vector tempd=(cos(AlphaAngle[CurrentSystem])-cos(GammaAngle[CurrentSystem])*cos(BetaAngle[CurrentSystem]))/sin(GammaAngle[CurrentSystem]); UnitCellBox[CurrentSystem].cx=C*cos(BetaAngle[CurrentSystem]); UnitCellBox[CurrentSystem].cy=C*tempd; UnitCellBox[CurrentSystem].cz=C*sqrt(1.0-SQR(cos(BetaAngle[CurrentSystem]))-SQR(tempd)); Invert3x3Matrix(&UnitCellBox[CurrentSystem],&InverseUnitCellBox[CurrentSystem],&det); A=(REAL)NumberOfUnitCells[CurrentSystem].x*UnitCellSize[CurrentSystem].x; B=(REAL)NumberOfUnitCells[CurrentSystem].y*UnitCellSize[CurrentSystem].y; C=(REAL)NumberOfUnitCells[CurrentSystem].z*UnitCellSize[CurrentSystem].z; tempd=(cos(AlphaAngle[CurrentSystem])-cos(GammaAngle[CurrentSystem])*cos(BetaAngle[CurrentSystem]))/sin(GammaAngle[CurrentSystem]); // first vector Box[CurrentSystem].ax=A; Box[CurrentSystem].ay=0.0; Box[CurrentSystem].az=0.0; // second vector Box[CurrentSystem].bx=B*cos(GammaAngle[CurrentSystem]); Box[CurrentSystem].by=B*sin(GammaAngle[CurrentSystem]); Box[CurrentSystem].bz=0.0; // third vector Box[CurrentSystem].cx=C*cos(BetaAngle[CurrentSystem]); Box[CurrentSystem].cy=C*tempd; Box[CurrentSystem].cz=C*sqrt(1.0-SQR(cos(BetaAngle[CurrentSystem]))-SQR(tempd)); Invert3x3Matrix(&Box[CurrentSystem],&InverseBox[CurrentSystem],&det); // calculate box-properties CellProperties(&InverseBox[CurrentSystem],&InverseBoxProperties[CurrentSystem],&det); CellProperties(&Box[CurrentSystem],&BoxProperties[CurrentSystem],&Volume[CurrentSystem]); // no charge definition found in the CIF-file, so UseChargesFromCIFFile must be set to false if(!BoolChargeDefinedInCIFFile) UseChargesFromCIFFile=FALSE; // expand asymmetric to full framework ExpandAsymmetricFrameworkToFullFramework(); if (!STREAM) { fprintf(stderr, "End reading cif-file\n"); } } void WriteFrameworkDefinitionShell(char * string) { int i; int Type; VECTOR pos; char symbol[256]; char buffer[256]; FILE *FilePtr; mkdir("Movies",S_IRWXU); for(CurrentSystem=0;CurrentSystemtm_year+1900,loctime->tm_mon+1,loctime->tm_mday); #if defined(__INTEL_COMPILER) getlogin_r(fullname,256); fprintf(FilePtr,"_audit_author_name '%s'\n",fullname); #else p=getpwuid(geteuid()); if(p) { n=strcspn(p->pw_gecos,","); memcpy(fullname,p->pw_gecos,n); fullname[n] = '\0'; fprintf(FilePtr,"_audit_author_name '%s'\n",fullname); } #endif fprintf(FilePtr,"\n"); if(Framework[CurrentSystem].NumberOfCitations[CurrentFramework]>0) { //for(i=0;i0) fprintf(FilePtr,"_citation_id %s\n",Framework[CurrentSystem].CitationInformation[CurrentFramework][0].CitationId); if(strlen(Framework[CurrentSystem].CitationInformation[CurrentFramework][0].CitationAuthorName)>0) fprintf(FilePtr,"_citation_author_name '%s'\n",Framework[CurrentSystem].CitationInformation[CurrentFramework][0].CitationAuthorName); if(strlen(Framework[CurrentSystem].CitationInformation[CurrentFramework][0].CitationCoordinateLinkage)>0) fprintf(FilePtr,"_citation_coordinate_linkage %s\n",Framework[CurrentSystem].CitationInformation[CurrentFramework][0].CitationCoordinateLinkage); if(strlen(Framework[CurrentSystem].CitationInformation[CurrentFramework][0].CitationTitle)>0) fprintf(FilePtr,"_citation_title '%s'\n",Framework[CurrentSystem].CitationInformation[CurrentFramework][0].CitationTitle); if(strlen(Framework[CurrentSystem].CitationInformation[CurrentFramework][0].CitationCountry)>0) fprintf(FilePtr,"_citation_country '%s'\n",Framework[CurrentSystem].CitationInformation[CurrentFramework][0].CitationCountry); if(strlen(Framework[CurrentSystem].CitationInformation[CurrentFramework][0].CitationJournalAbbrev)>0) fprintf(FilePtr,"_citation_journal_abbrev '%s'\n",Framework[CurrentSystem].CitationInformation[CurrentFramework][0].CitationJournalAbbrev); if(strlen(Framework[CurrentSystem].CitationInformation[CurrentFramework][0].CitationJournalVolume)>0) fprintf(FilePtr,"_citation_journal_volume %s\n",Framework[CurrentSystem].CitationInformation[CurrentFramework][0].CitationJournalVolume); if(strlen(Framework[CurrentSystem].CitationInformation[CurrentFramework][0].CitationJournalIssue)>0) fprintf(FilePtr,"_citation_journal_issue %s\n",Framework[CurrentSystem].CitationInformation[CurrentFramework][0].CitationJournalIssue); if(strlen(Framework[CurrentSystem].CitationInformation[CurrentFramework][0].CitationPageFirst)>0) fprintf(FilePtr,"_citation_page_first %s\n",Framework[CurrentSystem].CitationInformation[CurrentFramework][0].CitationPageFirst); if(strlen(Framework[CurrentSystem].CitationInformation[CurrentFramework][0].CitationPageLast)>0) fprintf(FilePtr,"_citation_page_last %s\n",Framework[CurrentSystem].CitationInformation[CurrentFramework][0].CitationPageLast); if(strlen(Framework[CurrentSystem].CitationInformation[CurrentFramework][0].CitationYear)>0) fprintf(FilePtr,"_citation_year %s\n",Framework[CurrentSystem].CitationInformation[CurrentFramework][0].CitationYear); if(strlen(Framework[CurrentSystem].CitationInformation[CurrentFramework][0].CitationJournalID_ASTM)>0) fprintf(FilePtr,"_citation_journal_ID_ASTM %s\n",Framework[CurrentSystem].CitationInformation[CurrentFramework][0].CitationJournalID_ASTM); if(strlen(Framework[CurrentSystem].CitationInformation[CurrentFramework][0].CitationJournalID_ISSN)>0) fprintf(FilePtr,"_citation_journal_ID_ISSN %s\n",Framework[CurrentSystem].CitationInformation[CurrentFramework][0].CitationJournalID_ISSN); if(strlen(Framework[CurrentSystem].CitationInformation[CurrentFramework][0].CitationBookTitle)>0) fprintf(FilePtr,"_citation_book_title '%s'\n",Framework[CurrentSystem].CitationInformation[CurrentFramework][0].CitationBookTitle); if(strlen(Framework[CurrentSystem].CitationInformation[CurrentFramework][0].CitationBookPublisher)>0) fprintf(FilePtr,"_citation_book_publisher '%s'\n",Framework[CurrentSystem].CitationInformation[CurrentFramework][0].CitationBookPublisher); if(strlen(Framework[CurrentSystem].CitationInformation[CurrentFramework][0].CitationBookID_ISBN)>0) fprintf(FilePtr,"_citation_book_ID_ISBN %s\n",Framework[CurrentSystem].CitationInformation[CurrentFramework][0].CitationBookID_ISBN); if(strlen(Framework[CurrentSystem].CitationInformation[CurrentFramework][0].CitationSpecialDetails)>0) fprintf(FilePtr,"_citation_special_details '%s'\n",Framework[CurrentSystem].CitationInformation[CurrentFramework][0].CitationSpecialDetails); fprintf(FilePtr,"\n"); } else { fprintf(FilePtr,"loop_\n"); if(strlen(Framework[CurrentSystem].CitationInformation[CurrentFramework][0].CitationId)>0) fprintf(FilePtr,"_citation_id\n"); if(strlen(Framework[CurrentSystem].CitationInformation[CurrentFramework][0].CitationAuthorName)>0) fprintf(FilePtr,"_citation_author_name\n"); if(strlen(Framework[CurrentSystem].CitationInformation[CurrentFramework][0].CitationCoordinateLinkage)>0) fprintf(FilePtr,"_citation_coordinate_linkage\n"); if(strlen(Framework[CurrentSystem].CitationInformation[CurrentFramework][0].CitationTitle)>0) fprintf(FilePtr,"_citation_title\n"); if(strlen(Framework[CurrentSystem].CitationInformation[CurrentFramework][0].CitationCountry)>0) fprintf(FilePtr,"_citation_country\n"); if(strlen(Framework[CurrentSystem].CitationInformation[CurrentFramework][0].CitationJournalAbbrev)>0) fprintf(FilePtr,"_citation_journal_abbrev\n"); if(strlen(Framework[CurrentSystem].CitationInformation[CurrentFramework][0].CitationJournalVolume)>0) fprintf(FilePtr,"_citation_journal_volume\n"); if(strlen(Framework[CurrentSystem].CitationInformation[CurrentFramework][0].CitationJournalIssue)>0) fprintf(FilePtr,"_citation_journal_issue\n"); if(strlen(Framework[CurrentSystem].CitationInformation[CurrentFramework][0].CitationPageFirst)>0) fprintf(FilePtr,"_citation_page_first\n"); if(strlen(Framework[CurrentSystem].CitationInformation[CurrentFramework][0].CitationPageLast)>0) fprintf(FilePtr,"_citation_page_last\n"); if(strlen(Framework[CurrentSystem].CitationInformation[CurrentFramework][0].CitationYear)>0) fprintf(FilePtr,"_citation_year\n"); if(strlen(Framework[CurrentSystem].CitationInformation[CurrentFramework][0].CitationJournalID_ASTM)>0) fprintf(FilePtr,"_citation_journal_ID_ASTM\n"); if(strlen(Framework[CurrentSystem].CitationInformation[CurrentFramework][0].CitationJournalID_ISSN)>0) fprintf(FilePtr,"_citation_journal_ID_ISSN\n"); if(strlen(Framework[CurrentSystem].CitationInformation[CurrentFramework][0].CitationBookTitle)>0) fprintf(FilePtr,"_citation_book_title\n"); if(strlen(Framework[CurrentSystem].CitationInformation[CurrentFramework][0].CitationBookPublisher)>0) fprintf(FilePtr,"_citation_book_publisher\n"); if(strlen(Framework[CurrentSystem].CitationInformation[CurrentFramework][0].CitationBookID_ISBN)>0) fprintf(FilePtr,"_citation_book_ID_ISBN\n"); if(strlen(Framework[CurrentSystem].CitationInformation[CurrentFramework][0].CitationSpecialDetails)>0) fprintf(FilePtr,"_citation_special_details\n"); for(i=0;i0) fprintf(FilePtr,"%s\n",Framework[CurrentSystem].CitationInformation[CurrentFramework][i].CitationId); if(strlen(Framework[CurrentSystem].CitationInformation[CurrentFramework][i].CitationAuthorName)>0) fprintf(FilePtr,"'%s'\n",Framework[CurrentSystem].CitationInformation[CurrentFramework][i].CitationAuthorName); if(strlen(Framework[CurrentSystem].CitationInformation[CurrentFramework][i].CitationCoordinateLinkage)>0) fprintf(FilePtr,"%s\n",Framework[CurrentSystem].CitationInformation[CurrentFramework][i].CitationCoordinateLinkage); if(strlen(Framework[CurrentSystem].CitationInformation[CurrentFramework][i].CitationTitle)>0) fprintf(FilePtr,"'%s'\n",Framework[CurrentSystem].CitationInformation[CurrentFramework][i].CitationTitle); if(strlen(Framework[CurrentSystem].CitationInformation[CurrentFramework][i].CitationCountry)>0) fprintf(FilePtr,"'%s'\n",Framework[CurrentSystem].CitationInformation[CurrentFramework][i].CitationCountry); if(strlen(Framework[CurrentSystem].CitationInformation[CurrentFramework][i].CitationJournalAbbrev)>0) fprintf(FilePtr,"'%s'\n",Framework[CurrentSystem].CitationInformation[CurrentFramework][i].CitationJournalAbbrev); if(strlen(Framework[CurrentSystem].CitationInformation[CurrentFramework][i].CitationJournalVolume)>0) fprintf(FilePtr,"%s\n",Framework[CurrentSystem].CitationInformation[CurrentFramework][i].CitationJournalVolume); if(strlen(Framework[CurrentSystem].CitationInformation[CurrentFramework][i].CitationJournalIssue)>0) fprintf(FilePtr,"%s\n",Framework[CurrentSystem].CitationInformation[CurrentFramework][i].CitationJournalIssue); if(strlen(Framework[CurrentSystem].CitationInformation[CurrentFramework][i].CitationPageFirst)>0) fprintf(FilePtr,"%s\n",Framework[CurrentSystem].CitationInformation[CurrentFramework][i].CitationPageFirst); if(strlen(Framework[CurrentSystem].CitationInformation[CurrentFramework][i].CitationPageLast)>0) fprintf(FilePtr,"%s\n",Framework[CurrentSystem].CitationInformation[CurrentFramework][i].CitationPageLast); if(strlen(Framework[CurrentSystem].CitationInformation[CurrentFramework][i].CitationYear)>0) fprintf(FilePtr,"%s\n",Framework[CurrentSystem].CitationInformation[CurrentFramework][i].CitationYear); if(strlen(Framework[CurrentSystem].CitationInformation[CurrentFramework][i].CitationJournalID_ASTM)>0) fprintf(FilePtr,"%s\n",Framework[CurrentSystem].CitationInformation[CurrentFramework][i].CitationJournalID_ASTM); if(strlen(Framework[CurrentSystem].CitationInformation[CurrentFramework][i].CitationJournalID_ISSN)>0) fprintf(FilePtr,"%s\n",Framework[CurrentSystem].CitationInformation[CurrentFramework][i].CitationJournalID_ISSN); if(strlen(Framework[CurrentSystem].CitationInformation[CurrentFramework][i].CitationBookTitle)>0) fprintf(FilePtr,"'%s'\n",Framework[CurrentSystem].CitationInformation[CurrentFramework][i].CitationBookTitle); if(strlen(Framework[CurrentSystem].CitationInformation[CurrentFramework][i].CitationBookPublisher)>0) fprintf(FilePtr,"'%s'\n",Framework[CurrentSystem].CitationInformation[CurrentFramework][i].CitationBookPublisher); if(strlen(Framework[CurrentSystem].CitationInformation[CurrentFramework][i].CitationBookID_ISBN)>0) fprintf(FilePtr,"%s\n",Framework[CurrentSystem].CitationInformation[CurrentFramework][i].CitationBookID_ISBN); if(strlen(Framework[CurrentSystem].CitationInformation[CurrentFramework][i].CitationSpecialDetails)>0) fprintf(FilePtr,"'%s'\n",Framework[CurrentSystem].CitationInformation[CurrentFramework][i].CitationSpecialDetails); } fprintf(FilePtr,"\n"); } } fprintf(FilePtr,"_cell_length_a %g\n",BoxProperties[CurrentSystem].ax/(REAL)NumberOfUnitCells[CurrentSystem].x); fprintf(FilePtr,"_cell_length_b %g\n",BoxProperties[CurrentSystem].ay/(REAL)NumberOfUnitCells[CurrentSystem].y); fprintf(FilePtr,"_cell_length_c %g\n",BoxProperties[CurrentSystem].az/(REAL)NumberOfUnitCells[CurrentSystem].z); fprintf(FilePtr,"_cell_angle_alpha %g\n",(REAL)AlphaAngle[CurrentSystem]*RAD2DEG); fprintf(FilePtr,"_cell_angle_beta %g\n",(REAL)BetaAngle[CurrentSystem]*RAD2DEG); fprintf(FilePtr,"_cell_angle_gamma %g\n",(REAL)GammaAngle[CurrentSystem]*RAD2DEG); fprintf(FilePtr,"_cell_volume %g\n\n",(REAL)Volume[CurrentSystem]); switch(SpaceGroupData[Framework[CurrentSystem].SpaceGroupIdentifier[CurrentFramework]].CrystalSystem) { case TRICLINIC_SPACEGROUP: fprintf(FilePtr,"_symmetry_cell_setting triclinic\n"); break; case MONOCLINIC_SPACEGROUP: fprintf(FilePtr,"_symmetry_cell_setting monoclinic\n"); break; case ORTHORHOMBIC_SPACEGROUP: fprintf(FilePtr,"_symmetry_cell_setting orthorhombic\n"); break; case TETRAGONAL_SPACEGROUP: fprintf(FilePtr,"_symmetry_cell_setting tetragonal\n"); break; case TRIGONAL_SPACEGROUP: fprintf(FilePtr,"_symmetry_cell_setting trigonal\n"); break; case HEXAGONAL_SPACEGROUP: fprintf(FilePtr,"_symmetry_cell_setting hexagonal\n"); break; case CUBIC_SPACEGROUP: fprintf(FilePtr,"_symmetry_cell_setting cubic\n"); break; } fprintf(FilePtr,"_symmetry_space_group_name_Hall '%s'\n",SpaceGroupData[1].HallSpaceGroupSymbol); fprintf(FilePtr,"_symmetry_space_group_name_H-M '%s'\n",SpaceGroupData[1].ShortInternationalHermannMauguinSpaceGroupSymbol); fprintf(FilePtr,"_symmetry_Int_Tables_number %d\n\n",SpaceGroupData[1].Number); fprintf(FilePtr,"_symmetry_equiv_pos_as_xyz 'x,y,z'\n"); fprintf(FilePtr,"\n"); fprintf(FilePtr,"loop_\n"); fprintf(FilePtr,"_atom_site_label\n"); fprintf(FilePtr,"_atom_site_type_symbol\n"); fprintf(FilePtr,"_atom_site_fract_x\n"); fprintf(FilePtr,"_atom_site_fract_y\n"); fprintf(FilePtr,"_atom_site_fract_z\n"); fprintf(FilePtr,"_atom_site_charge\n"); for(i=0;itm_year+1900,loctime->tm_mon+1,loctime->tm_mday); #if defined(__INTEL_COMPILER) getlogin_r(fullname,256); fprintf(FilePtr,"_audit_author_name '%s'\n",fullname); #else p=getpwuid(geteuid()); if(p) { n=strcspn(p->pw_gecos,","); memcpy(fullname,p->pw_gecos,n); fullname[n] = '\0'; fprintf(FilePtr,"_audit_author_name '%s'\n",fullname); } #endif fprintf(FilePtr,"\n"); if(Framework[CurrentSystem].NumberOfCitations[CurrentFramework]>0) { //for(i=0;i0) fprintf(FilePtr,"_citation_id %s\n",Framework[CurrentSystem].CitationInformation[CurrentFramework][0].CitationId); if(strlen(Framework[CurrentSystem].CitationInformation[CurrentFramework][0].CitationAuthorName)>0) fprintf(FilePtr,"_citation_author_name '%s'\n",Framework[CurrentSystem].CitationInformation[CurrentFramework][0].CitationAuthorName); if(strlen(Framework[CurrentSystem].CitationInformation[CurrentFramework][0].CitationCoordinateLinkage)>0) fprintf(FilePtr,"_citation_coordinate_linkage %s\n",Framework[CurrentSystem].CitationInformation[CurrentFramework][0].CitationCoordinateLinkage); if(strlen(Framework[CurrentSystem].CitationInformation[CurrentFramework][0].CitationTitle)>0) fprintf(FilePtr,"_citation_title '%s'\n",Framework[CurrentSystem].CitationInformation[CurrentFramework][0].CitationTitle); if(strlen(Framework[CurrentSystem].CitationInformation[CurrentFramework][0].CitationCountry)>0) fprintf(FilePtr,"_citation_country '%s'\n",Framework[CurrentSystem].CitationInformation[CurrentFramework][0].CitationCountry); if(strlen(Framework[CurrentSystem].CitationInformation[CurrentFramework][0].CitationJournalAbbrev)>0) fprintf(FilePtr,"_citation_journal_abbrev '%s'\n",Framework[CurrentSystem].CitationInformation[CurrentFramework][0].CitationJournalAbbrev); if(strlen(Framework[CurrentSystem].CitationInformation[CurrentFramework][0].CitationJournalVolume)>0) fprintf(FilePtr,"_citation_journal_volume %s\n",Framework[CurrentSystem].CitationInformation[CurrentFramework][0].CitationJournalVolume); if(strlen(Framework[CurrentSystem].CitationInformation[CurrentFramework][0].CitationJournalIssue)>0) fprintf(FilePtr,"_citation_journal_issue %s\n",Framework[CurrentSystem].CitationInformation[CurrentFramework][0].CitationJournalIssue); if(strlen(Framework[CurrentSystem].CitationInformation[CurrentFramework][0].CitationPageFirst)>0) fprintf(FilePtr,"_citation_page_first %s\n",Framework[CurrentSystem].CitationInformation[CurrentFramework][0].CitationPageFirst); if(strlen(Framework[CurrentSystem].CitationInformation[CurrentFramework][0].CitationPageLast)>0) fprintf(FilePtr,"_citation_page_last %s\n",Framework[CurrentSystem].CitationInformation[CurrentFramework][0].CitationPageLast); if(strlen(Framework[CurrentSystem].CitationInformation[CurrentFramework][0].CitationYear)>0) fprintf(FilePtr,"_citation_year %s\n",Framework[CurrentSystem].CitationInformation[CurrentFramework][0].CitationYear); if(strlen(Framework[CurrentSystem].CitationInformation[CurrentFramework][0].CitationJournalID_ASTM)>0) fprintf(FilePtr,"_citation_journal_ID_ASTM %s\n",Framework[CurrentSystem].CitationInformation[CurrentFramework][0].CitationJournalID_ASTM); if(strlen(Framework[CurrentSystem].CitationInformation[CurrentFramework][0].CitationJournalID_ISSN)>0) fprintf(FilePtr,"_citation_journal_ID_ISSN %s\n",Framework[CurrentSystem].CitationInformation[CurrentFramework][0].CitationJournalID_ISSN); if(strlen(Framework[CurrentSystem].CitationInformation[CurrentFramework][0].CitationBookTitle)>0) fprintf(FilePtr,"_citation_book_title '%s'\n",Framework[CurrentSystem].CitationInformation[CurrentFramework][0].CitationBookTitle); if(strlen(Framework[CurrentSystem].CitationInformation[CurrentFramework][0].CitationBookPublisher)>0) fprintf(FilePtr,"_citation_book_publisher '%s'\n",Framework[CurrentSystem].CitationInformation[CurrentFramework][0].CitationBookPublisher); if(strlen(Framework[CurrentSystem].CitationInformation[CurrentFramework][0].CitationBookID_ISBN)>0) fprintf(FilePtr,"_citation_book_ID_ISBN %s\n",Framework[CurrentSystem].CitationInformation[CurrentFramework][0].CitationBookID_ISBN); if(strlen(Framework[CurrentSystem].CitationInformation[CurrentFramework][0].CitationSpecialDetails)>0) fprintf(FilePtr,"_citation_special_details '%s'\n",Framework[CurrentSystem].CitationInformation[CurrentFramework][0].CitationSpecialDetails); fprintf(FilePtr,"\n"); } else { fprintf(FilePtr,"loop_\n"); if(strlen(Framework[CurrentSystem].CitationInformation[CurrentFramework][0].CitationId)>0) fprintf(FilePtr,"_citation_id\n"); if(strlen(Framework[CurrentSystem].CitationInformation[CurrentFramework][0].CitationAuthorName)>0) fprintf(FilePtr,"_citation_author_name\n"); if(strlen(Framework[CurrentSystem].CitationInformation[CurrentFramework][0].CitationCoordinateLinkage)>0) fprintf(FilePtr,"_citation_coordinate_linkage\n"); if(strlen(Framework[CurrentSystem].CitationInformation[CurrentFramework][0].CitationTitle)>0) fprintf(FilePtr,"_citation_title\n"); if(strlen(Framework[CurrentSystem].CitationInformation[CurrentFramework][0].CitationCountry)>0) fprintf(FilePtr,"_citation_country\n"); if(strlen(Framework[CurrentSystem].CitationInformation[CurrentFramework][0].CitationJournalAbbrev)>0) fprintf(FilePtr,"_citation_journal_abbrev\n"); if(strlen(Framework[CurrentSystem].CitationInformation[CurrentFramework][0].CitationJournalVolume)>0) fprintf(FilePtr,"_citation_journal_volume\n"); if(strlen(Framework[CurrentSystem].CitationInformation[CurrentFramework][0].CitationJournalIssue)>0) fprintf(FilePtr,"_citation_journal_issue\n"); if(strlen(Framework[CurrentSystem].CitationInformation[CurrentFramework][0].CitationPageFirst)>0) fprintf(FilePtr,"_citation_page_first\n"); if(strlen(Framework[CurrentSystem].CitationInformation[CurrentFramework][0].CitationPageLast)>0) fprintf(FilePtr,"_citation_page_last\n"); if(strlen(Framework[CurrentSystem].CitationInformation[CurrentFramework][0].CitationYear)>0) fprintf(FilePtr,"_citation_year\n"); if(strlen(Framework[CurrentSystem].CitationInformation[CurrentFramework][0].CitationJournalID_ASTM)>0) fprintf(FilePtr,"_citation_journal_ID_ASTM\n"); if(strlen(Framework[CurrentSystem].CitationInformation[CurrentFramework][0].CitationJournalID_ISSN)>0) fprintf(FilePtr,"_citation_journal_ID_ISSN\n"); if(strlen(Framework[CurrentSystem].CitationInformation[CurrentFramework][0].CitationBookTitle)>0) fprintf(FilePtr,"_citation_book_title\n"); if(strlen(Framework[CurrentSystem].CitationInformation[CurrentFramework][0].CitationBookPublisher)>0) fprintf(FilePtr,"_citation_book_publisher\n"); if(strlen(Framework[CurrentSystem].CitationInformation[CurrentFramework][0].CitationBookID_ISBN)>0) fprintf(FilePtr,"_citation_book_ID_ISBN\n"); if(strlen(Framework[CurrentSystem].CitationInformation[CurrentFramework][0].CitationSpecialDetails)>0) fprintf(FilePtr,"_citation_special_details\n"); for(i=0;i0) fprintf(FilePtr,"%s\n",Framework[CurrentSystem].CitationInformation[CurrentFramework][i].CitationId); if(strlen(Framework[CurrentSystem].CitationInformation[CurrentFramework][i].CitationAuthorName)>0) fprintf(FilePtr,"'%s'\n",Framework[CurrentSystem].CitationInformation[CurrentFramework][i].CitationAuthorName); if(strlen(Framework[CurrentSystem].CitationInformation[CurrentFramework][i].CitationCoordinateLinkage)>0) fprintf(FilePtr,"%s\n",Framework[CurrentSystem].CitationInformation[CurrentFramework][i].CitationCoordinateLinkage); if(strlen(Framework[CurrentSystem].CitationInformation[CurrentFramework][i].CitationTitle)>0) fprintf(FilePtr,"'%s'\n",Framework[CurrentSystem].CitationInformation[CurrentFramework][i].CitationTitle); if(strlen(Framework[CurrentSystem].CitationInformation[CurrentFramework][i].CitationCountry)>0) fprintf(FilePtr,"'%s'\n",Framework[CurrentSystem].CitationInformation[CurrentFramework][i].CitationCountry); if(strlen(Framework[CurrentSystem].CitationInformation[CurrentFramework][i].CitationJournalAbbrev)>0) fprintf(FilePtr,"'%s'\n",Framework[CurrentSystem].CitationInformation[CurrentFramework][i].CitationJournalAbbrev); if(strlen(Framework[CurrentSystem].CitationInformation[CurrentFramework][i].CitationJournalVolume)>0) fprintf(FilePtr,"%s\n",Framework[CurrentSystem].CitationInformation[CurrentFramework][i].CitationJournalVolume); if(strlen(Framework[CurrentSystem].CitationInformation[CurrentFramework][i].CitationJournalIssue)>0) fprintf(FilePtr,"%s\n",Framework[CurrentSystem].CitationInformation[CurrentFramework][i].CitationJournalIssue); if(strlen(Framework[CurrentSystem].CitationInformation[CurrentFramework][i].CitationPageFirst)>0) fprintf(FilePtr,"%s\n",Framework[CurrentSystem].CitationInformation[CurrentFramework][i].CitationPageFirst); if(strlen(Framework[CurrentSystem].CitationInformation[CurrentFramework][i].CitationPageLast)>0) fprintf(FilePtr,"%s\n",Framework[CurrentSystem].CitationInformation[CurrentFramework][i].CitationPageLast); if(strlen(Framework[CurrentSystem].CitationInformation[CurrentFramework][i].CitationYear)>0) fprintf(FilePtr,"%s\n",Framework[CurrentSystem].CitationInformation[CurrentFramework][i].CitationYear); if(strlen(Framework[CurrentSystem].CitationInformation[CurrentFramework][i].CitationJournalID_ASTM)>0) fprintf(FilePtr,"%s\n",Framework[CurrentSystem].CitationInformation[CurrentFramework][i].CitationJournalID_ASTM); if(strlen(Framework[CurrentSystem].CitationInformation[CurrentFramework][i].CitationJournalID_ISSN)>0) fprintf(FilePtr,"%s\n",Framework[CurrentSystem].CitationInformation[CurrentFramework][i].CitationJournalID_ISSN); if(strlen(Framework[CurrentSystem].CitationInformation[CurrentFramework][i].CitationBookTitle)>0) fprintf(FilePtr,"'%s'\n",Framework[CurrentSystem].CitationInformation[CurrentFramework][i].CitationBookTitle); if(strlen(Framework[CurrentSystem].CitationInformation[CurrentFramework][i].CitationBookPublisher)>0) fprintf(FilePtr,"'%s'\n",Framework[CurrentSystem].CitationInformation[CurrentFramework][i].CitationBookPublisher); if(strlen(Framework[CurrentSystem].CitationInformation[CurrentFramework][i].CitationBookID_ISBN)>0) fprintf(FilePtr,"%s\n",Framework[CurrentSystem].CitationInformation[CurrentFramework][i].CitationBookID_ISBN); if(strlen(Framework[CurrentSystem].CitationInformation[CurrentFramework][i].CitationSpecialDetails)>0) fprintf(FilePtr,"'%s'\n",Framework[CurrentSystem].CitationInformation[CurrentFramework][i].CitationSpecialDetails); } fprintf(FilePtr,"\n"); } } fprintf(FilePtr,"_cell_length_a %g\n",BoxProperties[CurrentSystem].ax); fprintf(FilePtr,"_cell_length_b %g\n",BoxProperties[CurrentSystem].ay); fprintf(FilePtr,"_cell_length_c %g\n",BoxProperties[CurrentSystem].az); fprintf(FilePtr,"_cell_angle_alpha %g\n",(REAL)AlphaAngle[CurrentSystem]*RAD2DEG); fprintf(FilePtr,"_cell_angle_beta %g\n",(REAL)BetaAngle[CurrentSystem]*RAD2DEG); fprintf(FilePtr,"_cell_angle_gamma %g\n",(REAL)GammaAngle[CurrentSystem]*RAD2DEG); fprintf(FilePtr,"_cell_volume %g\n\n",(REAL)Volume[CurrentSystem]); switch(SpaceGroupData[Framework[CurrentSystem].SpaceGroupIdentifier[CurrentFramework]].CrystalSystem) { case TRICLINIC_SPACEGROUP: fprintf(FilePtr,"_symmetry_cell_setting triclinic\n"); break; case MONOCLINIC_SPACEGROUP: fprintf(FilePtr,"_symmetry_cell_setting monoclinic\n"); break; case ORTHORHOMBIC_SPACEGROUP: fprintf(FilePtr,"_symmetry_cell_setting orthorhombic\n"); break; case TETRAGONAL_SPACEGROUP: fprintf(FilePtr,"_symmetry_cell_setting tetragonal\n"); break; case TRIGONAL_SPACEGROUP: fprintf(FilePtr,"_symmetry_cell_setting trigonal\n"); break; case HEXAGONAL_SPACEGROUP: fprintf(FilePtr,"_symmetry_cell_setting hexagonal\n"); break; case CUBIC_SPACEGROUP: fprintf(FilePtr,"_symmetry_cell_setting cubic\n"); break; } fprintf(FilePtr,"_symmetry_space_group_name_Hall '%s'\n",SpaceGroupData[1].HallSpaceGroupSymbol); fprintf(FilePtr,"_symmetry_space_group_name_H-M '%s'\n",SpaceGroupData[1].ShortInternationalHermannMauguinSpaceGroupSymbol); fprintf(FilePtr,"_symmetry_Int_Tables_number %d\n\n",SpaceGroupData[1].Number); fprintf(FilePtr,"_symmetry_equiv_pos_as_xyz 'x,y,z'\n"); fprintf(FilePtr,"\n"); fprintf(FilePtr,"loop_\n"); fprintf(FilePtr,"_atom_site_label\n"); fprintf(FilePtr,"_atom_site_type_symbol\n"); fprintf(FilePtr,"_atom_site_fract_x\n"); fprintf(FilePtr,"_atom_site_fract_y\n"); fprintf(FilePtr,"_atom_site_fract_z\n"); fprintf(FilePtr,"_atom_site_charge\n"); for(i=0;i1) { sprintf(buffer,"Movies/System_%d/Framework_%d_%s_%d_%d_%d%s.cif", CurrentSystem,CurrentFramework,string,1,1,1,FileNameAppend); FilePtr=fopen(buffer,"w"); fprintf(FilePtr,"data_%s\n\n",Framework[CurrentSystem].Name[CurrentFramework]); fprintf(FilePtr,"_audit_creation_method RASPA-1.0\n"); fprintf(FilePtr,"_audit_creation_date %d-%d-%d\n",loctime->tm_year+1900,loctime->tm_mon+1,loctime->tm_mday); #if defined(__INTEL_COMPILER) getlogin_r(fullname,256); fprintf(FilePtr,"_audit_author_name '%s'\n",fullname); #else p=getpwuid(geteuid()); if(p) { n=strcspn(p->pw_gecos,","); memcpy(fullname,p->pw_gecos,n); fullname[n] = '\0'; fprintf(FilePtr,"_audit_author_name '%s'\n",fullname); } #endif fprintf(FilePtr,"\n"); if(Framework[CurrentSystem].NumberOfCitations[CurrentFramework]>0) { if(Framework[CurrentSystem].NumberOfCitations[CurrentFramework]==1) { if(strlen(Framework[CurrentSystem].CitationInformation[CurrentFramework][0].CitationId)>0) fprintf(FilePtr,"_citation_id %s\n",Framework[CurrentSystem].CitationInformation[CurrentFramework][0].CitationId); if(strlen(Framework[CurrentSystem].CitationInformation[CurrentFramework][0].CitationAuthorName)>0) fprintf(FilePtr,"_citation_author_name '%s'\n",Framework[CurrentSystem].CitationInformation[CurrentFramework][0].CitationAuthorName); if(strlen(Framework[CurrentSystem].CitationInformation[CurrentFramework][0].CitationCoordinateLinkage)>0) fprintf(FilePtr,"_citation_coordinate_linkage %s\n",Framework[CurrentSystem].CitationInformation[CurrentFramework][0].CitationCoordinateLinkage); if(strlen(Framework[CurrentSystem].CitationInformation[CurrentFramework][0].CitationTitle)>0) fprintf(FilePtr,"_citation_title '%s'\n",Framework[CurrentSystem].CitationInformation[CurrentFramework][0].CitationTitle); if(strlen(Framework[CurrentSystem].CitationInformation[CurrentFramework][0].CitationCountry)>0) fprintf(FilePtr,"_citation_country '%s'\n",Framework[CurrentSystem].CitationInformation[CurrentFramework][0].CitationCountry); if(strlen(Framework[CurrentSystem].CitationInformation[CurrentFramework][0].CitationJournalAbbrev)>0) fprintf(FilePtr,"_citation_journal_abbrev '%s'\n",Framework[CurrentSystem].CitationInformation[CurrentFramework][0].CitationJournalAbbrev); if(strlen(Framework[CurrentSystem].CitationInformation[CurrentFramework][0].CitationJournalVolume)>0) fprintf(FilePtr,"_citation_journal_volume %s\n",Framework[CurrentSystem].CitationInformation[CurrentFramework][0].CitationJournalVolume); if(strlen(Framework[CurrentSystem].CitationInformation[CurrentFramework][0].CitationJournalIssue)>0) fprintf(FilePtr,"_citation_journal_issue %s\n",Framework[CurrentSystem].CitationInformation[CurrentFramework][0].CitationJournalIssue); if(strlen(Framework[CurrentSystem].CitationInformation[CurrentFramework][0].CitationPageFirst)>0) fprintf(FilePtr,"_citation_page_first %s\n",Framework[CurrentSystem].CitationInformation[CurrentFramework][0].CitationPageFirst); if(strlen(Framework[CurrentSystem].CitationInformation[CurrentFramework][0].CitationPageLast)>0) fprintf(FilePtr,"_citation_page_last %s\n",Framework[CurrentSystem].CitationInformation[CurrentFramework][0].CitationPageLast); if(strlen(Framework[CurrentSystem].CitationInformation[CurrentFramework][0].CitationYear)>0) fprintf(FilePtr,"_citation_year %s\n",Framework[CurrentSystem].CitationInformation[CurrentFramework][0].CitationYear); if(strlen(Framework[CurrentSystem].CitationInformation[CurrentFramework][0].CitationJournalID_ASTM)>0) fprintf(FilePtr,"_citation_journal_ID_ASTM %s\n",Framework[CurrentSystem].CitationInformation[CurrentFramework][0].CitationJournalID_ASTM); if(strlen(Framework[CurrentSystem].CitationInformation[CurrentFramework][0].CitationJournalID_ISSN)>0) fprintf(FilePtr,"_citation_journal_ID_ISSN %s\n",Framework[CurrentSystem].CitationInformation[CurrentFramework][0].CitationJournalID_ISSN); if(strlen(Framework[CurrentSystem].CitationInformation[CurrentFramework][0].CitationBookTitle)>0) fprintf(FilePtr,"_citation_book_title '%s'\n",Framework[CurrentSystem].CitationInformation[CurrentFramework][0].CitationBookTitle); if(strlen(Framework[CurrentSystem].CitationInformation[CurrentFramework][0].CitationBookPublisher)>0) fprintf(FilePtr,"_citation_book_publisher '%s'\n",Framework[CurrentSystem].CitationInformation[CurrentFramework][0].CitationBookPublisher); if(strlen(Framework[CurrentSystem].CitationInformation[CurrentFramework][0].CitationBookID_ISBN)>0) fprintf(FilePtr,"_citation_book_ID_ISBN %s\n",Framework[CurrentSystem].CitationInformation[CurrentFramework][0].CitationBookID_ISBN); if(strlen(Framework[CurrentSystem].CitationInformation[CurrentFramework][0].CitationSpecialDetails)>0) fprintf(FilePtr,"_citation_special_details '%s'\n",Framework[CurrentSystem].CitationInformation[CurrentFramework][0].CitationSpecialDetails); fprintf(FilePtr,"\n"); } else { fprintf(FilePtr,"loop_\n"); if(strlen(Framework[CurrentSystem].CitationInformation[CurrentFramework][0].CitationId)>0) fprintf(FilePtr,"_citation_id\n"); if(strlen(Framework[CurrentSystem].CitationInformation[CurrentFramework][0].CitationAuthorName)>0) fprintf(FilePtr,"_citation_author_name\n"); if(strlen(Framework[CurrentSystem].CitationInformation[CurrentFramework][0].CitationCoordinateLinkage)>0) fprintf(FilePtr,"_citation_coordinate_linkage\n"); if(strlen(Framework[CurrentSystem].CitationInformation[CurrentFramework][0].CitationTitle)>0) fprintf(FilePtr,"_citation_title\n"); if(strlen(Framework[CurrentSystem].CitationInformation[CurrentFramework][0].CitationCountry)>0) fprintf(FilePtr,"_citation_country\n"); if(strlen(Framework[CurrentSystem].CitationInformation[CurrentFramework][0].CitationJournalAbbrev)>0) fprintf(FilePtr,"_citation_journal_abbrev\n"); if(strlen(Framework[CurrentSystem].CitationInformation[CurrentFramework][0].CitationJournalVolume)>0) fprintf(FilePtr,"_citation_journal_volume\n"); if(strlen(Framework[CurrentSystem].CitationInformation[CurrentFramework][0].CitationJournalIssue)>0) fprintf(FilePtr,"_citation_journal_issue\n"); if(strlen(Framework[CurrentSystem].CitationInformation[CurrentFramework][0].CitationPageFirst)>0) fprintf(FilePtr,"_citation_page_first\n"); if(strlen(Framework[CurrentSystem].CitationInformation[CurrentFramework][0].CitationPageLast)>0) fprintf(FilePtr,"_citation_page_last\n"); if(strlen(Framework[CurrentSystem].CitationInformation[CurrentFramework][0].CitationYear)>0) fprintf(FilePtr,"_citation_year\n"); if(strlen(Framework[CurrentSystem].CitationInformation[CurrentFramework][0].CitationJournalID_ASTM)>0) fprintf(FilePtr,"_citation_journal_ID_ASTM\n"); if(strlen(Framework[CurrentSystem].CitationInformation[CurrentFramework][0].CitationJournalID_ISSN)>0) fprintf(FilePtr,"_citation_journal_ID_ISSN\n"); if(strlen(Framework[CurrentSystem].CitationInformation[CurrentFramework][0].CitationBookTitle)>0) fprintf(FilePtr,"_citation_book_title\n"); if(strlen(Framework[CurrentSystem].CitationInformation[CurrentFramework][0].CitationBookPublisher)>0) fprintf(FilePtr,"_citation_book_publisher\n"); if(strlen(Framework[CurrentSystem].CitationInformation[CurrentFramework][0].CitationBookID_ISBN)>0) fprintf(FilePtr,"_citation_book_ID_ISBN\n"); if(strlen(Framework[CurrentSystem].CitationInformation[CurrentFramework][0].CitationSpecialDetails)>0) fprintf(FilePtr,"_citation_special_details\n"); for(i=0;i0) fprintf(FilePtr,"%s\n",Framework[CurrentSystem].CitationInformation[CurrentFramework][i].CitationId); if(strlen(Framework[CurrentSystem].CitationInformation[CurrentFramework][i].CitationAuthorName)>0) fprintf(FilePtr,"'%s'\n",Framework[CurrentSystem].CitationInformation[CurrentFramework][i].CitationAuthorName); if(strlen(Framework[CurrentSystem].CitationInformation[CurrentFramework][i].CitationCoordinateLinkage)>0) fprintf(FilePtr,"%s\n",Framework[CurrentSystem].CitationInformation[CurrentFramework][i].CitationCoordinateLinkage); if(strlen(Framework[CurrentSystem].CitationInformation[CurrentFramework][i].CitationTitle)>0) fprintf(FilePtr,"'%s'\n",Framework[CurrentSystem].CitationInformation[CurrentFramework][i].CitationTitle); if(strlen(Framework[CurrentSystem].CitationInformation[CurrentFramework][i].CitationCountry)>0) fprintf(FilePtr,"'%s'\n",Framework[CurrentSystem].CitationInformation[CurrentFramework][i].CitationCountry); if(strlen(Framework[CurrentSystem].CitationInformation[CurrentFramework][i].CitationJournalAbbrev)>0) fprintf(FilePtr,"'%s'\n",Framework[CurrentSystem].CitationInformation[CurrentFramework][i].CitationJournalAbbrev); if(strlen(Framework[CurrentSystem].CitationInformation[CurrentFramework][i].CitationJournalVolume)>0) fprintf(FilePtr,"%s\n",Framework[CurrentSystem].CitationInformation[CurrentFramework][i].CitationJournalVolume); if(strlen(Framework[CurrentSystem].CitationInformation[CurrentFramework][i].CitationJournalIssue)>0) fprintf(FilePtr,"%s\n",Framework[CurrentSystem].CitationInformation[CurrentFramework][i].CitationJournalIssue); if(strlen(Framework[CurrentSystem].CitationInformation[CurrentFramework][i].CitationPageFirst)>0) fprintf(FilePtr,"%s\n",Framework[CurrentSystem].CitationInformation[CurrentFramework][i].CitationPageFirst); if(strlen(Framework[CurrentSystem].CitationInformation[CurrentFramework][i].CitationPageLast)>0) fprintf(FilePtr,"%s\n",Framework[CurrentSystem].CitationInformation[CurrentFramework][i].CitationPageLast); if(strlen(Framework[CurrentSystem].CitationInformation[CurrentFramework][i].CitationYear)>0) fprintf(FilePtr,"%s\n",Framework[CurrentSystem].CitationInformation[CurrentFramework][i].CitationYear); if(strlen(Framework[CurrentSystem].CitationInformation[CurrentFramework][i].CitationJournalID_ASTM)>0) fprintf(FilePtr,"%s\n",Framework[CurrentSystem].CitationInformation[CurrentFramework][i].CitationJournalID_ASTM); if(strlen(Framework[CurrentSystem].CitationInformation[CurrentFramework][i].CitationJournalID_ISSN)>0) fprintf(FilePtr,"%s\n",Framework[CurrentSystem].CitationInformation[CurrentFramework][i].CitationJournalID_ISSN); if(strlen(Framework[CurrentSystem].CitationInformation[CurrentFramework][i].CitationBookTitle)>0) fprintf(FilePtr,"'%s'\n",Framework[CurrentSystem].CitationInformation[CurrentFramework][i].CitationBookTitle); if(strlen(Framework[CurrentSystem].CitationInformation[CurrentFramework][i].CitationBookPublisher)>0) fprintf(FilePtr,"'%s'\n",Framework[CurrentSystem].CitationInformation[CurrentFramework][i].CitationBookPublisher); if(strlen(Framework[CurrentSystem].CitationInformation[CurrentFramework][i].CitationBookID_ISBN)>0) fprintf(FilePtr,"%s\n",Framework[CurrentSystem].CitationInformation[CurrentFramework][i].CitationBookID_ISBN); if(strlen(Framework[CurrentSystem].CitationInformation[CurrentFramework][i].CitationSpecialDetails)>0) fprintf(FilePtr,"'%s'\n",Framework[CurrentSystem].CitationInformation[CurrentFramework][i].CitationSpecialDetails); } fprintf(FilePtr,"\n"); } } fprintf(FilePtr,"_cell_length_a %g\n",UnitCellSize[CurrentSystem].x); fprintf(FilePtr,"_cell_length_b %g\n",UnitCellSize[CurrentSystem].y); fprintf(FilePtr,"_cell_length_c %g\n",UnitCellSize[CurrentSystem].z); fprintf(FilePtr,"_cell_angle_alpha %g\n",(REAL)AlphaAngle[CurrentSystem]*RAD2DEG); fprintf(FilePtr,"_cell_angle_beta %g\n",(REAL)BetaAngle[CurrentSystem]*RAD2DEG); fprintf(FilePtr,"_cell_angle_gamma %g\n",(REAL)GammaAngle[CurrentSystem]*RAD2DEG); fprintf(FilePtr,"_cell_volume %g\n\n",(REAL)Volume[CurrentSystem]); switch(SpaceGroupData[Framework[CurrentSystem].SpaceGroupIdentifier[CurrentFramework]].CrystalSystem) { case TRICLINIC_SPACEGROUP: fprintf(FilePtr,"_symmetry_cell_setting triclinic\n"); break; case MONOCLINIC_SPACEGROUP: fprintf(FilePtr,"_symmetry_cell_setting monoclinic\n"); break; case ORTHORHOMBIC_SPACEGROUP: fprintf(FilePtr,"_symmetry_cell_setting orthorhombic\n"); break; case TETRAGONAL_SPACEGROUP: fprintf(FilePtr,"_symmetry_cell_setting tetragonal\n"); break; case TRIGONAL_SPACEGROUP: fprintf(FilePtr,"_symmetry_cell_setting trigonal\n"); break; case HEXAGONAL_SPACEGROUP: fprintf(FilePtr,"_symmetry_cell_setting hexagonal\n"); break; case CUBIC_SPACEGROUP: fprintf(FilePtr,"_symmetry_cell_setting cubic\n"); break; } fprintf(FilePtr,"_symmetry_space_group_name_Hall '%s'\n",SpaceGroupData[Framework[CurrentSystem].SpaceGroupIdentifier[CurrentFramework]].HallSpaceGroupSymbol); // remove ":1", ":2", ":h" or ":r" from the short HM space group symbol sscanf(SpaceGroupData[Framework[CurrentSystem].SpaceGroupIdentifier[CurrentFramework]].ShortInternationalHermannMauguinSpaceGroupSymbol,"%[^:]%*[^\n]",buffer); fprintf(FilePtr,"_symmetry_space_group_name_H-M '%s'\n",buffer); fprintf(FilePtr,"_symmetry_Int_Tables_number %d\n\n",SpaceGroupData[Framework[CurrentSystem].SpaceGroupIdentifier[CurrentFramework]].Number); // printf _symmetry_equiv_pos_as_xyz for all space groups that have different origins // for these space groups, the H-M symbol is not sufficient to uniquely set the spacegroup fprintf(FilePtr,"loop_\n"); fprintf(FilePtr,"_symmetry_equiv_pos_as_xyz\n"); for(j=0;j1e-10) { Framework[CurrentSystem].NumberOfCharges[CurrentFramework]++; Framework[CurrentSystem].TotalNumberOfCharges++; } } // skip the 4 lines fscanf(FilePtr,"%[^\n]",buffer); fscanf(FilePtr,"%[^\n]",buffer); fscanf(FilePtr,"%[^\n]",buffer); fscanf(FilePtr,"%[^\n]",buffer); // read unit cell size fscanf(FilePtr,"%lf %lf %lf%*[^\n]\n",&tempx,&tempy,&tempz); UnitCellSize[CurrentSystem].x=(REAL)tempx; UnitCellSize[CurrentSystem].y=(REAL)tempy; UnitCellSize[CurrentSystem].z=(REAL)tempz; A=(REAL)NumberOfUnitCells[CurrentSystem].x*UnitCellSize[CurrentSystem].x; B=(REAL)NumberOfUnitCells[CurrentSystem].y*UnitCellSize[CurrentSystem].y; C=(REAL)NumberOfUnitCells[CurrentSystem].z*UnitCellSize[CurrentSystem].z; // read cell angles and convert to radians fscanf(FilePtr,"%lf %lf %lf%*[^\n]",&tempx,&tempy,&tempz); AlphaAngle[CurrentSystem]=tempx; BetaAngle[CurrentSystem]=tempy; GammaAngle[CurrentSystem]=tempz; if(BoundaryCondition[CurrentSystem]==UNINITIALIZED_BOUNDARY_CONDITION) { SetBoundaryCondition(CurrentSystem, 0.01, 0.01, AlphaAngle[CurrentSystem], BetaAngle[CurrentSystem], GammaAngle[CurrentSystem], A, B, C); } AlphaAngle[CurrentSystem]*=M_PI/180.0; BetaAngle[CurrentSystem]*=M_PI/180.0; GammaAngle[CurrentSystem]*=M_PI/180.0; // construct transformation matrix Box to go from abc-coordinates to xyz-coordinates A=UnitCellSize[CurrentSystem].x; B=UnitCellSize[CurrentSystem].y; C=UnitCellSize[CurrentSystem].z; tempd=(cos(AlphaAngle[CurrentSystem])-cos(GammaAngle[CurrentSystem])*cos(BetaAngle[CurrentSystem]))/sin(GammaAngle[CurrentSystem]); // first vector UnitCellBox[CurrentSystem].ax=A; UnitCellBox[CurrentSystem].ay=0.0; UnitCellBox[CurrentSystem].az=0.0; // second vector UnitCellBox[CurrentSystem].bx=B*cos(GammaAngle[CurrentSystem]); UnitCellBox[CurrentSystem].by=B*sin(GammaAngle[CurrentSystem]); UnitCellBox[CurrentSystem].bz=0.0; // third vector UnitCellBox[CurrentSystem].cx=C*cos(BetaAngle[CurrentSystem]); UnitCellBox[CurrentSystem].cy=C*tempd; UnitCellBox[CurrentSystem].cz=C*sqrt(1.0-SQR(cos(BetaAngle[CurrentSystem]))-SQR(tempd)); Invert3x3Matrix(&UnitCellBox[CurrentSystem],&InverseUnitCellBox[CurrentSystem],&det); A=(REAL)NumberOfUnitCells[CurrentSystem].x*UnitCellSize[CurrentSystem].x; B=(REAL)NumberOfUnitCells[CurrentSystem].y*UnitCellSize[CurrentSystem].y; C=(REAL)NumberOfUnitCells[CurrentSystem].z*UnitCellSize[CurrentSystem].z; tempd=(cos(AlphaAngle[CurrentSystem])-cos(GammaAngle[CurrentSystem])*cos(BetaAngle[CurrentSystem]))/sin(GammaAngle[CurrentSystem]); // first vector Box[CurrentSystem].ax=A; Box[CurrentSystem].ay=0.0; Box[CurrentSystem].az=0.0; // second vector Box[CurrentSystem].bx=B*cos(GammaAngle[CurrentSystem]); Box[CurrentSystem].by=B*sin(GammaAngle[CurrentSystem]); Box[CurrentSystem].bz=0.0; // third vector Box[CurrentSystem].cx=C*cos(BetaAngle[CurrentSystem]); Box[CurrentSystem].cy=C*tempd; Box[CurrentSystem].cz=C*sqrt(1.0-SQR(cos(BetaAngle[CurrentSystem]))-SQR(tempd)); // calculate box-properties CellProperties(&Box[CurrentSystem],&BoxProperties[CurrentSystem],&Volume[CurrentSystem]); // calculate inverse box Invert3x3Matrix(&Box[CurrentSystem],&InverseBox[CurrentSystem],&det); // calculate box-properties CellProperties(&InverseBox[CurrentSystem],&InverseBoxProperties[CurrentSystem],&det); index=Framework[CurrentSystem].NumberOfUnitCellAtoms[CurrentFramework]; for(i=0;i1e-10) { Framework[CurrentSystem].NumberOfCharges[CurrentFramework]++; Framework[CurrentSystem].TotalNumberOfCharges++; } index++; } } } fclose(FilePtr); Framework[CurrentSystem].FrameworkDensityPerComponent[CurrentFramework]= Framework[CurrentSystem].FrameworkMassPerComponent[CurrentFramework]/ (Volume[CurrentSystem]*CUBE(ANGSTROM)*AVOGADRO_CONSTANT); Framework[CurrentSystem].NumberOfAtoms[CurrentFramework]=index; Framework[CurrentSystem].TotalNumberOfAtoms+=Framework[CurrentSystem].NumberOfAtoms[CurrentFramework]; Framework[CurrentSystem].FrameworkDensity+=Framework[CurrentSystem].FrameworkDensityPerComponent[CurrentFramework]; Framework[CurrentSystem].FrameworkMass+=Framework[CurrentSystem].FrameworkMassPerComponent[CurrentFramework]; } void WriteFrameworkDefinitionMOL(char *string) { int j,Type; char buffer[256]; FILE *FilePtr; int *AtomId; VECTOR r; REAL charge; char Name[256]; if (STREAM) { fprintf(stderr, "File writing not allowed in streaming mode!"); return; } AtomId=(int*)calloc(NumberOfPseudoAtoms,sizeof(int)); mkdir("Movies",S_IRWXU); for(CurrentSystem=0;CurrentSystem230)) { fprintf(stderr, "Wrong space group number: %d\n",SpaceGroup); exit(0); } Framework[CurrentSystem].SpaceGroupIdentifier[CurrentFramework]=GetSpaceGroupFromITSpaceGroupNumber(SpaceGroup); } else { TrimStringInPlace(SpaceGroupName); CompressSpacesInString(SpaceGroupName); Framework[CurrentSystem].SpaceGroupIdentifier[CurrentFramework]=GetSpaceGroupFromHermannMauguinString(SpaceGroupName); fprintf(stderr, "Framework[CurrentSystem].SpaceGroupIdentifier[CurrentFramework]: %d %s\n",Framework[CurrentSystem].SpaceGroupIdentifier[CurrentFramework],SpaceGroupName); } Framework[CurrentSystem].SpaceGroupIdentifier[CurrentFramework]=AdjustForNonStandardCSSROption(Framework[CurrentSystem].SpaceGroupIdentifier[CurrentFramework],Option); if(BoundaryCondition[CurrentSystem]==UNINITIALIZED_BOUNDARY_CONDITION) { SetBoundaryCondition(CurrentSystem, 0.001, 0.00001, AlphaAngle[CurrentSystem], BetaAngle[CurrentSystem], GammaAngle[CurrentSystem], A, B, C); } AlphaAngle[CurrentSystem]*=M_PI/180.0; BetaAngle[CurrentSystem]*=M_PI/180.0; GammaAngle[CurrentSystem]*=M_PI/180.0; // construct transformation matrix Box to go from abc-coordinates to xyz-coordinates A=UnitCellSize[CurrentSystem].x; B=UnitCellSize[CurrentSystem].y; C=UnitCellSize[CurrentSystem].z; tempd=(cos(AlphaAngle[CurrentSystem])-cos(GammaAngle[CurrentSystem])*cos(BetaAngle[CurrentSystem]))/sin(GammaAngle[CurrentSystem]); // first vector UnitCellBox[CurrentSystem].ax=A; UnitCellBox[CurrentSystem].ay=0.0; UnitCellBox[CurrentSystem].az=0.0; // second vector UnitCellBox[CurrentSystem].bx=B*cos(GammaAngle[CurrentSystem]); UnitCellBox[CurrentSystem].by=B*sin(GammaAngle[CurrentSystem]); UnitCellBox[CurrentSystem].bz=0.0; // third vector UnitCellBox[CurrentSystem].cx=C*cos(BetaAngle[CurrentSystem]); UnitCellBox[CurrentSystem].cy=C*tempd; UnitCellBox[CurrentSystem].cz=C*sqrt(1.0-SQR(cos(BetaAngle[CurrentSystem]))-SQR(tempd)); Invert3x3Matrix(&UnitCellBox[CurrentSystem],&InverseUnitCellBox[CurrentSystem],&det); A=(REAL)NumberOfUnitCells[CurrentSystem].x*UnitCellSize[CurrentSystem].x; B=(REAL)NumberOfUnitCells[CurrentSystem].y*UnitCellSize[CurrentSystem].y; C=(REAL)NumberOfUnitCells[CurrentSystem].z*UnitCellSize[CurrentSystem].z; tempd=(cos(AlphaAngle[CurrentSystem])-cos(GammaAngle[CurrentSystem])*cos(BetaAngle[CurrentSystem]))/sin(GammaAngle[CurrentSystem]); // first vector Box[CurrentSystem].ax=A; Box[CurrentSystem].ay=0.0; Box[CurrentSystem].az=0.0; // second vector Box[CurrentSystem].bx=B*cos(GammaAngle[CurrentSystem]); Box[CurrentSystem].by=B*sin(GammaAngle[CurrentSystem]); Box[CurrentSystem].bz=0.0; // third vector Box[CurrentSystem].cx=C*cos(BetaAngle[CurrentSystem]); Box[CurrentSystem].cy=C*tempd; Box[CurrentSystem].cz=C*sqrt(1.0-SQR(cos(BetaAngle[CurrentSystem]))-SQR(tempd)); Invert3x3Matrix(&Box[CurrentSystem],&InverseBox[CurrentSystem],&det); // calculate box-properties CellProperties(&InverseBox[CurrentSystem],&InverseBoxProperties[CurrentSystem],&det); CellProperties(&Box[CurrentSystem],&BoxProperties[CurrentSystem],&Volume[CurrentSystem]); // get number of atoms of one unitcell fscanf(FilePtr,"%d %[^\n]",&temp,buffer); Framework[CurrentSystem].NumberOfAsymmetricAtoms[CurrentFramework]=temp; Framework[CurrentSystem].AtomsAsymmetric[CurrentFramework]=(FRAMEWORK_ASYMMETRIC_ATOM*)calloc(temp,sizeof(FRAMEWORK_ASYMMETRIC_ATOM)); index=0; fscanf(FilePtr,"%d %[^\n]",&temp,buffer); for(i=0;i1) fprintf(FilePtr," OPT = %d",SpaceGroupData[Framework[CurrentSystem].SpaceGroupIdentifier[CurrentFramework]].SpaceGroupOptionCSSR); fprintf(FilePtr,"\n"); if(SpaceGroupData[Framework[CurrentSystem].SpaceGroupIdentifier[CurrentFramework]].Number==1) { fprintf(FilePtr,"%4d %d %s\n",Framework[CurrentSystem].TotalNumberOfAtoms,0,"Created by Raspa-1.0"); fprintf(FilePtr," 0 %s : %s\n",Framework[CurrentSystem].Name[0], Framework[CurrentSystem].Name[0]); SerialNumber=1; for(j=0;j0) fprintf(FilePtr,"%s %s %g\n",PseudoAtoms[i].PrintToPDBName,PseudoAtoms[i].CoreShell==CORE?"core":"shel",PseudoAtoms[i].Charge1); count=0; for(i=0;i0) { fprintf(FilePtr,"buckingham\n"); for(i=0;i0)&&(NumberOfPseudoAtomsType[CurrentSystem][j]>0)) { fprintf(FilePtr,"%s %s %s %s %g %g %g %g %g\n",PseudoAtoms[i].PrintToPDBName,PseudoAtoms[i].CoreShell==CORE?"core":"shel", PseudoAtoms[j].PrintToPDBName,PseudoAtoms[j].CoreShell==CORE?"core":"shel", (double)PotentialParms[i][j][0]*ENERGY_TO_EV, (double)(1.0/PotentialParms[i][j][1]), (double)PotentialParms[i][j][2]*ENERGY_TO_EV, 0.0, CutOffVDW); } } if(Framework[CurrentSystem].NumberOfCoreShellDefinitions>0) { fprintf(FilePtr,"spring\n"); for(i=0;i0)) fprintf(FilePtr,"%s %g\n", PseudoAtoms[TypeA].PrintToPDBName, Framework[CurrentSystem].BondArgumentDefinitions[i][0]*KELVIN_TO_ENERGY*ENERGY_TO_EV); } } if(Framework[CurrentSystem].NumberOfBendDefinitions>0) { fprintf(FilePtr,"three\n"); for(i=0;i0)&& (NumberOfPseudoAtomsType[CurrentSystem][TypeB]>0)&&(NumberOfPseudoAtomsType[CurrentSystem][TypeC]>0)) fprintf(FilePtr,"%s %s %s %s %s %s %g %g 1.9 1.9 3.5\n", PseudoAtoms[TypeB].PrintToPDBName, PseudoAtoms[TypeB].CoreShell==CORE?"core":"shel", PseudoAtoms[TypeA].PrintToPDBName, PseudoAtoms[TypeA].CoreShell==CORE?"core":"shel", PseudoAtoms[TypeC].PrintToPDBName, PseudoAtoms[TypeC].CoreShell==CORE?"core":"shel", Framework[CurrentSystem].BendArgumentDefinitions[i][0]*KELVIN_TO_ENERGY*ENERGY_TO_EV, Framework[CurrentSystem].BendArgumentDefinitions[i][1]); } } fprintf(FilePtr,"\n"); fprintf(FilePtr,"frac\n"); SerialNumber=1; nr_cores=Framework[CurrentSystem].NumberOfAtoms[CurrentFramework]-Framework[CurrentSystem].NumberOfCoreShells[CurrentFramework]; for(j=0;j0) fprintf(FilePtr,"%s (%d) ",PseudoAtoms[i].ChemicalElement,count); } fprintf(FilePtr,"\n"); */ fprintf(FilePtr,"%f\n",1.0); fprintf(FilePtr,"%20.16f %20.16f %20.10f\n",Box[CurrentSystem].ax,Box[CurrentSystem].ay,Box[CurrentSystem].az); fprintf(FilePtr,"%20.16f %20.16f %20.10f\n",Box[CurrentSystem].bx,Box[CurrentSystem].by,Box[CurrentSystem].bz); fprintf(FilePtr,"%20.16f %20.16f %20.10f\n",Box[CurrentSystem].cx,Box[CurrentSystem].cy,Box[CurrentSystem].cz); for(i=0;i0) fprintf(FilePtr,"%d ",count); } fprintf(FilePtr,"\n"); fprintf(FilePtr,"Direct\n"); for(i=0;i insert it as a framework atom if(index<0) { // reallocate memory if needed if(insert_index>=Framework[CurrentSystem].MaxNumberOfAtoms[CurrentFramework]) { Framework[CurrentSystem].MaxNumberOfAtoms[CurrentFramework]+=1024; Framework[CurrentSystem].Atoms[CurrentFramework]=(ATOM*)realloc(Framework[CurrentSystem].Atoms[CurrentFramework], Framework[CurrentSystem].MaxNumberOfAtoms[CurrentFramework]*sizeof(ATOM)); if(!Framework[CurrentSystem].Atoms[CurrentFramework]) { printf("Memory reallocation error of 'Framework[CurrentSystem].Atoms[CurrentFramework]' in file %s line %d\n", __FILE__, __LINE__); exit(-1); } } // insert atom into framework Framework[CurrentSystem].Atoms[CurrentFramework][insert_index].Position=pos; Framework[CurrentSystem].Atoms[CurrentFramework][insert_index].Type=Type; // Fill in charge from the pseudo-atom definition Framework[CurrentSystem].Atoms[CurrentFramework][insert_index].Charge=charge; // adjust the counter for the type of pseudo atoms NumberOfPseudoAtomsCount[CurrentSystem][Type]++; NumberOfPseudoAtomsType[CurrentSystem][Type]++; if(PseudoAtoms[Type].HasCharges) Framework[CurrentSystem].NumberOfCharges[CurrentFramework]++; // add the mass of the atom to the total framework mass Framework[CurrentSystem].FrameworkMassPerComponent[CurrentFramework]+=PseudoAtoms[Type].Mass; // increase the number of atoms by one insert_index++; } } } } // update bookkeeping for framework properties Framework[CurrentSystem].NumberOfAtoms[CurrentFramework]=insert_index; Framework[CurrentSystem].NumberOfUnitCellAtoms[CurrentFramework]=insert_index/(NumberOfUnitCells[CurrentSystem].x* NumberOfUnitCells[CurrentSystem].y*NumberOfUnitCells[CurrentSystem].z); Framework[CurrentSystem].FrameworkDensityPerComponent[CurrentFramework]= Framework[CurrentSystem].FrameworkMassPerComponent[CurrentFramework]/ (Volume[CurrentSystem]*CUBE(ANGSTROM)*AVOGADRO_CONSTANT); Framework[CurrentSystem].TotalNumberOfAtoms+=Framework[CurrentSystem].NumberOfAtoms[CurrentFramework]; Framework[CurrentSystem].TotalNumberOfCharges+=Framework[CurrentSystem].NumberOfCharges[CurrentFramework]; Framework[CurrentSystem].TotalNumberOfUnitCellAtoms+=Framework[CurrentSystem].NumberOfUnitCellAtoms[CurrentFramework]; Framework[CurrentSystem].FrameworkDensity+=Framework[CurrentSystem].FrameworkDensityPerComponent[CurrentFramework]; Framework[CurrentSystem].FrameworkMass+=Framework[CurrentSystem].FrameworkMassPerComponent[CurrentFramework]; // transform from fractional coordinates (abc) to Cartesian coordinates (xyz) for(i=0;i insert it as a framework atom if(index<0) { // reallocate memory if needed if(insert_index>=Framework[CurrentSystem].MaxNumberOfIons) { Framework[CurrentSystem].MaxNumberOfIons+=1024; Framework[CurrentSystem].Ions=(ATOM*)realloc(Framework[CurrentSystem].Ions, Framework[CurrentSystem].MaxNumberOfIons*sizeof(ATOM)); if(!Framework[CurrentSystem].Ions) { printf("Memory reallocation error of 'Framework[CurrentSystem].Ions' in file %s line %d\n", __FILE__, __LINE__); exit(-1); } } // insert atom into framework Framework[CurrentSystem].Ions[insert_index].Position=pos; Framework[CurrentSystem].Ions[insert_index].Type=Type; Framework[CurrentSystem].Ions[insert_index].AssymetricType=i; crystallographic_stats[CurrentSystem].NumberOfCationSites[i]++; // increase the number of atoms by one insert_index++; } } } } // update bookkeeping for framework properties Framework[CurrentSystem].NumberOfIons=insert_index; // transform from fractional coordinates (abc) to Cartesian coordinates (xyz) for(i=0;i0) return Stack[stack][StackSize[stack]--]; return -1; } int IsElementInStack(int stack,int element) { int i; for(i=0;imax) { max=Framework[CurrentSystem].Connectivity[j][A]; fmax=j; } } // Recursively handle all neighboring atoms for(j=0;j1e-4) { for(j=0;j0.0) for(fr=0;fr=0) { index=-1; for(i=0;iNumberOfPseudoAtomsType[CurrentSystem][TypeSource]) nr=NumberOfPseudoAtomsType[CurrentSystem][TypeSource]; do { // substitute the 'k-th' atom of type 'source' by type 'dest' k=RandomNumber()*NumberOfPseudoAtomsType[CurrentSystem][TypeSource];; index=0; index2=0; for(f1=0;f10); } } void ModifyAtomsConnectedToDefinedNeighbours(void) { int i,j,k,l,f1; int A,B,C,D,E,F; int found[12]; int nr_found; REAL temp_real; REAL Angle1,Angle2; Lowenstein[CurrentSystem]=TRUE; for(l=0;l=4)&&(Framework[CurrentSystem].Atoms[f1][A].Type==ModifyFrameworkAtomTypes[l][0])) { nr_found=0; for(j=0;jAngle2) SWAP(found[1],found[2],temp_real); Angle1=ReturnConstraintBendAngle(Framework[CurrentSystem].Atoms[f1][found[0]].Position,Framework[CurrentSystem].Atoms[f1][A].Position, Framework[CurrentSystem].Atoms[f1][found[3]].Position); Angle2=ReturnConstraintBendAngle(Framework[CurrentSystem].Atoms[f1][found[0]].Position,Framework[CurrentSystem].Atoms[f1][A].Position, Framework[CurrentSystem].Atoms[f1][found[2]].Position); if(Angle1>Angle2) SWAP(found[2],found[3],temp_real); Framework[CurrentSystem].Atoms[f1][A].Type=ModifyFrameworkAtomTypes[l][5]; if(!UseChargesFromCIFFile) Framework[CurrentSystem].Atoms[f1][A].Charge=PseudoAtoms[ModifyFrameworkAtomTypes[l][5]].Charge1; NumberOfPseudoAtomsCount[CurrentSystem][ModifyFrameworkAtomTypes[l][0]]--; NumberOfPseudoAtomsType[CurrentSystem][ModifyFrameworkAtomTypes[l][0]]--; NumberOfPseudoAtomsCount[CurrentSystem][ModifyFrameworkAtomTypes[l][5]]++; NumberOfPseudoAtomsType[CurrentSystem][ModifyFrameworkAtomTypes[l][5]]++; Framework[CurrentSystem].Atoms[f1][found[0]].Type=ModifyFrameworkAtomTypes[l][6]; if(!UseChargesFromCIFFile) Framework[CurrentSystem].Atoms[f1][found[0]].Charge=PseudoAtoms[ModifyFrameworkAtomTypes[l][6]].Charge1; NumberOfPseudoAtomsCount[CurrentSystem][ModifyFrameworkAtomTypes[l][1]]--; NumberOfPseudoAtomsType[CurrentSystem][ModifyFrameworkAtomTypes[l][1]]--; NumberOfPseudoAtomsCount[CurrentSystem][ModifyFrameworkAtomTypes[l][6]]++; NumberOfPseudoAtomsType[CurrentSystem][ModifyFrameworkAtomTypes[l][6]]++; Framework[CurrentSystem].Atoms[f1][found[1]].Type=ModifyFrameworkAtomTypes[l][7]; if(!UseChargesFromCIFFile) Framework[CurrentSystem].Atoms[f1][found[1]].Charge=PseudoAtoms[ModifyFrameworkAtomTypes[l][7]].Charge1; NumberOfPseudoAtomsCount[CurrentSystem][ModifyFrameworkAtomTypes[l][2]]--; NumberOfPseudoAtomsType[CurrentSystem][ModifyFrameworkAtomTypes[l][2]]--; NumberOfPseudoAtomsCount[CurrentSystem][ModifyFrameworkAtomTypes[l][7]]++; NumberOfPseudoAtomsType[CurrentSystem][ModifyFrameworkAtomTypes[l][7]]++; Framework[CurrentSystem].Atoms[f1][found[2]].Type=ModifyFrameworkAtomTypes[l][8]; if(!UseChargesFromCIFFile) Framework[CurrentSystem].Atoms[f1][found[2]].Charge=PseudoAtoms[ModifyFrameworkAtomTypes[l][8]].Charge1; NumberOfPseudoAtomsCount[CurrentSystem][ModifyFrameworkAtomTypes[l][3]]--; NumberOfPseudoAtomsType[CurrentSystem][ModifyFrameworkAtomTypes[l][3]]--; NumberOfPseudoAtomsCount[CurrentSystem][ModifyFrameworkAtomTypes[l][8]]++; NumberOfPseudoAtomsType[CurrentSystem][ModifyFrameworkAtomTypes[l][8]]++; Framework[CurrentSystem].Atoms[f1][found[3]].Type=ModifyFrameworkAtomTypes[l][9]; if(!UseChargesFromCIFFile) Framework[CurrentSystem].Atoms[f1][found[3]].Charge=PseudoAtoms[ModifyFrameworkAtomTypes[l][9]].Charge1; NumberOfPseudoAtomsCount[CurrentSystem][ModifyFrameworkAtomTypes[l][4]]--; NumberOfPseudoAtomsType[CurrentSystem][ModifyFrameworkAtomTypes[l][4]]--; NumberOfPseudoAtomsCount[CurrentSystem][ModifyFrameworkAtomTypes[l][9]]++; NumberOfPseudoAtomsType[CurrentSystem][ModifyFrameworkAtomTypes[l][9]]++; } } } break; case MODIFY_FRAMEWORKATOM_DIMER: for(f1=0;f16 neighbors not implemented\n"); exit(0); break; } } } } break; } } for(l=0;lax=sqrt(SQR(in->ax)+SQR(in->ay)+SQR(in->az)); out->ay=sqrt(SQR(in->bx)+SQR(in->by)+SQR(in->bz)); out->az=0.0; // calculate cosines of cell angles out->bx=0.0; out->by=0.0; out->bz=(in->ax*in->bx+in->ay*in->by+in->az*in->bz)/(out->ax*out->ay); // calculate volume of cell *Volume=in->ax*in->by-in->ay*in->bx; // calculate cell perpendicular widths out->cx=*Volume/out->ay; out->cy=*Volume/out->ax; out->cz=0.0; break; case 3: // calculate lengths of cell vectors out->ax=sqrt(SQR(in->ax)+SQR(in->ay)+SQR(in->az)); out->ay=sqrt(SQR(in->bx)+SQR(in->by)+SQR(in->bz)); out->az=sqrt(SQR(in->cx)+SQR(in->cy)+SQR(in->cz)); // calculate cosines of cell angles out->bx=(in->bx*in->cx+in->by*in->cy+in->bz*in->cz)/(out->ay*out->az); out->by=(in->ax*in->cx+in->ay*in->cy+in->az*in->cz)/(out->ax*out->az); out->bz=(in->ax*in->bx+in->ay*in->by+in->az*in->bz)/(out->ax*out->ay); // calculate vector products of cell vectors axb1=in->ay*in->bz-in->az*in->by; axb2=in->az*in->bx-in->ax*in->bz; axb3=in->ax*in->by-in->ay*in->bx; bxc1=in->by*in->cz-in->bz*in->cy; bxc2=in->bz*in->cx-in->bx*in->cz; bxc3=in->bx*in->cy-in->by*in->cx; cxa1=in->cy*in->az-in->ay*in->cz; cxa2=in->ax*in->cz-in->az*in->cx; cxa3=in->ay*in->cx-in->ax*in->cy; // calculate volume of cell *Volume=fabs(in->ax*bxc1+in->ay*bxc2+in->az*bxc3); // calculate cell perpendicular widths out->cx=*Volume/sqrt(bxc1*bxc1+bxc2*bxc2+bxc3*bxc3); out->cy=*Volume/sqrt(cxa1*cxa1+cxa2*cxa2+cxa3*cxa3); out->cz=*Volume/sqrt(axb1*axb1+axb2*axb2+axb3*axb3); break; } } void PrintFrameworkStatus(void) { int i; VECTOR pos; fprintf(stderr, "Framework contains %d atoms\n",Framework[CurrentSystem].TotalNumberOfAtoms); fprintf(stderr, "===================================================\n"); for(i=0;i0) { // loop over shells for(A=0;A0) Framework[CurrentSystem].Atoms[f1][B].Velocity=Framework[CurrentSystem].Atoms[f1][A].Velocity; } } } } VECTOR MeasureFrameworkVelocityDrift(void) { int i,f1; REAL Mass,TotalMass; VECTOR com; TotalMass=0.0; com.x=com.y=com.z=0.0; for(f1=0;f10) { Framework[CurrentSystem].MaxNumberOfBonds[CurrentFramework]+=NumberOfBonds; Framework[CurrentSystem].Bonds[CurrentFramework]=(PAIR*)realloc(Framework[CurrentSystem].Bonds[CurrentFramework], Framework[CurrentSystem].MaxNumberOfBonds[CurrentFramework]*sizeof(PAIR)); if(!Framework[CurrentSystem].Bonds[CurrentFramework]) { printf("Memory reallocation error of 'Framework[CurrentSystem].Bonds[CurrentFramework]' in file %s line %d\n", __FILE__, __LINE__); exit(-1); } Framework[CurrentSystem].BondType[CurrentFramework]=(int*)realloc(Framework[CurrentSystem].BondType[CurrentFramework], Framework[CurrentSystem].MaxNumberOfBonds[CurrentFramework]*sizeof(int)); if(!Framework[CurrentSystem].BondType[CurrentFramework]) { printf("Memory reallocation error of 'Framework[CurrentSystem].BondType[CurrentFramework]' in file %s line %d\n", __FILE__, __LINE__); exit(-1); } Framework[CurrentSystem].BondArguments[CurrentFramework]=(REAL(*)[MAX_BOND_POTENTIAL_ARGUMENTS]) realloc(Framework[CurrentSystem].BondArguments[CurrentFramework], Framework[CurrentSystem].MaxNumberOfBonds[CurrentFramework]*sizeof(REAL[MAX_BOND_POTENTIAL_ARGUMENTS])); if(!Framework[CurrentSystem].BondArguments[CurrentFramework]) { printf("Memory reallocation error of 'Framework[CurrentSystem].BondArguments[CurrentFramework]' in file %s line %d\n", __FILE__, __LINE__); exit(-1); } } else { Framework[CurrentSystem].MaxNumberOfBonds[CurrentFramework]=NumberOfBonds; Framework[CurrentSystem].Bonds[CurrentFramework]=(PAIR*)calloc(Framework[CurrentSystem].MaxNumberOfBonds[CurrentFramework],sizeof(PAIR)); Framework[CurrentSystem].BondType[CurrentFramework]=(int*)calloc(Framework[CurrentSystem].MaxNumberOfBonds[CurrentFramework],sizeof(int)); Framework[CurrentSystem].BondArguments[CurrentFramework]=(REAL(*)[MAX_BOND_POTENTIAL_ARGUMENTS]) calloc(Framework[CurrentSystem].MaxNumberOfBonds[CurrentFramework],sizeof(REAL[MAX_BOND_POTENTIAL_ARGUMENTS])); } index=Framework[CurrentSystem].NumberOfBonds[CurrentFramework]; for(i=index;i0) { Framework[CurrentSystem].MaxNumberOfBends[CurrentFramework]+=NumberOfBends; Framework[CurrentSystem].Bends[CurrentFramework]=(QUAD*)realloc(Framework[CurrentSystem].Bends[CurrentFramework], Framework[CurrentSystem].MaxNumberOfBends[CurrentFramework]*sizeof(QUAD)); if(!Framework[CurrentSystem].Bends[CurrentFramework]) { printf("Memory reallocation error of 'Framework[CurrentSystem].Bends[CurrentFramework]' in file %s line %d\n", __FILE__, __LINE__); exit(-1); } Framework[CurrentSystem].BendType[CurrentFramework]=(int*)realloc(Framework[CurrentSystem].BendType[CurrentFramework], Framework[CurrentSystem].MaxNumberOfBends[CurrentFramework]*sizeof(int)); if(!Framework[CurrentSystem].BendType[CurrentFramework]) { printf("Memory reallocation error of 'Framework[CurrentSystem].BendType[CurrentFramework]' in file %s line %d\n", __FILE__, __LINE__); exit(-1); } Framework[CurrentSystem].BendArguments[CurrentFramework]=(REAL(*)[MAX_BEND_POTENTIAL_ARGUMENTS]) realloc(Framework[CurrentSystem].BendArguments[CurrentFramework], Framework[CurrentSystem].MaxNumberOfBends[CurrentFramework]*sizeof(REAL[MAX_BEND_POTENTIAL_ARGUMENTS])); if(!Framework[CurrentSystem].BendArguments[CurrentFramework]) { printf("Memory reallocation error of 'Framework[CurrentSystem].BendArguments[CurrentFramework]' in file %s line %d\n", __FILE__, __LINE__); exit(-1); } } else { Framework[CurrentSystem].MaxNumberOfBends[CurrentFramework]=NumberOfBends; Framework[CurrentSystem].Bends[CurrentFramework]=(QUAD*)calloc(Framework[CurrentSystem].MaxNumberOfBends[CurrentFramework],sizeof(QUAD)); Framework[CurrentSystem].BendType[CurrentFramework]=(int*)calloc(Framework[CurrentSystem].MaxNumberOfBends[CurrentFramework],sizeof(int)); Framework[CurrentSystem].BendArguments[CurrentFramework]=(REAL(*)[MAX_BEND_POTENTIAL_ARGUMENTS]) calloc(Framework[CurrentSystem].MaxNumberOfBends[CurrentFramework],sizeof(REAL[MAX_BEND_POTENTIAL_ARGUMENTS])); } index=Framework[CurrentSystem].NumberOfBends[CurrentFramework]; for(i=index;i0) { Framework[CurrentSystem].MaxNumberOfTorsions[CurrentFramework]+=NumberOfTorsions; Framework[CurrentSystem].Torsions[CurrentFramework]=(QUAD*)realloc(Framework[CurrentSystem].Torsions[CurrentFramework], Framework[CurrentSystem].MaxNumberOfTorsions[CurrentFramework]*sizeof(QUAD)); if(!Framework[CurrentSystem].Torsions[CurrentFramework]) { printf("Memory reallocation error of 'Framework[CurrentSystem].Torsions[CurrentFramework]' in file %s line %d\n", __FILE__, __LINE__); exit(-1); } Framework[CurrentSystem].TorsionType[CurrentFramework]=(int*)realloc(Framework[CurrentSystem].TorsionType[CurrentFramework], Framework[CurrentSystem].MaxNumberOfTorsions[CurrentFramework]*sizeof(int)); if(!Framework[CurrentSystem].TorsionType[CurrentFramework]) { printf("Memory reallocation error of 'Framework[CurrentSystem].TorsionType[CurrentFramework]' in file %s line %d\n", __FILE__, __LINE__); exit(-1); } Framework[CurrentSystem].TorsionArguments[CurrentFramework]=(REAL(*)[MAX_TORSION_POTENTIAL_ARGUMENTS]) realloc(Framework[CurrentSystem].TorsionArguments[CurrentFramework], Framework[CurrentSystem].MaxNumberOfTorsions[CurrentFramework]*sizeof(REAL[MAX_TORSION_POTENTIAL_ARGUMENTS])); if(!Framework[CurrentSystem].TorsionArguments[CurrentFramework]) { printf("Memory reallocation error of 'Framework[CurrentSystem].TorsionArguments[CurrentFramework]' in file %s line %d\n", __FILE__, __LINE__); exit(-1); } } else { Framework[CurrentSystem].MaxNumberOfTorsions[CurrentFramework]=NumberOfTorsions; Framework[CurrentSystem].Torsions[CurrentFramework]=(QUAD*)calloc(Framework[CurrentSystem].MaxNumberOfTorsions[CurrentFramework],sizeof(QUAD)); Framework[CurrentSystem].TorsionType[CurrentFramework]=(int*)calloc(Framework[CurrentSystem].MaxNumberOfTorsions[CurrentFramework],sizeof(int)); Framework[CurrentSystem].TorsionArguments[CurrentFramework]=(REAL(*)[MAX_TORSION_POTENTIAL_ARGUMENTS]) calloc(Framework[CurrentSystem].MaxNumberOfTorsions[CurrentFramework],sizeof(REAL[MAX_TORSION_POTENTIAL_ARGUMENTS])); } if(Framework[CurrentSystem].MaxNumberOfImproperTorsions[CurrentFramework]>0) { Framework[CurrentSystem].MaxNumberOfImproperTorsions[CurrentFramework]+=NumberOfTorsions; Framework[CurrentSystem].ImproperTorsions[CurrentFramework]=(QUAD*)realloc(Framework[CurrentSystem].ImproperTorsions[CurrentFramework], Framework[CurrentSystem].MaxNumberOfImproperTorsions[CurrentFramework]*sizeof(QUAD)); if(!Framework[CurrentSystem].ImproperTorsions[CurrentFramework]) { printf("Memory reallocation error of 'Framework[CurrentSystem].ImproperTorsions[CurrentFramework]' in file %s line %d\n", __FILE__, __LINE__); exit(-1); } Framework[CurrentSystem].ImproperTorsionType[CurrentFramework]=(int*)realloc(Framework[CurrentSystem].ImproperTorsionType[CurrentFramework], Framework[CurrentSystem].MaxNumberOfImproperTorsions[CurrentFramework]*sizeof(int)); if(!Framework[CurrentSystem].ImproperTorsionType[CurrentFramework]) { printf("Memory reallocation error of 'Framework[CurrentSystem].ImproperTorsionType[CurrentFramework]' in file %s line %d\n", __FILE__, __LINE__); exit(-1); } Framework[CurrentSystem].ImproperTorsionArguments[CurrentFramework]=(REAL(*)[MAX_TORSION_POTENTIAL_ARGUMENTS]) realloc(Framework[CurrentSystem].ImproperTorsionArguments[CurrentFramework], Framework[CurrentSystem].MaxNumberOfImproperTorsions[CurrentFramework]*sizeof(REAL[MAX_TORSION_POTENTIAL_ARGUMENTS])); if(!Framework[CurrentSystem].ImproperTorsionArguments[CurrentFramework]) { printf("Memory reallocation error of 'Framework[CurrentSystem].ImproperTorsionArguments[CurrentFramework]' in file %s line %d\n", __FILE__, __LINE__); exit(-1); } } else { Framework[CurrentSystem].MaxNumberOfImproperTorsions[CurrentFramework]=NumberOfTorsions; Framework[CurrentSystem].ImproperTorsions[CurrentFramework]=(QUAD*)calloc(Framework[CurrentSystem].MaxNumberOfImproperTorsions[CurrentFramework],sizeof(QUAD)); Framework[CurrentSystem].ImproperTorsionType[CurrentFramework]=(int*)calloc(Framework[CurrentSystem].MaxNumberOfImproperTorsions[CurrentFramework],sizeof(int)); Framework[CurrentSystem].ImproperTorsionArguments[CurrentFramework]=(REAL(*)[MAX_TORSION_POTENTIAL_ARGUMENTS]) calloc(Framework[CurrentSystem].MaxNumberOfImproperTorsions[CurrentFramework],sizeof(REAL[MAX_TORSION_POTENTIAL_ARGUMENTS])); } index=Framework[CurrentSystem].NumberOfTorsions[CurrentFramework]; index2=Framework[CurrentSystem].NumberOfImproperTorsions[CurrentFramework]; for(i=0;i0) { total=0; for(m=0;m0) { fprintf(FilePtr,"RIGID %d\n",total); for(l=0;l0) { for(j=i;j0) { if(PotentialType[i][j]==LENNARD_JONES) total++; } } } } fprintf(FilePtr,"VDW %d\n",total); for(i=0;i0) { for(j=i;j0) { switch(PotentialType[i][j]) { case ZERO_POTENTIAL: case ZERO_POTENTIAL_CONTINUOUS_FRACTIONAL: break; case LENNARD_JONES: // 4*p_0*((p_1/r)^12-(p_1/r)^6) // ====================================================================================== // p_0/k_B [K] strength parameter epsilon // p_1 [A] size parameter sigma // p_2/k_B [K] (non-zero for a shifted potential) fprintf(FilePtr,"%6s %6s lj %12.6lf %12.6lf\n", PseudoAtoms[i].Name, PseudoAtoms[j].Name, (double)PotentialParms[i][j][0]*ENERGY_TO_KELVIN, (double)PotentialParms[i][j][1]); break; } } } } } fprintf(FilePtr,"CLOSE\n"); fclose(FilePtr); } /********************************************************************************************************* * Name | ReadFrameworkDefinition * * ----------------------------------------------------------------------------------------------------- * * Function | Read the definition (bond, bend, torsion, etc) of a framework component. * * Note | The excluded Van der Waals and Coulombic interactions are automatically computed from * * | framework exclusion rules (1-2, 1-3, 1-4 omission, bond/bend/torsion omission). * *********************************************************************************************************/ int ReadFrameworkDefinition(void) { int i,j,k,l,m,n,f1,index_excluded,present,nr_atoms; int A,B,C,D,A1,B1,C1,TypeA,TypeB,TypeC,TypeD,CurrentTypeA,CurrentTypeB,CurrentTypeC,CurrentTypeD,index,ListTypeC,ListTypeD; char buffer[256],TypeNameA[256],TypeNameB[256],TypeNameC[256],TypeNameD[256]; char line[1024]; char *arg_pointer; REAL arguments[10]; int BondType=0,BendType=0,TorsionType=0,InversionBendType=0,ImproperTorsionType=0; int BondBondType=0,BondBendType=0,BendBendType=0,BondTorsionType=0,BendTorsionType=0; REAL r,rab,rbc,theta; double temp; VECTOR Rab,Rbc,dr; FILE *FilePtr; // Create an initial connectivity list // Based on the connectivity and defined rules the type of an atom can be modified (e.g. oxygen connected to an aluminum) // The list has to be created first because the shells of cores is possibly based on the modified atoms AllocateConnectivityList(); MakeConnectivityList(); SubstituteAtoms(); ModifyAtomsConnectedToDefinedNeighbours(); if(strlen(Framework[CurrentSystem].FrameworkDefinitions)<1) return 0; // try "framework.def", then "Framework,def", and then the repository sprintf(buffer,"%s.%s","framework","def"); if(!(FilePtr=fopen(buffer,"r"))) { sprintf(buffer,"%s.%s","Framework","def"); if(!(FilePtr=fopen(buffer,"r"))) { sprintf(buffer,"%s/share/raspa/framework/%s/%s.%s",RASPA_DIRECTORY, Framework[CurrentSystem].FrameworkDefinitions,"framework","def"); if(!(FilePtr=fopen(buffer,"r"))) { sprintf(buffer,"%s/share/raspa/framework/%s/%s.%s",RASPA_DIRECTORY, Framework[CurrentSystem].FrameworkDefinitions,"Framework","def"); if(!(FilePtr=fopen(buffer,"r"))) { fprintf(stderr, "Error: file %s does not exist.\n",buffer); exit(1); } } } } ReadLine(line,1024,FilePtr); // skip line ReadLine(line,1024,FilePtr); sscanf(line,"%d%d%d%d%d%d%d%d%d%d%d%d%d", &Framework[CurrentSystem].NumberOfCoreShellDefinitions, &Framework[CurrentSystem].NumberOfBondsDefinitions, &Framework[CurrentSystem].NumberOfBondDipoleDefinitions, &Framework[CurrentSystem].NumberOfUreyBradleyDefinitions, &Framework[CurrentSystem].NumberOfBendDefinitions, &Framework[CurrentSystem].NumberOfInversionBendDefinitions, &Framework[CurrentSystem].NumberOfTorsionDefinitions, &Framework[CurrentSystem].NumberOfImproperTorsionDefinitions, //&Framework[CurrentSystem].NumberOfOutOfPlaneDefinitions, &Framework[CurrentSystem].NumberOfBondBondDefinitions, &Framework[CurrentSystem].NumberOfBondBendDefinitions, &Framework[CurrentSystem].NumberOfBendBendDefinitions, &Framework[CurrentSystem].NumberOfBondTorsionDefinitions, &Framework[CurrentSystem].NumberOfBendTorsionDefinitions); // read the core and the shells index_excluded=0; if(Framework[CurrentSystem].NumberOfCoreShellDefinitions>0) { Framework[CurrentSystem].CoreShellConnectivity=(int**)calloc(Framework[CurrentSystem].NumberOfFrameworks,sizeof(int*)); for(f1=0;f10) { // allocate the shells for(f1=0;f10) { nr_atoms=Framework[CurrentSystem].NumberOfAtoms[f1]+Framework[CurrentSystem].NumberOfCoreShells[f1]; // create memory for the core-shell connectivity array Framework[CurrentSystem].CoreShellConnectivity[f1]=(int*)calloc(nr_atoms,sizeof(int)); for(i=0;i0) { // alloc memory Framework[CurrentSystem].BondDefinitionType=(int*)calloc(Framework[CurrentSystem].NumberOfBondsDefinitions,sizeof(int)); Framework[CurrentSystem].BondDefinitions=(PAIR*)calloc(Framework[CurrentSystem].NumberOfBondsDefinitions,sizeof(PAIR)); Framework[CurrentSystem].BondArgumentDefinitions=(REAL(*)[MAX_BOND_POTENTIAL_ARGUMENTS]) calloc(Framework[CurrentSystem].NumberOfBondsDefinitions,sizeof(REAL[MAX_BOND_POTENTIAL_ARGUMENTS])); Framework[CurrentSystem].NumberOfBondsPerType=(int*)calloc(Framework[CurrentSystem].NumberOfBondsDefinitions,sizeof(int)); for(CurrentFramework=0;CurrentFrameworkp_2 // =============================================== // p_0/k_B [K/A^2] // p_1 [A] // p_2 [A] Framework[CurrentSystem].BondArguments[CurrentFramework][index][0]*=KELVIN_TO_ENERGY; break; case QUARTIC_BOND: // (1/2)*p_0*(r-p_1)^2+(1/3)*p_2*(r-p_1)^3+(1/4)*p_3*(r-p_1)^4 // =========================================================== // p_0/k_B [K/A^2] // p_1 [A] // p_2/k_B [K/A^3] // p_3/k_B [K/A^4] case CFF_QUARTIC_BOND: // p_0*(r-p_1)^2+p_2*(r-p_1)^3+p_3*(r-p_1)^4 // =============================================== // p_0/k_B [K/A^2] // p_1 [A] // p_2/k_B [K/A^3] // p_3/k_B [K/A^4] r=Framework[CurrentSystem].BondArguments[CurrentFramework][index][1]; if(r<1e-5) { dr.x=Framework[CurrentSystem].Atoms[CurrentFramework][A].Position.x- Framework[CurrentSystem].Atoms[CurrentFramework][B].Position.x; dr.y=Framework[CurrentSystem].Atoms[CurrentFramework][A].Position.y- Framework[CurrentSystem].Atoms[CurrentFramework][B].Position.y; dr.z=Framework[CurrentSystem].Atoms[CurrentFramework][A].Position.z- Framework[CurrentSystem].Atoms[CurrentFramework][B].Position.z; dr=ApplyBoundaryCondition(dr); r=sqrt(SQR(dr.x)+SQR(dr.y)+SQR(dr.z)); Framework[CurrentSystem].BondArguments[CurrentFramework][index][1]=r; } Framework[CurrentSystem].BondArguments[CurrentFramework][index][0]*=KELVIN_TO_ENERGY; Framework[CurrentSystem].BondArguments[CurrentFramework][index][2]*=KELVIN_TO_ENERGY; Framework[CurrentSystem].BondArguments[CurrentFramework][index][3]*=KELVIN_TO_ENERGY; break; case MM3_BOND: // p_0*(r-p_1)^2*(1.0-2.55*(r-p_1)+(7.0/12.0)*2.55^2*(r-p_1)^2) // ================================================================= // p_0 [mdyne/A molecule] // p_1 [A] r=Framework[CurrentSystem].BondArguments[CurrentFramework][index][1]; if(r<1e-5) { dr.x=Framework[CurrentSystem].Atoms[CurrentFramework][A].Position.x- Framework[CurrentSystem].Atoms[CurrentFramework][B].Position.x; dr.y=Framework[CurrentSystem].Atoms[CurrentFramework][A].Position.y- Framework[CurrentSystem].Atoms[CurrentFramework][B].Position.y; dr.z=Framework[CurrentSystem].Atoms[CurrentFramework][A].Position.z- Framework[CurrentSystem].Atoms[CurrentFramework][B].Position.z; dr=ApplyBoundaryCondition(dr); r=sqrt(SQR(dr.x)+SQR(dr.y)+SQR(dr.z)); Framework[CurrentSystem].BondArguments[CurrentFramework][index][1]=r; } // MM3 input is in mdyne/A-molecule // the MM3 force field uses the factor 71.94 to convert to kcal/mole Framework[CurrentSystem].BondArguments[CurrentFramework][index][0]*=71.94*KCAL_PER_MOL_TO_ENERGY; break; case MEASURE_BOND: break; default: fprintf(stderr, "Undefined Bond potential in routine 'ReadFrameworkDefinition' ('framework.c')\n"); exit(0); break; } Framework[CurrentSystem].NumberOfBonds[CurrentFramework]++; index=Framework[CurrentSystem].NumberOfBonds[CurrentFramework]; if(index>=Framework[CurrentSystem].MaxNumberOfBonds[CurrentFramework]) { Framework[CurrentSystem].MaxNumberOfBonds[CurrentFramework]+=4096; Framework[CurrentSystem].Bonds[CurrentFramework]=(PAIR*)realloc(Framework[CurrentSystem].Bonds[CurrentFramework], Framework[CurrentSystem].MaxNumberOfBonds[CurrentFramework]*sizeof(PAIR)); if(!Framework[CurrentSystem].Bonds[CurrentFramework]) { printf("Memory reallocation error of 'Framework[CurrentSystem].Bonds[CurrentFramework]' in file %s line %d\n", __FILE__, __LINE__); exit(-1); } Framework[CurrentSystem].BondType[CurrentFramework]=(int*)realloc(Framework[CurrentSystem].BondType[CurrentFramework], Framework[CurrentSystem].MaxNumberOfBonds[CurrentFramework]*sizeof(int)); if(!Framework[CurrentSystem].BondType[CurrentFramework]) { printf("Memory reallocation error of 'Framework[CurrentSystem].BondType[CurrentFramework]' in file %s line %d\n", __FILE__, __LINE__); exit(-1); } Framework[CurrentSystem].BondArguments[CurrentFramework]=(REAL(*)[MAX_BOND_POTENTIAL_ARGUMENTS]) realloc(Framework[CurrentSystem].BondArguments[CurrentFramework], Framework[CurrentSystem].MaxNumberOfBonds[CurrentFramework]*sizeof(REAL[MAX_BOND_POTENTIAL_ARGUMENTS])); if(!Framework[CurrentSystem].BondArguments[CurrentFramework]) { printf("Memory reallocation error of 'Framework[CurrentSystem].BondArguments[CurrentFramework]' in file %s line %d\n", __FILE__, __LINE__); exit(-1); } } } } } } } } // reading Bond-Dipole-data index=0; if(Framework[CurrentSystem].NumberOfBondDipoleDefinitions>0) { Framework[CurrentSystem].BondDipoleDefinitions=(PAIR*)calloc(Framework[CurrentSystem].NumberOfBondDipoleDefinitions,sizeof(PAIR)); Framework[CurrentSystem].BondDipoleArgumentDefinition=(REAL*)calloc(Framework[CurrentSystem].NumberOfBondDipoleDefinitions,sizeof(REAL)); Framework[CurrentSystem].NumberOfBondDipolesPerType=(int*)calloc(Framework[CurrentSystem].NumberOfBondDipoleDefinitions,sizeof(int)); // allocate first dimension of bond-dipoles for(CurrentFramework=0;CurrentFramework=Framework[CurrentSystem].MaxNumberOfBondDipoles[CurrentFramework]) { Framework[CurrentSystem].MaxNumberOfBondDipoles[CurrentFramework]+=4096; Framework[CurrentSystem].BondDipoles[CurrentFramework]=(PAIR*)realloc(Framework[CurrentSystem].BondDipoles[CurrentFramework], Framework[CurrentSystem].MaxNumberOfBondDipoles[CurrentFramework]*sizeof(PAIR)); if(!Framework[CurrentSystem].BondDipoles[CurrentFramework]) { printf("Memory reallocation error of 'Framework[CurrentSystem].BondDipoles[CurrentFramework]' in file %s line %d\n", __FILE__, __LINE__); exit(-1); } Framework[CurrentSystem].BondDipoleMagnitude[CurrentFramework]=(REAL*)realloc(Framework[CurrentSystem].BondDipoleMagnitude[CurrentFramework], Framework[CurrentSystem].MaxNumberOfBondDipoles[CurrentFramework]*sizeof(REAL)); if(!Framework[CurrentSystem].BondDipoleMagnitude[CurrentFramework]) { printf("Memory reallocation error of 'Framework[CurrentSystem].BondDipoleMagnitude[CurrentFramework]' in file %s line %d\n", __FILE__, __LINE__); exit(-1); } } } } } } } } // reading Urey-Bradley-data if(Framework[CurrentSystem].NumberOfUreyBradleyDefinitions>0) { // alloc memory Framework[CurrentSystem].UreyBradleyDefinitionType=(int*)calloc(Framework[CurrentSystem].NumberOfUreyBradleyDefinitions,sizeof(int)); Framework[CurrentSystem].UreyBradleyDefinitions=(TRIPLE*)calloc(Framework[CurrentSystem].NumberOfUreyBradleyDefinitions,sizeof(TRIPLE)); Framework[CurrentSystem].UreyBradleyArgumentDefinitions=(REAL(*)[MAX_UREYBRADLEY_POTENTIAL_ARGUMENTS]) calloc(Framework[CurrentSystem].NumberOfUreyBradleyDefinitions,sizeof(REAL[MAX_UREYBRADLEY_POTENTIAL_ARGUMENTS])); Framework[CurrentSystem].NumberOfUreyBradleysPerType=(int*)calloc(Framework[CurrentSystem].NumberOfUreyBradleyDefinitions,sizeof(int)); for(CurrentFramework=0;CurrentFrameworkp_2 // =============================================== // p_0/k_B [K/A^2] // p_1 [A] // p_2 [A] Framework[CurrentSystem].UreyBradleyArguments[CurrentFramework][index][0]*=KELVIN_TO_ENERGY; break; case QUARTIC_UREYBRADLEY: // p_0*(r-p_1)^2+p_2*(r-p_1)^3+p_3*(r-p_1)^4 // =============================================== // p_0/k_B [K/A^2] // p_1 [A] // p_2/k_B [K/A^3] // p_3/k_B [K/A^4] case CFF_QUARTIC_UREYBRADLEY: // p_0*(r-p_1)^2+p_2*(r-p_1)^3+p_3*(r-p_1)^4 // =============================================== // p_0/k_B [K/A^2] // p_1 [A] // p_2/k_B [K/A^3] // p_3/k_B [K/A^4] r=Framework[CurrentSystem].UreyBradleyArguments[CurrentFramework][index][1]; if(r<1e-5) { dr.x=Framework[CurrentSystem].Atoms[CurrentFramework][A].Position.x- Framework[CurrentSystem].Atoms[CurrentFramework][C].Position.x; dr.y=Framework[CurrentSystem].Atoms[CurrentFramework][A].Position.y- Framework[CurrentSystem].Atoms[CurrentFramework][C].Position.y; dr.z=Framework[CurrentSystem].Atoms[CurrentFramework][A].Position.z- Framework[CurrentSystem].Atoms[CurrentFramework][C].Position.z; dr=ApplyBoundaryCondition(dr); r=sqrt(SQR(dr.x)+SQR(dr.y)+SQR(dr.z)); Framework[CurrentSystem].UreyBradleyArguments[CurrentFramework][index][1]=r; } Framework[CurrentSystem].UreyBradleyArguments[CurrentFramework][index][0]*=KELVIN_TO_ENERGY; Framework[CurrentSystem].UreyBradleyArguments[CurrentFramework][index][2]*=KELVIN_TO_ENERGY; Framework[CurrentSystem].UreyBradleyArguments[CurrentFramework][index][3]*=KELVIN_TO_ENERGY; break; case MM3_UREYBRADLEY: // p_0*(r-p_1)^2*(1.0-2.55*(r-p_1)+(7.0/12.0)*2.55^2*(r-p_1)^2) // ================================================================= // p_0 [mdyne/A molecule] // p_1 [A] r=Framework[CurrentSystem].UreyBradleyArguments[CurrentFramework][index][1]; if(r<1e-5) { dr.x=Framework[CurrentSystem].Atoms[CurrentFramework][A].Position.x- Framework[CurrentSystem].Atoms[CurrentFramework][C].Position.x; dr.y=Framework[CurrentSystem].Atoms[CurrentFramework][A].Position.y- Framework[CurrentSystem].Atoms[CurrentFramework][C].Position.y; dr.z=Framework[CurrentSystem].Atoms[CurrentFramework][A].Position.z- Framework[CurrentSystem].Atoms[CurrentFramework][C].Position.z; dr=ApplyBoundaryCondition(dr); r=sqrt(SQR(dr.x)+SQR(dr.y)+SQR(dr.z)); Framework[CurrentSystem].UreyBradleyArguments[CurrentFramework][index][1]=r; } // MM3 input is in mdyne/A // the MM3 force field uses the factor 71.94 to convert to kcal/mole Framework[CurrentSystem].UreyBradleyArguments[CurrentFramework][index][0]*=71.94*KCAL_PER_MOL_TO_ENERGY; break; default: fprintf(stderr, "Undefined Urey-Bradley potential in routine 'ReadFrameworkDefinition' ('framework.c')\n"); exit(0); break; } Framework[CurrentSystem].NumberOfUreyBradleys[CurrentFramework]++; index=Framework[CurrentSystem].NumberOfUreyBradleys[CurrentFramework]; if(index>=Framework[CurrentSystem].MaxNumberOfUreyBradleys[CurrentFramework]) { Framework[CurrentSystem].MaxNumberOfUreyBradleys[CurrentFramework]+=4096; Framework[CurrentSystem].UreyBradleys[CurrentFramework]=(TRIPLE*)realloc(Framework[CurrentSystem].UreyBradleys[CurrentFramework], Framework[CurrentSystem].MaxNumberOfUreyBradleys[CurrentFramework]*sizeof(TRIPLE)); if(!Framework[CurrentSystem].UreyBradleys[CurrentFramework]) { printf("Memory reallocation error of 'Framework[CurrentSystem].UreyBradleys[CurrentFramework]' in file %s line %d\n", __FILE__, __LINE__); exit(-1); } Framework[CurrentSystem].UreyBradleyType[CurrentFramework]=(int*)realloc(Framework[CurrentSystem].UreyBradleyType[CurrentFramework], Framework[CurrentSystem].MaxNumberOfUreyBradleys[CurrentFramework]*sizeof(int)); if(!Framework[CurrentSystem].UreyBradleyType[CurrentFramework]) { printf("Memory reallocation error of 'Framework[CurrentSystem].UreyBradleyType[CurrentFramework]' in file %s line %d\n", __FILE__, __LINE__); exit(-1); } Framework[CurrentSystem].UreyBradleyArguments[CurrentFramework]=(REAL(*)[MAX_UREYBRADLEY_POTENTIAL_ARGUMENTS]) realloc(Framework[CurrentSystem].UreyBradleyArguments[CurrentFramework], Framework[CurrentSystem].MaxNumberOfUreyBradleys[CurrentFramework]*sizeof(REAL[MAX_UREYBRADLEY_POTENTIAL_ARGUMENTS])); if(!Framework[CurrentSystem].UreyBradleyArguments[CurrentFramework]) { printf("Memory reallocation error of 'Framework[CurrentSystem].UreyBradleyArguments[CurrentFramework]' in file %s line %d\n", __FILE__, __LINE__); exit(-1); } } } } } } } } } } // reading Bend-data if(Framework[CurrentSystem].NumberOfBendDefinitions>0) { // alloc memory Framework[CurrentSystem].BendDefinitionType=(int*)calloc(Framework[CurrentSystem].NumberOfBendDefinitions,sizeof(int)); Framework[CurrentSystem].BendDefinitions=(QUAD*)calloc(Framework[CurrentSystem].NumberOfBendDefinitions,sizeof(QUAD)); Framework[CurrentSystem].BendArgumentDefinitions=(REAL(*)[MAX_BEND_POTENTIAL_ARGUMENTS]) calloc(Framework[CurrentSystem].NumberOfBendDefinitions,sizeof(REAL[MAX_BEND_POTENTIAL_ARGUMENTS])); Framework[CurrentSystem].NumberOfBendsPerType=(int*)calloc(Framework[CurrentSystem].NumberOfBendDefinitions,sizeof(int)); for(CurrentFramework=0;CurrentFramework0) { for(k=0;k0) { // loop not over the core, but its shell A=Framework[CurrentSystem].CoreShellConnectivity[CurrentFramework][A]; CurrentTypeA=Framework[CurrentSystem].Atoms[CurrentFramework][A].Type; for(l=0;l0) { // loop not over the core, but its shell C=Framework[CurrentSystem].CoreShellConnectivity[CurrentFramework][C]; CurrentTypeC=Framework[CurrentSystem].Atoms[CurrentFramework][C].Type; // A=Framework[CurrentSystem].MaxNumberOfBends[CurrentFramework]) { Framework[CurrentSystem].MaxNumberOfBends[CurrentFramework]+=4096; Framework[CurrentSystem].Bends[CurrentFramework]=(QUAD*)realloc(Framework[CurrentSystem].Bends[CurrentFramework], Framework[CurrentSystem].MaxNumberOfBends[CurrentFramework]*sizeof(QUAD)); if(!Framework[CurrentSystem].Bends[CurrentFramework]) { printf("Memory reallocation error of 'Framework[CurrentSystem].Bends[CurrentFramework]' in file %s line %d\n", __FILE__, __LINE__); exit(-1); } Framework[CurrentSystem].BendType[CurrentFramework]=(int*)realloc(Framework[CurrentSystem].BendType[CurrentFramework], Framework[CurrentSystem].MaxNumberOfBends[CurrentFramework]*sizeof(int)); if(!Framework[CurrentSystem].BendType[CurrentFramework]) { printf("Memory reallocation error of 'Framework[CurrentSystem].BendType[CurrentFramework]' in file %s line %d\n", __FILE__, __LINE__); exit(-1); } Framework[CurrentSystem].BendArguments[CurrentFramework]=(REAL(*)[MAX_BEND_POTENTIAL_ARGUMENTS]) realloc(Framework[CurrentSystem].BendArguments[CurrentFramework], Framework[CurrentSystem].MaxNumberOfBends[CurrentFramework]*sizeof(REAL[MAX_BEND_POTENTIAL_ARGUMENTS])); if(!Framework[CurrentSystem].BendArguments[CurrentFramework]) { printf("Memory reallocation error of 'Framework[CurrentSystem].BendArguments[CurrentFramework]' in file %s line %d\n", __FILE__, __LINE__); exit(-1); } } } } } } } } } for(k=0;k=Framework[CurrentSystem].MaxNumberOfBends[CurrentFramework]) { Framework[CurrentSystem].MaxNumberOfBends[CurrentFramework]+=4096; Framework[CurrentSystem].Bends[CurrentFramework]=(QUAD*)realloc(Framework[CurrentSystem].Bends[CurrentFramework], Framework[CurrentSystem].MaxNumberOfBends[CurrentFramework]*sizeof(QUAD)); if(!Framework[CurrentSystem].Bends[CurrentFramework]) { printf("Memory reallocation error of 'Framework[CurrentSystem].Bends[CurrentFramework]' in file %s line %d\n", __FILE__, __LINE__); exit(-1); } Framework[CurrentSystem].BendType[CurrentFramework]=(int*)realloc(Framework[CurrentSystem].BendType[CurrentFramework], Framework[CurrentSystem].MaxNumberOfBends[CurrentFramework]*sizeof(int)); if(!Framework[CurrentSystem].BendType[CurrentFramework]) { printf("Memory reallocation error of 'Framework[CurrentSystem].BendType[CurrentFramework]' in file %s line %d\n", __FILE__, __LINE__); exit(-1); } Framework[CurrentSystem].BendArguments[CurrentFramework]=(REAL(*)[MAX_BEND_POTENTIAL_ARGUMENTS]) realloc(Framework[CurrentSystem].BendArguments[CurrentFramework], Framework[CurrentSystem].MaxNumberOfBends[CurrentFramework]*sizeof(REAL[MAX_BEND_POTENTIAL_ARGUMENTS])); if(!Framework[CurrentSystem].BendArguments[CurrentFramework]) { printf("Memory reallocation error of 'Framework[CurrentSystem].BendArguments[CurrentFramework]' in file %s line %d\n", __FILE__, __LINE__); exit(-1); } } } } } } } } } } } // reading InversionBend-data index=0; if(Framework[CurrentSystem].NumberOfInversionBendDefinitions>0) { // alloc memory Framework[CurrentSystem].InversionBendDefinitionType=(int*)calloc(Framework[CurrentSystem].NumberOfInversionBendDefinitions,sizeof(int)); Framework[CurrentSystem].InversionBendDefinitions=(QUAD*)calloc(Framework[CurrentSystem].NumberOfInversionBendDefinitions,sizeof(QUAD)); Framework[CurrentSystem].InversionBendArgumentDefinitions=(REAL(*)[MAX_INVERSION_BEND_POTENTIAL_ARGUMENTS]) calloc(Framework[CurrentSystem].NumberOfInversionBendDefinitions,sizeof(REAL[MAX_INVERSION_BEND_POTENTIAL_ARGUMENTS])); Framework[CurrentSystem].NumberOfInversionBendsPerType=(int*)calloc(Framework[CurrentSystem].NumberOfInversionBendDefinitions,sizeof(int)); for(CurrentFramework=0;CurrentFramework=Framework[CurrentSystem].MaxNumberOfInversionBends[CurrentFramework]) { Framework[CurrentSystem].MaxNumberOfInversionBends[CurrentFramework]+=4096; Framework[CurrentSystem].InversionBends[CurrentFramework]=(QUAD*)realloc(Framework[CurrentSystem].InversionBends[CurrentFramework], Framework[CurrentSystem].MaxNumberOfInversionBends[CurrentFramework]*sizeof(QUAD)); if(!Framework[CurrentSystem].InversionBends[CurrentFramework]) { printf("Memory reallocation error of 'Framework[CurrentSystem].InversionBends[CurrentFramework]' in file %s line %d\n", __FILE__, __LINE__); exit(-1); } Framework[CurrentSystem].InversionBendType[CurrentFramework]=(int*)realloc(Framework[CurrentSystem].InversionBendType[CurrentFramework], Framework[CurrentSystem].MaxNumberOfInversionBends[CurrentFramework]*sizeof(int)); if(!Framework[CurrentSystem].InversionBendType[CurrentFramework]) { printf("Memory reallocation error of 'Framework[CurrentSystem].InversionBendType[CurrentFramework]' in file %s line %d\n", __FILE__, __LINE__); exit(-1); } Framework[CurrentSystem].InversionBendArguments[CurrentFramework]=(REAL(*)[MAX_INVERSION_BEND_POTENTIAL_ARGUMENTS]) realloc(Framework[CurrentSystem].InversionBendArguments[CurrentFramework], Framework[CurrentSystem].MaxNumberOfInversionBends[CurrentFramework]*sizeof(REAL[MAX_INVERSION_BEND_POTENTIAL_ARGUMENTS])); if(!Framework[CurrentSystem].InversionBendArguments[CurrentFramework]) { printf("Memory reallocation error of 'Framework[CurrentSystem].InversionBendArguments[CurrentFramework]' in file %s line %d\n", __FILE__, __LINE__); exit(-1); } } } } } } } } } } } } } } // determine the fourth atom for in-plane bends by searching the bends in the list of inversion-bends for(CurrentFramework=0;CurrentFramework0) { // alloc memory Framework[CurrentSystem].TorsionDefinitionType=(int*)calloc(Framework[CurrentSystem].NumberOfTorsionDefinitions,sizeof(int)); Framework[CurrentSystem].TorsionDefinitions=(QUAD*)calloc(Framework[CurrentSystem].NumberOfTorsionDefinitions,sizeof(QUAD)); Framework[CurrentSystem].TorsionArgumentDefinitions=(REAL(*)[MAX_TORSION_POTENTIAL_ARGUMENTS]) calloc(Framework[CurrentSystem].NumberOfTorsionDefinitions,sizeof(REAL[MAX_TORSION_POTENTIAL_ARGUMENTS])); Framework[CurrentSystem].NumberOfTorsionsPerType=(int*)calloc(Framework[CurrentSystem].NumberOfTorsionDefinitions,sizeof(int)); for(CurrentFramework=0;CurrentFramework=1) { arguments[j]=(REAL)temp; arg_pointer+=n; } } Framework[CurrentSystem].TorsionDefinitionType[i]=TorsionType; Framework[CurrentSystem].TorsionDefinitions[i].A=TypeA; Framework[CurrentSystem].TorsionDefinitions[i].B=TypeB; Framework[CurrentSystem].TorsionDefinitions[i].C=TypeC; Framework[CurrentSystem].TorsionDefinitions[i].D=TypeD; for(j=0;j=Framework[CurrentSystem].MaxNumberOfTorsions[CurrentFramework]) { Framework[CurrentSystem].MaxNumberOfTorsions[CurrentFramework]+=4096; Framework[CurrentSystem].Torsions[CurrentFramework]=(QUAD*)realloc(Framework[CurrentSystem].Torsions[CurrentFramework], Framework[CurrentSystem].MaxNumberOfTorsions[CurrentFramework]*sizeof(QUAD)); if(!Framework[CurrentSystem].Torsions[CurrentFramework]) { printf("Memory reallocation error of 'Framework[CurrentSystem].Torsions[CurrentFramework]' in file %s line %d\n", __FILE__, __LINE__); exit(-1); } Framework[CurrentSystem].TorsionType[CurrentFramework]=(int*)realloc(Framework[CurrentSystem].TorsionType[CurrentFramework], Framework[CurrentSystem].MaxNumberOfTorsions[CurrentFramework]*sizeof(int)); if(!Framework[CurrentSystem].TorsionType[CurrentFramework]) { printf("Memory reallocation error of 'Framework[CurrentSystem].TorsionType[CurrentFramework]' in file %s line %d\n", __FILE__, __LINE__); exit(-1); } Framework[CurrentSystem].TorsionArguments[CurrentFramework]=(REAL(*)[MAX_TORSION_POTENTIAL_ARGUMENTS]) realloc(Framework[CurrentSystem].TorsionArguments[CurrentFramework], Framework[CurrentSystem].MaxNumberOfTorsions[CurrentFramework]*sizeof(REAL[MAX_TORSION_POTENTIAL_ARGUMENTS])); if(!Framework[CurrentSystem].TorsionArguments[CurrentFramework]) { printf("Memory reallocation error of 'Framework[CurrentSystem].TorsionArguments[CurrentFramework]' in file %s line %d\n", __FILE__, __LINE__); exit(-1); } } } } } } } } } } } } } } // reading Improper torsion-data if(Framework[CurrentSystem].NumberOfImproperTorsionDefinitions>0) { // alloc memory Framework[CurrentSystem].ImproperTorsionDefinitionType=(int*)calloc(Framework[CurrentSystem].NumberOfImproperTorsionDefinitions,sizeof(int)); Framework[CurrentSystem].ImproperTorsionDefinitions=(QUAD*)calloc(Framework[CurrentSystem].NumberOfImproperTorsionDefinitions,sizeof(QUAD)); Framework[CurrentSystem].ImproperTorsionArgumentDefinitions=(REAL(*)[MAX_IMPROPER_TORSION_POTENTIAL_ARGUMENTS]) calloc(Framework[CurrentSystem].NumberOfImproperTorsionDefinitions,sizeof(REAL[MAX_IMPROPER_TORSION_POTENTIAL_ARGUMENTS])); Framework[CurrentSystem].NumberOfImproperTorsionsPerType=(int*)calloc(Framework[CurrentSystem].NumberOfImproperTorsionDefinitions,sizeof(int)); for(CurrentFramework=0;CurrentFramework=Framework[CurrentSystem].MaxNumberOfImproperTorsions[CurrentFramework]) { Framework[CurrentSystem].MaxNumberOfImproperTorsions[CurrentFramework]+=4096; Framework[CurrentSystem].ImproperTorsions[CurrentFramework]=(QUAD*)realloc(Framework[CurrentSystem].ImproperTorsions[CurrentFramework], Framework[CurrentSystem].MaxNumberOfImproperTorsions[CurrentFramework]*sizeof(QUAD)); if(!Framework[CurrentSystem].ImproperTorsions[CurrentFramework]) { printf("Memory reallocation error of 'Framework[CurrentSystem].ImproperTorsions[CurrentFramework]' in file %s line %d\n", __FILE__, __LINE__); exit(-1); } Framework[CurrentSystem].ImproperTorsionType[CurrentFramework]=(int*)realloc(Framework[CurrentSystem].ImproperTorsionType[CurrentFramework], Framework[CurrentSystem].MaxNumberOfImproperTorsions[CurrentFramework]*sizeof(int)); if(!Framework[CurrentSystem].ImproperTorsionType[CurrentFramework]) { printf("Memory reallocation error of 'Framework[CurrentSystem].ImproperTorsionType[CurrentFramework]' in file %s line %d\n", __FILE__, __LINE__); exit(-1); } Framework[CurrentSystem].ImproperTorsionArguments[CurrentFramework]=(REAL(*)[MAX_IMPROPER_TORSION_POTENTIAL_ARGUMENTS]) realloc(Framework[CurrentSystem].ImproperTorsionArguments[CurrentFramework], Framework[CurrentSystem].MaxNumberOfImproperTorsions[CurrentFramework]*sizeof(REAL[MAX_IMPROPER_TORSION_POTENTIAL_ARGUMENTS])); if(!Framework[CurrentSystem].ImproperTorsionArguments[CurrentFramework]) { printf("Memory reallocation error of 'Framework[CurrentSystem].ImproperTorsionArguments[CurrentFramework]' in file %s line %d\n", __FILE__, __LINE__); exit(-1); } } } } } } } } } } } } } } // READ OUT_OF_PLANE TODO // reading Bond-Bond cross-term data index=0; if(Framework[CurrentSystem].NumberOfBondBondDefinitions>0) { // alloc memory Framework[CurrentSystem].BondBondDefinitionType=(int*)calloc(Framework[CurrentSystem].NumberOfBondBondDefinitions,sizeof(int)); Framework[CurrentSystem].BondBondDefinitions=(TRIPLE*)calloc(Framework[CurrentSystem].NumberOfBondBondDefinitions,sizeof(TRIPLE)); Framework[CurrentSystem].BondBondArgumentDefinitions=(REAL(*)[MAX_BOND_BOND_POTENTIAL_ARGUMENTS]) calloc(Framework[CurrentSystem].NumberOfBondBondDefinitions,sizeof(REAL[MAX_BOND_BOND_POTENTIAL_ARGUMENTS])); Framework[CurrentSystem].NumberOfBondBondsPerType=(int*)calloc(Framework[CurrentSystem].NumberOfBondBondDefinitions,sizeof(int)); for(CurrentFramework=0;CurrentFramework=Framework[CurrentSystem].MaxNumberOfBondBonds[CurrentFramework]) { Framework[CurrentSystem].MaxNumberOfBondBonds[CurrentFramework]+=4096; Framework[CurrentSystem].BondBonds[CurrentFramework]=(TRIPLE*)realloc(Framework[CurrentSystem].BondBonds[CurrentFramework], Framework[CurrentSystem].MaxNumberOfBondBonds[CurrentFramework]*sizeof(TRIPLE)); if(!Framework[CurrentSystem].BondBonds[CurrentFramework]) { printf("Memory reallocation error of 'Framework[CurrentSystem].BondBonds[CurrentFramework]' in file %s line %d\n", __FILE__, __LINE__); exit(-1); } Framework[CurrentSystem].BondBondType[CurrentFramework]=(int*)realloc(Framework[CurrentSystem].BondBondType[CurrentFramework], Framework[CurrentSystem].MaxNumberOfBondBonds[CurrentFramework]*sizeof(int)); if(!Framework[CurrentSystem].BondBondType[CurrentFramework]) { printf("Memory reallocation error of 'Framework[CurrentSystem].BondBondType[CurrentFramework]' in file %s line %d\n", __FILE__, __LINE__); exit(-1); } Framework[CurrentSystem].BondBondArguments[CurrentFramework]=(REAL(*)[MAX_BOND_BOND_POTENTIAL_ARGUMENTS]) realloc(Framework[CurrentSystem].BondBondArguments[CurrentFramework], Framework[CurrentSystem].MaxNumberOfBondBonds[CurrentFramework]*sizeof(REAL[MAX_BOND_BOND_POTENTIAL_ARGUMENTS])); if(!Framework[CurrentSystem].BondBondArguments[CurrentFramework]) { printf("Memory reallocation error of 'Framework[CurrentSystem].BondBondArguments[CurrentFramework]' in file %s line %d\n", __FILE__, __LINE__); exit(-1); } } } } } } } } } } } } // reading Bond-Bend cross-term data index=0; if(Framework[CurrentSystem].NumberOfBondBendDefinitions>0) { // alloc memory Framework[CurrentSystem].BondBendDefinitionType=(int*)calloc(Framework[CurrentSystem].NumberOfBondBendDefinitions,sizeof(int)); Framework[CurrentSystem].BondBendDefinitions=(TRIPLE*)calloc(Framework[CurrentSystem].NumberOfBondBendDefinitions,sizeof(TRIPLE)); Framework[CurrentSystem].BondBendArgumentDefinitions=(REAL(*)[MAX_BOND_BEND_POTENTIAL_ARGUMENTS]) calloc(Framework[CurrentSystem].NumberOfBondBendDefinitions,sizeof(REAL[MAX_BOND_BEND_POTENTIAL_ARGUMENTS])); Framework[CurrentSystem].NumberOfBondBendsPerType=(int*)calloc(Framework[CurrentSystem].NumberOfBondBendDefinitions,sizeof(int)); for(CurrentFramework=0;CurrentFramework=Framework[CurrentSystem].MaxNumberOfBondBends[CurrentFramework]) { Framework[CurrentSystem].MaxNumberOfBondBends[CurrentFramework]+=4096; Framework[CurrentSystem].BondBends[CurrentFramework]=(TRIPLE*)realloc(Framework[CurrentSystem].BondBends[CurrentFramework], Framework[CurrentSystem].MaxNumberOfBondBends[CurrentFramework]*sizeof(TRIPLE)); if(!Framework[CurrentSystem].BondBends[CurrentFramework]) { printf("Memory reallocation error of 'Framework[CurrentSystem].BondBends[CurrentFramework]' in file %s line %d\n", __FILE__, __LINE__); exit(-1); } Framework[CurrentSystem].BondBendType[CurrentFramework]=(int*)realloc(Framework[CurrentSystem].BondBendType[CurrentFramework], Framework[CurrentSystem].MaxNumberOfBondBends[CurrentFramework]*sizeof(int)); if(!Framework[CurrentSystem].BondBendType[CurrentFramework]) { printf("Memory reallocation error of 'Framework[CurrentSystem].BondBendType[CurrentFramework]' in file %s line %d\n", __FILE__, __LINE__); exit(-1); } Framework[CurrentSystem].BondBendArguments[CurrentFramework]=(REAL(*)[MAX_BOND_BEND_POTENTIAL_ARGUMENTS]) realloc(Framework[CurrentSystem].BondBendArguments[CurrentFramework], Framework[CurrentSystem].MaxNumberOfBondBends[CurrentFramework]*sizeof(REAL[MAX_BOND_BEND_POTENTIAL_ARGUMENTS])); if(!Framework[CurrentSystem].BondBendArguments[CurrentFramework]) { printf("Memory reallocation error of 'Framework[CurrentSystem].BondBendArguments[CurrentFramework]' in file %s line %d\n", __FILE__, __LINE__); exit(-1); } } } } } } } } } } } // reading Bend-Bend cross-term data index=0; if(Framework[CurrentSystem].NumberOfBendBendDefinitions>0) { // alloc memory Framework[CurrentSystem].BendBendDefinitionType=(int*)calloc(Framework[CurrentSystem].NumberOfBendBendDefinitions,sizeof(int)); Framework[CurrentSystem].BendBendDefinitions=(QUAD*)calloc(Framework[CurrentSystem].NumberOfBendBendDefinitions,sizeof(QUAD)); Framework[CurrentSystem].BendBendArgumentDefinitions=(REAL(*)[MAX_BEND_BEND_POTENTIAL_ARGUMENTS]) calloc(Framework[CurrentSystem].NumberOfBendBendDefinitions,sizeof(REAL[MAX_BEND_BEND_POTENTIAL_ARGUMENTS])); Framework[CurrentSystem].NumberOfBendBendsPerType=(int*)calloc(Framework[CurrentSystem].NumberOfBendBendDefinitions,sizeof(int)); for(CurrentFramework=0;CurrentFramework=Framework[CurrentSystem].MaxNumberOfBendBends[CurrentFramework]) { Framework[CurrentSystem].MaxNumberOfBendBends[CurrentFramework]+=4096; Framework[CurrentSystem].BendBends[CurrentFramework]=(QUAD*)realloc(Framework[CurrentSystem].BendBends[CurrentFramework], Framework[CurrentSystem].MaxNumberOfBendBends[CurrentFramework]*sizeof(QUAD)); if(!Framework[CurrentSystem].BendBends[CurrentFramework]) { printf("Memory reallocation error of 'Framework[CurrentSystem].BendBends[CurrentFramework]' in file %s line %d\n", __FILE__, __LINE__); exit(-1); } Framework[CurrentSystem].BendBendType[CurrentFramework]=(int*)realloc(Framework[CurrentSystem].BendBendType[CurrentFramework], Framework[CurrentSystem].MaxNumberOfBendBends[CurrentFramework]*sizeof(int)); if(!Framework[CurrentSystem].BendBendType[CurrentFramework]) { printf("Memory reallocation error of 'Framework[CurrentSystem].BendBendType[CurrentFramework]' in file %s line %d\n", __FILE__, __LINE__); exit(-1); } Framework[CurrentSystem].BendBendArguments[CurrentFramework]=(REAL(*)[MAX_BEND_BEND_POTENTIAL_ARGUMENTS]) realloc(Framework[CurrentSystem].BendBendArguments[CurrentFramework], Framework[CurrentSystem].MaxNumberOfBendBends[CurrentFramework]*sizeof(REAL[MAX_BEND_BEND_POTENTIAL_ARGUMENTS])); if(!Framework[CurrentSystem].BendBendArguments[CurrentFramework]) { printf("Memory reallocation error of 'Framework[CurrentSystem].BendBendArguments[CurrentFramework]' in file %s line %d\n", __FILE__, __LINE__); exit(-1); } } } } } } } } } } } } } } // reading Bond/Torsion-data if(Framework[CurrentSystem].NumberOfBondTorsionDefinitions>0) { // alloc memory Framework[CurrentSystem].BondTorsionDefinitionType=(int*)calloc(Framework[CurrentSystem].NumberOfBondTorsionDefinitions,sizeof(int)); Framework[CurrentSystem].BondTorsionDefinitions=(QUAD*)calloc(Framework[CurrentSystem].NumberOfBondTorsionDefinitions,sizeof(QUAD)); Framework[CurrentSystem].BondTorsionArgumentDefinitions=(REAL(*)[MAX_BOND_TORSION_POTENTIAL_ARGUMENTS]) calloc(Framework[CurrentSystem].NumberOfBondTorsionDefinitions,sizeof(REAL[MAX_BOND_TORSION_POTENTIAL_ARGUMENTS])); Framework[CurrentSystem].NumberOfBondTorsionsPerType=(int*)calloc(Framework[CurrentSystem].NumberOfBondTorsionDefinitions,sizeof(int)); for(CurrentFramework=0;CurrentFramework=Framework[CurrentSystem].MaxNumberOfBondTorsions[CurrentFramework]) { Framework[CurrentSystem].MaxNumberOfBondTorsions[CurrentFramework]+=4096; Framework[CurrentSystem].BondTorsions[CurrentFramework]=(QUAD*)realloc(Framework[CurrentSystem].BondTorsions[CurrentFramework], Framework[CurrentSystem].MaxNumberOfBondTorsions[CurrentFramework]*sizeof(QUAD)); if(!Framework[CurrentSystem].BondTorsions[CurrentFramework]) { printf("Memory reallocation error of 'Framework[CurrentSystem].BondTorsions[CurrentFramework]' in file %s line %d\n", __FILE__, __LINE__); exit(-1); } Framework[CurrentSystem].BondTorsionType[CurrentFramework]=(int*)realloc(Framework[CurrentSystem].BondTorsionType[CurrentFramework], Framework[CurrentSystem].MaxNumberOfBondTorsions[CurrentFramework]*sizeof(int)); if(!Framework[CurrentSystem].BondTorsionType[CurrentFramework]) { printf("Memory reallocation error of 'Framework[CurrentSystem].BondTorsionType[CurrentFramework]' in file %s line %d\n", __FILE__, __LINE__); exit(-1); } Framework[CurrentSystem].BondTorsionArguments[CurrentFramework]=(REAL(*)[MAX_BOND_TORSION_POTENTIAL_ARGUMENTS]) realloc(Framework[CurrentSystem].BondTorsionArguments[CurrentFramework], Framework[CurrentSystem].MaxNumberOfBondTorsions[CurrentFramework]*sizeof(REAL[MAX_BOND_TORSION_POTENTIAL_ARGUMENTS])); if(!Framework[CurrentSystem].BondTorsionArguments[CurrentFramework]) { printf("Memory reallocation error of 'Framework[CurrentSystem].BondTorsionArguments[CurrentFramework]' in file %s line %d\n", __FILE__, __LINE__); exit(-1); } } } } } } } } } } } } } // reading Bend/Torsion-data index=0; if(Framework[CurrentSystem].NumberOfBendTorsionDefinitions>0) { // alloc memory Framework[CurrentSystem].BendTorsionDefinitionType=(int*)calloc(Framework[CurrentSystem].NumberOfBendTorsionDefinitions,sizeof(int)); Framework[CurrentSystem].BendTorsionDefinitions=(QUAD*)calloc(Framework[CurrentSystem].NumberOfBendTorsionDefinitions,sizeof(QUAD)); Framework[CurrentSystem].BendTorsionArgumentDefinitions=(REAL(*)[MAX_BEND_TORSION_POTENTIAL_ARGUMENTS]) calloc(Framework[CurrentSystem].NumberOfBendTorsionDefinitions,sizeof(REAL[MAX_BEND_TORSION_POTENTIAL_ARGUMENTS])); Framework[CurrentSystem].NumberOfBendTorsionsPerType=(int*)calloc(Framework[CurrentSystem].NumberOfBendTorsionDefinitions,sizeof(int)); for(CurrentFramework=0;CurrentFramework=Framework[CurrentSystem].MaxNumberOfBendTorsions[CurrentFramework]) { Framework[CurrentSystem].MaxNumberOfBendTorsions[CurrentFramework]+=4096; Framework[CurrentSystem].BendTorsions[CurrentFramework]=(QUAD*)realloc(Framework[CurrentSystem].BendTorsions[CurrentFramework], Framework[CurrentSystem].MaxNumberOfBendTorsions[CurrentFramework]*sizeof(QUAD)); if(!Framework[CurrentSystem].BendTorsions[CurrentFramework]) { printf("Memory reallocation error of 'Framework[CurrentSystem].BendTorsions[CurrentFramework]' in file %s line %d\n", __FILE__, __LINE__); exit(-1); } Framework[CurrentSystem].BendTorsionType[CurrentFramework]=(int*)realloc(Framework[CurrentSystem].BendTorsionType[CurrentFramework], Framework[CurrentSystem].MaxNumberOfBendTorsions[CurrentFramework]*sizeof(int)); if(!Framework[CurrentSystem].BendTorsionType[CurrentFramework]) { printf("Memory reallocation error of 'Framework[CurrentSystem].BendTorsionType[CurrentFramework]' in file %s line %d\n", __FILE__, __LINE__); exit(-1); } Framework[CurrentSystem].BendTorsionArguments[CurrentFramework]=(REAL(*)[MAX_BEND_TORSION_POTENTIAL_ARGUMENTS]) realloc(Framework[CurrentSystem].BendTorsionArguments[CurrentFramework], Framework[CurrentSystem].MaxNumberOfBendTorsions[CurrentFramework]*sizeof(REAL[MAX_BEND_TORSION_POTENTIAL_ARGUMENTS])); if(!Framework[CurrentSystem].BendTorsionArguments[CurrentFramework]) { printf("Memory reallocation error of 'Framework[CurrentSystem].BendTorsionArguments[CurrentFramework]' in file %s line %d\n", __FILE__, __LINE__); exit(-1); } } } } } } } } } } } } } } fprintf(stderr, "Number of bonds: %d %d %d\n",Framework[0].NumberOfBonds[0],CurrentSystem,CurrentFramework); return 0; } int IsDefinedBondType(int system,int f1,int A,int B) { int i; int typeA,typeB; A%=Framework[system].NumberOfAtoms[f1]; B%=Framework[system].NumberOfAtoms[f1]; typeA=Framework[system].Atoms[f1][A].Type; typeB=Framework[system].Atoms[f1][B].Type; for(i=0;i=0)) { SETBIT(Framework[system].ExclusionMatrix[f1][A][index1],2); if(B=0)) { if(C=0)) SETBIT(Framework[system].ExclusionMatrix[f1][A][index1],2); } for(m=0;m=0)) SETBIT(Framework[system].ExclusionMatrix[f1][D][index1],2); index1=ReturnDipoleIndex(f1,C,D); if(Remove13NeighboursFromChargeBondDipoleInteraction&&(index1>=0)) SETBIT(Framework[system].ExclusionMatrix[f1][A][index1],2); } } } } } } // set general 1-2, 1-3, 1-4 exclusions for charge-bonddipole exclusion-list // charge-bonddipole exclusion in Fourier-space is based on the unit-cell using 'GetNeighbour' for(f1=0;f1=0)) { SETBIT(Framework[system].ExclusionMatrix[f1][A][index1],5); if(B=0)) { if(C=0)) SETBIT(Framework[system].ExclusionMatrix[f1][A][index1],5); } for(m=0;m=0)) SETBIT(Framework[system].ExclusionMatrix[f1][D][index1],5); index1=ReturnDipoleIndex(f1,C,D); if(Remove13NeighboursFromChargeBondDipoleInteraction&&(index1>=0)) SETBIT(Framework[system].ExclusionMatrix[f1][A][index1],5); } } } } } } // Bonddipole-bonddipole // ============================================================================================== // set general 1-2, 1-3, 1-4 exclusions for bonddipole-bonddipole interactions // bonddipole-bonddipole is based on replica-method using 'GetReplicaNeighbour' for(f1=0;f1=0)&&(index2>=0)) { SETBIT(Framework[system].ExclusionMatrix[f1][index1][index2],3); SETBIT(Framework[system].ExclusionMatrix[f1][index2][index1],3); } } for(m=0;m=0)&&(index2>=0)) { SETBIT(Framework[system].ExclusionMatrix[f1][index1][index2],3); SETBIT(Framework[system].ExclusionMatrix[f1][index2][index1],3); } } } } } } } // set general 1-2, 1-3, 1-4 exclusions for bonddipole-bonddipole exclusion-list // bonddipole-bonddipole exclusion in Fourier-space is based on the unit-cell using 'GetNeighbour' for(f1=0;f1=0)&&(index2>=0)) { SETBIT(Framework[system].ExclusionMatrix[f1][index1][index2],6); SETBIT(Framework[system].ExclusionMatrix[f1][index2][index1],6); } } for(m=0;m=0)&&(index2>=0)) { SETBIT(Framework[system].ExclusionMatrix[f1][index1][index2],6); SETBIT(Framework[system].ExclusionMatrix[f1][index2][index1],6); } } } } } } } } void MakeExcludedInteractionLists(int system) { int i,j,f1; int index_excluded; int TypeA,TypeB; // make lists for exclusion in the Ewald summation (subtraction using 'erf') // count the amount of interactions and exclusions for(f1=0;f10) { // loop over shells for(A=0;A0) { MassA=PseudoAtoms[Framework[CurrentSystem].Atoms[f1][A].Type].Mass; MassB=PseudoAtoms[Framework[CurrentSystem].Atoms[f1][B].Type].Mass; rmu=MassA*MassB/(MassA+MassB); dv.x=Framework[CurrentSystem].Atoms[f1][B].Velocity.x-Framework[CurrentSystem].Atoms[f1][A].Velocity.x; dv.y=Framework[CurrentSystem].Atoms[f1][B].Velocity.y-Framework[CurrentSystem].Atoms[f1][A].Velocity.y; dv.z=Framework[CurrentSystem].Atoms[f1][B].Velocity.z-Framework[CurrentSystem].Atoms[f1][A].Velocity.z; scale=sqrt(pke/(rmu*(SQR(dv.x)+SQR(dv.y)+SQR(dv.z)))); tm.x=MassA*Framework[CurrentSystem].Atoms[f1][A].Velocity.x+ MassB*Framework[CurrentSystem].Atoms[f1][B].Velocity.x; tm.y=MassA*Framework[CurrentSystem].Atoms[f1][A].Velocity.y+ MassB*Framework[CurrentSystem].Atoms[f1][B].Velocity.y; tm.z=MassA*Framework[CurrentSystem].Atoms[f1][A].Velocity.z+ MassB*Framework[CurrentSystem].Atoms[f1][B].Velocity.z; Framework[CurrentSystem].Atoms[f1][A].Velocity.x=tm.x/(MassA+MassB)-scale*rmu*dv.x/MassA; Framework[CurrentSystem].Atoms[f1][B].Velocity.x=tm.x/(MassA+MassB)+scale*rmu*dv.x/MassB; Framework[CurrentSystem].Atoms[f1][A].Velocity.y=tm.y/(MassA+MassB)-scale*rmu*dv.y/MassA; Framework[CurrentSystem].Atoms[f1][B].Velocity.y=tm.y/(MassA+MassB)+scale*rmu*dv.y/MassB; Framework[CurrentSystem].Atoms[f1][A].Velocity.z=tm.z/(MassA+MassB)-scale*rmu*dv.z/MassA; Framework[CurrentSystem].Atoms[f1][B].Velocity.z=tm.z/(MassA+MassB)+scale*rmu*dv.z/MassB; } } } } } int CheckSurfaceAreaOverlap(int typeA,VECTOR posA,int skipf,int skipfa,int skipcm,int skipca) { int j,m; int typeB,f1; VECTOR dr,posB; REAL rr,well_depth_factor; if(BlockedPocket(posA)||(!ValidCartesianPoint(CurrentComponent,posA))) return TRUE; well_depth_factor=Framework[CurrentSystem].SurfaceAreaProbeDistance; // check overlap with framework for(f1=0;f11e-10) temp=DipoleMagnitudeA/length; else temp=0.0; Dipole.x*=temp; Dipole.y*=temp; Dipole.z*=temp; Framework[CurrentSystem].BondDipoleVector[CurrentFramework][i]=Dipole; Framework[CurrentSystem].BondLength[CurrentFramework][i]=length; } } */ } // returns TRUE when an asymmetric atom is find (it is stored in 'r'), // otherwise FALSE is returned int FindAsymmetricAtom(int sg,VECTOR s,VECTOR *r) { int i; int k1,k2,k3; VECTOR t; s.x-=NINT(s.x); s.y-=NINT(s.y); s.z-=NINT(s.z); if(s.x<0.0) s.x+=1.0; if(s.y<0.0) s.y+=1.0; if(s.z<0.0) s.z+=1.0; // try all inverse transformation and find one that lies in the asymmetric unit cell SpaceGroupInverseSymmetry(sg,s); for(i=0;iFramework[CurrentSystem].NumberOfUnitCellAtoms[CurrentFramework]) { sg_possible=FALSE; break; } } } // if the asymmetric unit does not generate the proper amount of atoms then it is certainly the wrong space group if(nr_atoms!=Framework[CurrentSystem].NumberOfUnitCellAtoms[CurrentFramework]) sg_possible=FALSE; // choice the space group with the lowest amount of atoms and the highest symmetry (Note the '<=') if(sg_possible&&(Framework[CurrentSystem].NumberOfAsymmetricAtoms[CurrentFramework]<=LowestNumberOfAsymmetricUnits)) { LowestNumberOfAsymmetricUnits=Framework[CurrentSystem].NumberOfAsymmetricAtoms[CurrentFramework]; FoundSpaceGroup=sg; //WriteAsymmetricUnitCell(FoundSpaceGroup); } if(sg_possible) fprintf(stderr, "Possible space group: %d\n",FoundSpaceGroup); } // assume a certain space-group Framework[CurrentSystem].SpaceGroupIdentifier[CurrentFramework]=FoundSpaceGroup; } Framework[CurrentSystem].NumberOfAsymmetricAtoms[CurrentFramework]=0; for(k=0;ksizeLastSpaceGroup))) //if(nAtoms0) { fwrite(&crystallographic_stats[i].Position,sizeof(VECTOR),Framework[i].NumberOfAsymmetricIons,FilePtr); fwrite(&crystallographic_stats[i].PositionSquared,sizeof(VECTOR),Framework[i].NumberOfAsymmetricIons,FilePtr); fwrite(&crystallographic_stats[i].Distance,sizeof(VECTOR),Framework[i].NumberOfAsymmetricIons,FilePtr); fwrite(&crystallographic_stats[i].Occupation,sizeof(REAL),Framework[i].NumberOfAsymmetricIons,FilePtr); fwrite(&crystallographic_stats[i].AverageDistance,sizeof(REAL),Framework[i].NumberOfAsymmetricIons,FilePtr); fwrite(&crystallographic_stats[i].RelativeOccupation,sizeof(REAL),Framework[i].NumberOfAsymmetricIons,FilePtr); fwrite(&crystallographic_stats[i].NumberOfCationSites,sizeof(int),Framework[i].NumberOfAsymmetricIons,FilePtr); fwrite(&crystallographic_stats[i].Count,sizeof(REAL),Framework[i].NumberOfAsymmetricIons,FilePtr); fwrite(&crystallographic_stats[i].TemperatureFactor,sizeof(REAL_MATRIX3x3),Framework[i].NumberOfAsymmetricIons,FilePtr); } fwrite(&Framework[i].NumberOfIons,sizeof(int),1,FilePtr); fwrite(&Framework[i].MaxNumberOfIons,sizeof(int),1,FilePtr); if(Framework[i].NumberOfIons>0) fwrite(Framework[i].Ions,sizeof(ATOM),Framework[i].NumberOfIons,FilePtr); fwrite(&Framework[i].NumberOfFrameworks,sizeof(int),1,FilePtr); if(Framework[i].NumberOfFrameworks==0) { fwrite(Framework[i].Name,sizeof(char[256]),1,FilePtr); } else { fwrite(Framework[i].NumberOfAtoms,sizeof(int),Framework[i].NumberOfFrameworks,FilePtr); fwrite(Framework[i].NumberOfFixedAtoms,sizeof(int),Framework[i].NumberOfFrameworks,FilePtr); fwrite(Framework[i].NumberOfFreeAtoms,sizeof(int),Framework[i].NumberOfFrameworks,FilePtr); fwrite(Framework[i].NumberOfCharges,sizeof(int),Framework[i].NumberOfFrameworks,FilePtr); fwrite(Framework[i].NumberOfUnitCellAtoms,sizeof(int),Framework[i].NumberOfFrameworks,FilePtr); fwrite(Framework[i].MaxNumberOfAtoms,sizeof(int),Framework[i].NumberOfFrameworks,FilePtr); fwrite(Framework[i].FrameworkProbability,sizeof(REAL),Framework[i].NumberOfFrameworks,FilePtr); for(j=0;j0) { fwrite(Framework[i].CoreShellDefinitions,sizeof(PAIR),Framework[i].NumberOfCoreShellDefinitions,FilePtr); fwrite(Framework[i].NumberOfCoreShellsPerType,sizeof(int),Framework[i].NumberOfCoreShellDefinitions,FilePtr); for(j=0;j0) fwrite(Framework[i].CoreShellConnectivity[j],sizeof(int),Framework[i].NumberOfAtoms[j],FilePtr); } } fwrite(&Framework[i].NumberOfBondsDefinitions,sizeof(int),1,FilePtr); if(Framework[i].NumberOfBondsDefinitions>0) { fwrite(Framework[i].BondDefinitionType,sizeof(int),Framework[i].NumberOfBondsDefinitions,FilePtr); fwrite(Framework[i].BondDefinitions,sizeof(PAIR),Framework[i].NumberOfBondsDefinitions,FilePtr); fwrite(Framework[i].BondArgumentDefinitions,sizeof(REAL[MAX_BOND_POTENTIAL_ARGUMENTS]),Framework[i].NumberOfBondsDefinitions,FilePtr); fwrite(Framework[i].NumberOfBondsPerType,sizeof(int),Framework[i].NumberOfBondsDefinitions,FilePtr); fwrite(Framework[i].NumberOfBonds,sizeof(int),Framework[i].NumberOfFrameworks,FilePtr); fwrite(Framework[i].MaxNumberOfBonds,sizeof(int),Framework[i].NumberOfFrameworks,FilePtr); for(j=0;j0) { fwrite(Framework[i].Bonds[j],sizeof(PAIR),Framework[i].NumberOfBonds[j],FilePtr); fwrite(Framework[i].BondType[j],sizeof(int),Framework[i].NumberOfBonds[j],FilePtr); fwrite(Framework[i].BondArguments[j],sizeof(REAL[MAX_BOND_POTENTIAL_ARGUMENTS]),Framework[i].NumberOfBonds[j],FilePtr); } } } fwrite(&Framework[i].NumberOfBondDipoleDefinitions,sizeof(int),1,FilePtr); if(Framework[i].NumberOfBondDipoleDefinitions>0) { fwrite(Framework[i].NumberOfBondDipoles,sizeof(int),Framework[i].NumberOfFrameworks,FilePtr); fwrite(Framework[i].MaxNumberOfBondDipoles,sizeof(int),Framework[i].NumberOfFrameworks,FilePtr); fwrite(Framework[i].BondDipoleDefinitions,sizeof(PAIR),Framework[i].NumberOfBondDipoleDefinitions,FilePtr); fwrite(Framework[i].BondDipoleArgumentDefinition,sizeof(REAL),Framework[i].NumberOfBondDipoleDefinitions,FilePtr); fwrite(Framework[i].NumberOfBondDipolesPerType,sizeof(int),Framework[i].NumberOfBondDipoleDefinitions,FilePtr); // allocate first dimension of bond-dipoles for(j=0;j0) { fwrite(Framework[i].BondDipoles[j],sizeof(PAIR),Framework[i].NumberOfBondDipoles[j],FilePtr); fwrite(Framework[i].BondDipoleMagnitude[j],sizeof(REAL),Framework[i].NumberOfBondDipoles[j],FilePtr); } } } fwrite(&Framework[i].NumberOfUreyBradleyDefinitions,sizeof(int),1,FilePtr); if(Framework[i].NumberOfUreyBradleyDefinitions>0) { fwrite(Framework[i].UreyBradleyDefinitionType,sizeof(int),Framework[i].NumberOfUreyBradleyDefinitions,FilePtr); fwrite(Framework[i].UreyBradleyDefinitions,sizeof(TRIPLE),Framework[i].NumberOfUreyBradleyDefinitions,FilePtr); fwrite(Framework[i].UreyBradleyArgumentDefinitions,sizeof(REAL[MAX_UREYBRADLEY_POTENTIAL_ARGUMENTS]),Framework[i].NumberOfUreyBradleyDefinitions,FilePtr); fwrite(Framework[i].NumberOfUreyBradleysPerType,sizeof(int),Framework[i].NumberOfUreyBradleyDefinitions,FilePtr); fwrite(Framework[i].NumberOfUreyBradleys,sizeof(int),Framework[i].NumberOfFrameworks,FilePtr); fwrite(Framework[i].MaxNumberOfUreyBradleys,sizeof(int),Framework[i].NumberOfFrameworks,FilePtr); for(j=0;j0) { fwrite(Framework[i].UreyBradleys[j],sizeof(TRIPLE),Framework[i].NumberOfUreyBradleys[j],FilePtr); fwrite(Framework[i].UreyBradleyType[j],sizeof(int),Framework[i].NumberOfUreyBradleys[j],FilePtr); fwrite(Framework[i].UreyBradleyArguments[j],sizeof(REAL[MAX_UREYBRADLEY_POTENTIAL_ARGUMENTS]),Framework[i].NumberOfUreyBradleys[j],FilePtr); } } } fwrite(&Framework[i].NumberOfBendDefinitions,sizeof(int),1,FilePtr); if(Framework[i].NumberOfBendDefinitions>0) { fwrite(Framework[i].BendDefinitionType,sizeof(int),Framework[i].NumberOfBendDefinitions,FilePtr); fwrite(Framework[i].BendDefinitions,sizeof(QUAD),Framework[i].NumberOfBendDefinitions,FilePtr); fwrite(Framework[i].BendArgumentDefinitions,sizeof(REAL[MAX_BEND_POTENTIAL_ARGUMENTS]),Framework[i].NumberOfBendDefinitions,FilePtr); fwrite(Framework[i].NumberOfBendsPerType,sizeof(int),Framework[i].NumberOfBendDefinitions,FilePtr); fwrite(Framework[i].NumberOfBends,sizeof(int),Framework[i].NumberOfFrameworks,FilePtr); fwrite(Framework[i].MaxNumberOfBends,sizeof(int),Framework[i].NumberOfFrameworks,FilePtr); for(j=0;j0) { fwrite(Framework[i].Bends[j],sizeof(QUAD),Framework[i].NumberOfBends[j],FilePtr); fwrite(Framework[i].BendType[j],sizeof(int),Framework[i].NumberOfBends[j],FilePtr); fwrite(Framework[i].BendArguments[j],sizeof(REAL[MAX_BEND_POTENTIAL_ARGUMENTS]),Framework[i].NumberOfBends[j],FilePtr); } } } fwrite(&Framework[i].NumberOfInversionBendDefinitions,sizeof(int),1,FilePtr); if(Framework[i].NumberOfInversionBendDefinitions>0) { fwrite(Framework[i].InversionBendDefinitionType,sizeof(int),Framework[i].NumberOfInversionBendDefinitions,FilePtr); fwrite(Framework[i].InversionBendDefinitions,sizeof(QUAD),Framework[i].NumberOfInversionBendDefinitions,FilePtr); fwrite(Framework[i].InversionBendArgumentDefinitions,sizeof(REAL[MAX_INVERSION_BEND_POTENTIAL_ARGUMENTS]),Framework[i].NumberOfInversionBendDefinitions,FilePtr); fwrite(Framework[i].NumberOfInversionBendsPerType,sizeof(int),Framework[i].NumberOfInversionBendDefinitions,FilePtr); fwrite(Framework[i].NumberOfInversionBends,sizeof(int),Framework[i].NumberOfFrameworks,FilePtr); fwrite(Framework[i].MaxNumberOfInversionBends,sizeof(int),Framework[i].NumberOfFrameworks,FilePtr); for(j=0;j0) { fwrite(Framework[i].InversionBends[j],sizeof(QUAD),Framework[i].NumberOfInversionBends[j],FilePtr); fwrite(Framework[i].InversionBendType[j],sizeof(int),Framework[i].NumberOfInversionBends[j],FilePtr); fwrite(Framework[i].InversionBendArguments[j],sizeof(REAL[MAX_INVERSION_BEND_POTENTIAL_ARGUMENTS]),Framework[i].NumberOfInversionBends[j],FilePtr); } } } fwrite(&Framework[i].NumberOfTorsionDefinitions,sizeof(int),1,FilePtr); if(Framework[i].NumberOfTorsionDefinitions>0) { fwrite(Framework[i].TorsionDefinitionType,sizeof(int),Framework[i].NumberOfTorsionDefinitions,FilePtr); fwrite(Framework[i].TorsionDefinitions,sizeof(QUAD),Framework[i].NumberOfTorsionDefinitions,FilePtr); fwrite(Framework[i].TorsionArgumentDefinitions,sizeof(REAL[MAX_TORSION_POTENTIAL_ARGUMENTS]),Framework[i].NumberOfTorsionDefinitions,FilePtr); fwrite(Framework[i].NumberOfTorsionsPerType,sizeof(int),Framework[i].NumberOfTorsionDefinitions,FilePtr); fwrite(Framework[i].NumberOfTorsions,sizeof(int),Framework[i].NumberOfFrameworks,FilePtr); fwrite(Framework[i].MaxNumberOfTorsions,sizeof(int),Framework[i].NumberOfFrameworks,FilePtr); for(j=0;j0) { fwrite(Framework[i].Torsions[j],sizeof(QUAD),Framework[i].NumberOfTorsions[j],FilePtr); fwrite(Framework[i].TorsionType[j],sizeof(int),Framework[i].NumberOfTorsions[j],FilePtr); fwrite(Framework[i].TorsionArguments[j],sizeof(REAL[MAX_TORSION_POTENTIAL_ARGUMENTS]),Framework[i].NumberOfTorsions[j],FilePtr); } } } fwrite(&Framework[i].NumberOfImproperTorsionDefinitions,sizeof(int),1,FilePtr); if(Framework[i].NumberOfImproperTorsionDefinitions>0) { fwrite(Framework[i].ImproperTorsionDefinitionType,sizeof(int),Framework[i].NumberOfImproperTorsionDefinitions,FilePtr); fwrite(Framework[i].ImproperTorsionDefinitions,sizeof(QUAD),Framework[i].NumberOfImproperTorsionDefinitions,FilePtr); fwrite(Framework[i].ImproperTorsionArgumentDefinitions,sizeof(REAL[MAX_IMPROPER_TORSION_POTENTIAL_ARGUMENTS]),Framework[i].NumberOfImproperTorsionDefinitions,FilePtr); fwrite(Framework[i].NumberOfImproperTorsionsPerType,sizeof(int),Framework[i].NumberOfImproperTorsionDefinitions,FilePtr); fwrite(Framework[i].NumberOfImproperTorsions,sizeof(int),Framework[i].NumberOfFrameworks,FilePtr); fwrite(Framework[i].MaxNumberOfImproperTorsions,sizeof(int),Framework[i].NumberOfFrameworks,FilePtr); for(j=0;j0) { fwrite(Framework[i].ImproperTorsions[j],sizeof(QUAD),Framework[i].NumberOfImproperTorsions[j],FilePtr); fwrite(Framework[i].ImproperTorsionType[j],sizeof(int),Framework[i].NumberOfImproperTorsions[j],FilePtr); fwrite(Framework[i].ImproperTorsionArguments[j],sizeof(REAL[MAX_IMPROPER_TORSION_POTENTIAL_ARGUMENTS]),Framework[i].NumberOfImproperTorsions[j],FilePtr); } } } fwrite(&Framework[i].NumberOfOutOfPlaneDefinitions,sizeof(int),1,FilePtr); if(Framework[i].NumberOfOutOfPlaneDefinitions>0) { fwrite(Framework[i].OutOfPlaneDefinitionType,sizeof(int),Framework[i].NumberOfOutOfPlaneDefinitions,FilePtr); fwrite(Framework[i].OutOfPlaneDefinitions,sizeof(QUAD),Framework[i].NumberOfOutOfPlaneDefinitions,FilePtr); fwrite(Framework[i].OutOfPlaneArgumentDefinitions,sizeof(REAL[MAX_OUT_OF_PLANE_POTENTIAL_ARGUMENTS]),Framework[i].NumberOfOutOfPlaneDefinitions,FilePtr); fwrite(Framework[i].NumberOfOutOfPlanesPerType,sizeof(int),Framework[i].NumberOfOutOfPlaneDefinitions,FilePtr); fwrite(Framework[i].NumberOfOutOfPlanes,sizeof(int),Framework[i].NumberOfFrameworks,FilePtr); fwrite(Framework[i].MaxNumberOfOutOfPlanes,sizeof(int),Framework[i].NumberOfFrameworks,FilePtr); for(j=0;j0) { fwrite(Framework[i].OutOfPlanes[j],sizeof(QUAD),Framework[i].NumberOfOutOfPlanes[j],FilePtr); fwrite(Framework[i].OutOfPlaneType[j],sizeof(int),Framework[i].NumberOfOutOfPlanes[j],FilePtr); fwrite(Framework[i].OutOfPlaneArguments[j],sizeof(REAL[MAX_OUT_OF_PLANE_POTENTIAL_ARGUMENTS]),Framework[i].NumberOfOutOfPlanes[j],FilePtr); } } } fwrite(&Framework[i].NumberOfBondBondDefinitions,sizeof(int),1,FilePtr); if(Framework[i].NumberOfBondBondDefinitions>0) { fwrite(Framework[i].BondBondDefinitionType,sizeof(int),Framework[i].NumberOfBondBondDefinitions,FilePtr); fwrite(Framework[i].BondBondDefinitions,sizeof(TRIPLE),Framework[i].NumberOfBondBondDefinitions,FilePtr); fwrite(Framework[i].BondBondArgumentDefinitions,sizeof(REAL[MAX_BOND_BOND_POTENTIAL_ARGUMENTS]),Framework[i].NumberOfBondBondDefinitions,FilePtr); fwrite(Framework[i].NumberOfBondBondsPerType,sizeof(int),Framework[i].NumberOfBondBondDefinitions,FilePtr); fwrite(Framework[i].NumberOfBondBonds,sizeof(int),Framework[i].NumberOfFrameworks,FilePtr); fwrite(Framework[i].MaxNumberOfBondBonds,sizeof(int),Framework[i].NumberOfFrameworks,FilePtr); for(j=0;j0) { fwrite(Framework[i].BondBonds[j],sizeof(TRIPLE),Framework[i].NumberOfBondBonds[j],FilePtr); fwrite(Framework[i].BondBondType[j],sizeof(int),Framework[i].NumberOfBondBonds[j],FilePtr); fwrite(Framework[i].BondBondArguments[j],sizeof(REAL[MAX_BOND_BOND_POTENTIAL_ARGUMENTS]),Framework[i].NumberOfBondBonds[j],FilePtr); } } } fwrite(&Framework[i].NumberOfBondBendDefinitions,sizeof(int),1,FilePtr); if(Framework[i].NumberOfBondBendDefinitions>0) { fwrite(Framework[i].BondBendDefinitionType,sizeof(int),Framework[i].NumberOfBondBendDefinitions,FilePtr); fwrite(Framework[i].BondBendDefinitions,sizeof(TRIPLE),Framework[i].NumberOfBondBendDefinitions,FilePtr); fwrite(Framework[i].BondBendArgumentDefinitions,sizeof(REAL[MAX_BOND_BEND_POTENTIAL_ARGUMENTS]),Framework[i].NumberOfBondBendDefinitions,FilePtr); fwrite(Framework[i].NumberOfBondBendsPerType,sizeof(int),Framework[i].NumberOfBondBendDefinitions,FilePtr); fwrite(Framework[i].NumberOfBondBends,sizeof(int),Framework[i].NumberOfFrameworks,FilePtr); fwrite(Framework[i].MaxNumberOfBondBends,sizeof(int),Framework[i].NumberOfFrameworks,FilePtr); for(j=0;j0) { fwrite(Framework[i].BondBends[j],sizeof(TRIPLE),Framework[i].NumberOfBondBends[j],FilePtr); fwrite(Framework[i].BondBendType[j],sizeof(int),Framework[i].NumberOfBondBends[j],FilePtr); fwrite(Framework[i].BondBendArguments[j],sizeof(REAL[MAX_BOND_BEND_POTENTIAL_ARGUMENTS]),Framework[i].NumberOfBondBends[j],FilePtr); } } } fwrite(&Framework[i].NumberOfBendBendDefinitions,sizeof(int),1,FilePtr); if(Framework[i].NumberOfBendBendDefinitions>0) { fwrite(Framework[i].BendBendDefinitionType,sizeof(int),Framework[i].NumberOfBendBendDefinitions,FilePtr); fwrite(Framework[i].BendBendDefinitions,sizeof(QUAD),Framework[i].NumberOfBendBendDefinitions,FilePtr); fwrite(Framework[i].BendBendArgumentDefinitions,sizeof(REAL[MAX_BEND_BEND_POTENTIAL_ARGUMENTS]),Framework[i].NumberOfBendBendDefinitions,FilePtr); fwrite(Framework[i].NumberOfBendBendsPerType,sizeof(int),Framework[i].NumberOfBendBendDefinitions,FilePtr); fwrite(Framework[i].NumberOfBendBends,sizeof(int),Framework[i].NumberOfFrameworks,FilePtr); fwrite(Framework[i].MaxNumberOfBendBends,sizeof(int),Framework[i].NumberOfFrameworks,FilePtr); for(j=0;j0) { fwrite(Framework[i].BendBends[j],sizeof(QUAD),Framework[i].NumberOfBendBends[j],FilePtr); fwrite(Framework[i].BendBendType[j],sizeof(int),Framework[i].NumberOfBendBends[j],FilePtr); fwrite(Framework[i].BendBendArguments[j],sizeof(REAL[MAX_BEND_BEND_POTENTIAL_ARGUMENTS]),Framework[i].NumberOfBendBends[j],FilePtr); } } } fwrite(&Framework[i].NumberOfBondTorsionDefinitions,sizeof(int),1,FilePtr); if(Framework[i].NumberOfBondTorsionDefinitions>0) { fwrite(Framework[i].BondTorsionDefinitionType,sizeof(int),Framework[i].NumberOfBondTorsionDefinitions,FilePtr); fwrite(Framework[i].BondTorsionDefinitions,sizeof(QUAD),Framework[i].NumberOfBondTorsionDefinitions,FilePtr); fwrite(Framework[i].BondTorsionArgumentDefinitions,sizeof(REAL[MAX_BOND_TORSION_POTENTIAL_ARGUMENTS]),Framework[i].NumberOfBondTorsionDefinitions,FilePtr); fwrite(Framework[i].NumberOfBondTorsionsPerType,sizeof(int),Framework[i].NumberOfBondTorsionDefinitions,FilePtr); fwrite(Framework[i].NumberOfBondTorsions,sizeof(int),Framework[i].NumberOfFrameworks,FilePtr); fwrite(Framework[i].MaxNumberOfBondTorsions,sizeof(int),Framework[i].NumberOfFrameworks,FilePtr); for(j=0;j0) { fwrite(Framework[i].BondTorsions[j],sizeof(QUAD),Framework[i].NumberOfBondTorsions[j],FilePtr); fwrite(Framework[i].BondTorsionType[j],sizeof(int),Framework[i].NumberOfBondTorsions[j],FilePtr); fwrite(Framework[i].BondTorsionArguments[j],sizeof(REAL[MAX_BOND_TORSION_POTENTIAL_ARGUMENTS]),Framework[i].NumberOfBondTorsions[j],FilePtr); } } } fwrite(&Framework[i].NumberOfBendTorsionDefinitions,sizeof(int),1,FilePtr); if(Framework[i].NumberOfBendTorsionDefinitions>0) { fwrite(Framework[i].BendTorsionDefinitionType,sizeof(int),Framework[i].NumberOfBendTorsionDefinitions,FilePtr); fwrite(Framework[i].BendTorsionDefinitions,sizeof(QUAD),Framework[i].NumberOfBendTorsionDefinitions,FilePtr); fwrite(Framework[i].BendTorsionArgumentDefinitions,sizeof(REAL[MAX_BEND_TORSION_POTENTIAL_ARGUMENTS]),Framework[i].NumberOfBendTorsionDefinitions,FilePtr); fwrite(Framework[i].NumberOfBendTorsionsPerType,sizeof(int),Framework[i].NumberOfBendTorsionDefinitions,FilePtr); fwrite(Framework[i].NumberOfBendTorsions,sizeof(int),Framework[i].NumberOfFrameworks,FilePtr); fwrite(Framework[i].MaxNumberOfBendTorsions,sizeof(int),Framework[i].NumberOfFrameworks,FilePtr); for(j=0;j0) { fwrite(Framework[i].BendTorsions[j],sizeof(QUAD),Framework[i].NumberOfBendTorsions[j],FilePtr); fwrite(Framework[i].BendTorsionType[j],sizeof(int),Framework[i].NumberOfBendTorsions[j],FilePtr); fwrite(Framework[i].BendTorsionArguments[j],sizeof(REAL[MAX_BEND_TORSION_POTENTIAL_ARGUMENTS]),Framework[i].NumberOfBendTorsions[j],FilePtr); } } } fwrite(Framework[i].NumberOfIntraVDW,sizeof(int),Framework[i].NumberOfFrameworks,FilePtr); fwrite(Framework[i].NumberOfExcludedIntraVDW,sizeof(int),Framework[i].NumberOfFrameworks,FilePtr); fwrite(Framework[i].NumberOfIntraCharges,sizeof(int),Framework[i].NumberOfFrameworks,FilePtr); fwrite(Framework[i].NumberOfIntraChargeBondDipoles,sizeof(int),Framework[i].NumberOfFrameworks,FilePtr); fwrite(Framework[i].NumberOfIntraBondDipoles,sizeof(int),Framework[i].NumberOfFrameworks,FilePtr); fwrite(Framework[i].NumberOfExcludedIntraChargeCharge,sizeof(int),Framework[i].NumberOfFrameworks,FilePtr); fwrite(Framework[i].MaxNumberOfExcludedIntraChargeCharge,sizeof(int),Framework[i].NumberOfFrameworks,FilePtr); fwrite(Framework[i].NumberOfExcludedIntraChargeBondDipole,sizeof(int),Framework[i].NumberOfFrameworks,FilePtr); fwrite(Framework[i].MaxNumberOfExcludedIntraChargeBondDipole,sizeof(int),Framework[i].NumberOfFrameworks,FilePtr); fwrite(Framework[i].NumberOfExcludedIntraBondDipoleBondDipole,sizeof(int),Framework[i].NumberOfFrameworks,FilePtr); fwrite(Framework[i].MaxNumberOfExcludedIntraBondDipoleBondDipole,sizeof(int),Framework[i].NumberOfFrameworks,FilePtr); if(Framework[i].FrameworkModel==FLEXIBLE) { for(j=0;j0) fwrite(Framework[i].ExcludedIntraChargeCharge[j],sizeof(PAIR),Framework[i].NumberOfExcludedIntraChargeCharge[j],FilePtr); if(Framework[i].NumberOfExcludedIntraChargeBondDipole[j]) fwrite(Framework[i].ExcludedIntraChargeBondDipole[j],sizeof(PAIR),Framework[i].NumberOfExcludedIntraChargeBondDipole[j],FilePtr); if(Framework[i].NumberOfExcludedIntraBondDipoleBondDipole[j]>0) fwrite(Framework[i].ExcludedIntraBondDipoleBondDipole[j],sizeof(PAIR),Framework[i].NumberOfExcludedIntraBondDipoleBondDipole[j],FilePtr); } } } } } fwrite(&NumberOfSingleSubstitutionRules,sizeof(int),1,FilePtr); if(NumberOfSingleSubstitutionRules>0) { fwrite(SubstitutionSingleFrameworkAtom,sizeof(char[3][256]),NumberOfSingleSubstitutionRules,FilePtr); fwrite(SubstitutionSingleFrameworkAtomTypes,sizeof(int[3]),NumberOfSingleSubstitutionRules,FilePtr); } fwrite(&NumberOfSubstitutionRules,sizeof(int),1,FilePtr); fwrite(&NumberOfRandomSubstitutions,sizeof(int),1,FilePtr); if(NumberOfSubstitutionRules>0) { fwrite(SubstitutionFrameworkAtoms,sizeof(char[3][256]),NumberOfSubstitutionRules,FilePtr); fwrite(SubstitutionFrameworkAtomTypes,sizeof(int[3]),NumberOfSubstitutionRules,FilePtr); } fwrite(&NumberOfSubstitutions,sizeof(int),1,FilePtr); if(NumberOfSubstitutions>0) fwrite(ListOfAtomSubstitutions,sizeof(int[3]),NumberOfSubstitutions,FilePtr); // write the framework atom modification rules fwrite(&NumberOfModificationRules,sizeof(int),1,FilePtr); if(NumberOfModificationRules>0) { fwrite(ModificationRuleType,sizeof(int),NumberOfModificationRules,FilePtr); fwrite(ModifyFrameworkAtoms,sizeof(char[10][256]),NumberOfModificationRules,FilePtr); fwrite(ModifyFrameworkAtomTypes,sizeof(int[10]),NumberOfModificationRules,FilePtr); } // write the framework atom forbidden connectivity rules fwrite(&NumberOfForbiddenConnectivityRules,sizeof(int),1,FilePtr); if(NumberOfForbiddenConnectivityRules>0) { fwrite(ForbiddenConnectivityAtoms,sizeof(char[3][256]),NumberOfForbiddenConnectivityRules,FilePtr); fwrite(ForbiddenConnectivityTypes,sizeof(int[3]),NumberOfForbiddenConnectivityRules,FilePtr); } Check=123456789.0; fwrite(&Check,1,sizeof(REAL),FilePtr); } void ReadRestartFramework(FILE *FilePtr) { int i,j,k; REAL Check; int readversionNumber=0; fread(&readversionNumber,sizeof(int),1,FilePtr); if(readversionNumber > versionNumber) { fprintf(stderr,"Upgrade to last version of RASPA to read binary restart-file"); exit(-1); } fread(&NumberOfSystems,sizeof(NumberOfSystems),1,FilePtr); Framework=(FRAMEWORK_COMPONENT*)calloc(NumberOfSystems,sizeof(FRAMEWORK_COMPONENT)); crystallographic_stats=(CRYSTALLOGRAPHIC_STATISTICS*)calloc(NumberOfSystems,sizeof(CRYSTALLOGRAPHIC_STATISTICS)); fread(crystallographic_stats,sizeof(CRYSTALLOGRAPHIC_STATISTICS),NumberOfSystems,FilePtr); fread(Framework,NumberOfSystems,sizeof(FRAMEWORK_COMPONENT),FilePtr); fread(&CurrentFramework,sizeof(CurrentFramework),1,FilePtr); UnitCellSize=(VECTOR*)calloc(NumberOfSystems,sizeof(VECTOR)); NumberOfUnitCells=(INT_VECTOR3*)calloc(NumberOfSystems,sizeof(INT_VECTOR3)); UnitCellBox=(REAL_MATRIX3x3*)calloc(NumberOfSystems,sizeof(REAL_MATRIX3x3)); InverseUnitCellBox=(REAL_MATRIX3x3*)calloc(NumberOfSystems,sizeof(REAL_MATRIX3x3)); Lowenstein=(int*)calloc(NumberOfSystems,sizeof(int)); fread(UnitCellSize,sizeof(VECTOR),NumberOfSystems,FilePtr); fread(NumberOfUnitCells,sizeof(INT_VECTOR3),NumberOfSystems,FilePtr); fread(UnitCellBox,sizeof(REAL_MATRIX3x3),NumberOfSystems,FilePtr); fread(InverseUnitCellBox,sizeof(REAL_MATRIX3x3),NumberOfSystems,FilePtr); fread(Lowenstein,sizeof(int),NumberOfSystems,FilePtr); fread(&RemoveBondNeighboursFromLongRangeInteraction,sizeof(int),1,FilePtr); fread(&RemoveBendNeighboursFromLongRangeInteraction,sizeof(int),1,FilePtr); fread(&RemoveTorsionNeighboursFromLongRangeInteraction,sizeof(int),1,FilePtr); fread(&Remove12NeighboursFromVDWInteraction,sizeof(int),1,FilePtr); fread(&Remove13NeighboursFromVDWInteraction,sizeof(int),1,FilePtr); fread(&Remove14NeighboursFromVDWInteraction,sizeof(int),1,FilePtr); fread(&Remove12NeighboursFromChargeChargeInteraction,sizeof(int),1,FilePtr); fread(&Remove13NeighboursFromChargeChargeInteraction,sizeof(int),1,FilePtr); fread(&Remove14NeighboursFromChargeChargeInteraction,sizeof(int),1,FilePtr); fread(&Remove11NeighboursFromChargeBondDipoleInteraction,sizeof(int),1,FilePtr); fread(&Remove12NeighboursFromChargeBondDipoleInteraction,sizeof(int),1,FilePtr); fread(&Remove13NeighboursFromChargeBondDipoleInteraction,sizeof(int),1,FilePtr); fread(&Remove14NeighboursFromChargeBondDipoleInteraction,sizeof(int),1,FilePtr); fread(&Remove12NeighboursFromBondDipoleBondDipoleInteraction,sizeof(int),1,FilePtr); fread(&Remove13NeighboursFromBondDipoleBondDipoleInteraction,sizeof(int),1,FilePtr); fread(&Remove14NeighboursFromBondDipoleBondDipoleInteraction,sizeof(int),1,FilePtr); fread(&ImproperTorsionScanType,sizeof(int),1,FilePtr); fread(&InternalFrameworkLennardJonesInteractions,sizeof(int),1,FilePtr); for(i=0;i0) { fread(&crystallographic_stats[i].Position,sizeof(VECTOR),Framework[i].NumberOfAsymmetricIons,FilePtr); fread(&crystallographic_stats[i].PositionSquared,sizeof(VECTOR),Framework[i].NumberOfAsymmetricIons,FilePtr); fread(&crystallographic_stats[i].Distance,sizeof(VECTOR),Framework[i].NumberOfAsymmetricIons,FilePtr); fread(&crystallographic_stats[i].Occupation,sizeof(REAL),Framework[i].NumberOfAsymmetricIons,FilePtr); fread(&crystallographic_stats[i].AverageDistance,sizeof(REAL),Framework[i].NumberOfAsymmetricIons,FilePtr); fread(&crystallographic_stats[i].RelativeOccupation,sizeof(REAL),Framework[i].NumberOfAsymmetricIons,FilePtr); fread(&crystallographic_stats[i].NumberOfCationSites,sizeof(int),Framework[i].NumberOfAsymmetricIons,FilePtr); fread(&crystallographic_stats[i].Count,sizeof(REAL),Framework[i].NumberOfAsymmetricIons,FilePtr); fread(&crystallographic_stats[i].TemperatureFactor,sizeof(REAL_MATRIX3x3),Framework[i].NumberOfAsymmetricIons,FilePtr); } fread(&Framework[i].NumberOfIons,sizeof(int),1,FilePtr); fread(&Framework[i].MaxNumberOfIons,sizeof(int),1,FilePtr); Framework[i].MaxNumberOfIons=Framework[i].NumberOfIons; if(Framework[i].NumberOfIons>0) { Framework[i].Ions=(ATOM*)calloc(Framework[i].NumberOfIons,sizeof(ATOM)); fread(Framework[i].Ions,Framework[i].NumberOfIons,sizeof(ATOM),FilePtr); } fread(&Framework[i].NumberOfFrameworks,sizeof(int),1,FilePtr); if(Framework[i].NumberOfFrameworks==0) { Framework[i].NumberOfAtoms=(int*)calloc(1,sizeof(int)); Framework[i].NumberOfAtoms[0]=0; Framework[i].NumberOfFixedAtoms=(int*)calloc(1,sizeof(int)); Framework[i].NumberOfFixedAtoms[0]=0; Framework[i].NumberOfFreeAtoms=(int*)calloc(1,sizeof(int)); Framework[i].NumberOfFreeAtoms[0]=0; Framework[i].NumberOfCharges=(int*)calloc(1,sizeof(int)); Framework[i].NumberOfCharges[0]=0; Framework[i].NumberOfUnitCellAtoms=(int*)calloc(1,sizeof(int)); Framework[i].NumberOfUnitCellAtoms[0]=0; Framework[i].NumberOfAsymmetricAtoms=(int*)calloc(1,sizeof(int)); Framework[i].NumberOfAsymmetricAtoms[0]=0; Framework[i].Name=(char(*)[256])calloc(1,sizeof(char[256])); fread(Framework[i].Name,sizeof(char[256]),1,FilePtr); } else { Framework[i].Atoms=(ATOM**)calloc(Framework[i].NumberOfFrameworks,sizeof(ATOM*)); Framework[i].NumberOfAtoms=(int*)calloc(Framework[i].NumberOfFrameworks,sizeof(int)); Framework[i].NumberOfFixedAtoms=(int*)calloc(Framework[i].NumberOfFrameworks,sizeof(int)); Framework[i].NumberOfFreeAtoms=(int*)calloc(Framework[i].NumberOfFrameworks,sizeof(int)); Framework[i].NumberOfCharges=(int*)calloc(Framework[i].NumberOfFrameworks,sizeof(int)); Framework[i].NumberOfUnitCellAtoms=(int*)calloc(Framework[i].NumberOfFrameworks,sizeof(int)); Framework[i].MaxNumberOfAtoms=(int*)calloc(Framework[i].NumberOfFrameworks,sizeof(int)); Framework[i].FrameworkProbability=(REAL*)calloc(Framework[i].NumberOfFrameworks,sizeof(REAL)); fread(Framework[i].NumberOfAtoms,sizeof(int),Framework[i].NumberOfFrameworks,FilePtr); fread(Framework[i].NumberOfFixedAtoms,sizeof(int),Framework[i].NumberOfFrameworks,FilePtr); fread(Framework[i].NumberOfFreeAtoms,sizeof(int),Framework[i].NumberOfFrameworks,FilePtr); fread(Framework[i].NumberOfCharges,sizeof(int),Framework[i].NumberOfFrameworks,FilePtr); fread(Framework[i].NumberOfUnitCellAtoms,sizeof(int),Framework[i].NumberOfFrameworks,FilePtr); fread(Framework[i].MaxNumberOfAtoms,sizeof(int),Framework[i].NumberOfFrameworks,FilePtr); fread(Framework[i].FrameworkProbability,sizeof(REAL),Framework[i].NumberOfFrameworks,FilePtr); for(j=0;j0) { Framework[i].CoreShellDefinitions=(PAIR*)calloc(Framework[i].NumberOfCoreShellDefinitions,sizeof(PAIR)); Framework[i].NumberOfCoreShellsPerType=(int*)calloc(Framework[i].NumberOfCoreShellDefinitions,sizeof(int)); Framework[i].CoreShellConnectivity=(int**)calloc(Framework[i].NumberOfFrameworks,sizeof(int*)); fread(Framework[i].CoreShellDefinitions,sizeof(PAIR),Framework[i].NumberOfCoreShellDefinitions,FilePtr); fread(Framework[i].NumberOfCoreShellsPerType,sizeof(int),Framework[i].NumberOfCoreShellDefinitions,FilePtr); for(j=0;j0) { Framework[i].CoreShellConnectivity[j]=(int*)calloc(Framework[i].NumberOfAtoms[j],sizeof(int)); fread(Framework[i].CoreShellConnectivity[j],sizeof(int),Framework[i].NumberOfAtoms[j],FilePtr); } } } fread(&Framework[i].NumberOfBondsDefinitions,sizeof(int),1,FilePtr); Framework[i].NumberOfBonds=(int*)calloc(Framework[i].NumberOfFrameworks,sizeof(int)); if(Framework[i].NumberOfBondsDefinitions>0) { // alloc memory Framework[i].BondDefinitionType=(int*)calloc(Framework[i].NumberOfBondsDefinitions,sizeof(int)); Framework[i].BondDefinitions=(PAIR*)calloc(Framework[i].NumberOfBondsDefinitions,sizeof(PAIR)); Framework[i].BondArgumentDefinitions=(REAL(*)[MAX_BOND_POTENTIAL_ARGUMENTS]) calloc(Framework[i].NumberOfBondsDefinitions,sizeof(REAL[MAX_BOND_POTENTIAL_ARGUMENTS])); Framework[i].NumberOfBondsPerType=(int*)calloc(Framework[i].NumberOfBondsDefinitions,sizeof(int)); fread(Framework[i].BondDefinitionType,sizeof(int),Framework[i].NumberOfBondsDefinitions,FilePtr); fread(Framework[i].BondDefinitions,sizeof(PAIR),Framework[i].NumberOfBondsDefinitions,FilePtr); fread(Framework[i].BondArgumentDefinitions,sizeof(REAL[MAX_BOND_POTENTIAL_ARGUMENTS]),Framework[i].NumberOfBondsDefinitions,FilePtr); fread(Framework[i].NumberOfBondsPerType,sizeof(int),Framework[i].NumberOfBondsDefinitions,FilePtr); Framework[i].MaxNumberOfBonds=(int*)calloc(Framework[i].NumberOfFrameworks,sizeof(int)); Framework[i].Bonds=(PAIR**)calloc(Framework[i].NumberOfFrameworks,sizeof(PAIR*)); Framework[i].BondType=(int**)calloc(Framework[i].NumberOfFrameworks,sizeof(int*)); Framework[i].BondArguments=(REAL(**)[MAX_BOND_POTENTIAL_ARGUMENTS])calloc(Framework[i].NumberOfFrameworks, sizeof(REAL(*)[MAX_BOND_POTENTIAL_ARGUMENTS])); fread(Framework[i].NumberOfBonds,sizeof(int),Framework[i].NumberOfFrameworks,FilePtr); fread(Framework[i].MaxNumberOfBonds,sizeof(int),Framework[i].NumberOfFrameworks,FilePtr); for(j=0;j0) { Framework[i].Bonds[j]=(PAIR*)calloc(Framework[i].NumberOfBonds[j],sizeof(PAIR)); Framework[i].BondType[j]=(int*)calloc(Framework[i].NumberOfBonds[j],sizeof(int)); Framework[i].BondArguments[j]=(REAL(*)[MAX_BOND_POTENTIAL_ARGUMENTS]) calloc(Framework[i].NumberOfBonds[j],sizeof(REAL[MAX_BOND_POTENTIAL_ARGUMENTS])); fread(Framework[i].Bonds[j],sizeof(PAIR),Framework[i].NumberOfBonds[j],FilePtr); fread(Framework[i].BondType[j],sizeof(int),Framework[i].NumberOfBonds[j],FilePtr); fread(Framework[i].BondArguments[j],sizeof(REAL[MAX_BOND_POTENTIAL_ARGUMENTS]),Framework[i].NumberOfBonds[j],FilePtr); } } } fread(&Framework[i].NumberOfBondDipoleDefinitions,sizeof(int),1,FilePtr); Framework[i].NumberOfBondDipoles=(int*)calloc(Framework[i].NumberOfFrameworks,sizeof(int)); if(Framework[i].NumberOfBondDipoleDefinitions>0) { // allocate first dimension of bond-dipoles Framework[i].MaxNumberOfBondDipoles=(int*)calloc(Framework[i].NumberOfFrameworks,sizeof(int)); Framework[i].BondDipoles=(PAIR**)calloc(Framework[i].NumberOfFrameworks,sizeof(PAIR*)); Framework[i].BondDipoleMagnitude=(REAL**)calloc(Framework[i].NumberOfFrameworks,sizeof(REAL*)); fread(Framework[i].NumberOfBondDipoles,sizeof(int),Framework[i].NumberOfFrameworks,FilePtr); fread(Framework[i].MaxNumberOfBondDipoles,sizeof(int),Framework[i].NumberOfFrameworks,FilePtr); Framework[i].BondDipoleDefinitions=(PAIR*)calloc(Framework[i].NumberOfBondDipoleDefinitions,sizeof(PAIR)); Framework[i].BondDipoleArgumentDefinition=(REAL*)calloc(Framework[i].NumberOfBondDipoleDefinitions,sizeof(REAL)); Framework[i].NumberOfBondDipolesPerType=(int*)calloc(Framework[i].NumberOfBondDipoleDefinitions,sizeof(int)); fread(Framework[i].BondDipoleDefinitions,sizeof(PAIR),Framework[i].NumberOfBondDipoleDefinitions,FilePtr); fread(Framework[i].BondDipoleArgumentDefinition,sizeof(REAL),Framework[i].NumberOfBondDipoleDefinitions,FilePtr); fread(Framework[i].NumberOfBondDipolesPerType,sizeof(int),Framework[i].NumberOfBondDipoleDefinitions,FilePtr); // allocate first dimension of bond-dipoles for(j=0;j0) { Framework[i].BondDipoles[j]=(PAIR*)calloc(Framework[i].NumberOfBondDipoles[j],sizeof(PAIR)); Framework[i].BondDipoleMagnitude[j]=(REAL*)calloc(Framework[i].NumberOfBondDipoles[j],sizeof(REAL)); fread(Framework[i].BondDipoles[j],sizeof(PAIR),Framework[i].NumberOfBondDipoles[j],FilePtr); fread(Framework[i].BondDipoleMagnitude[j],sizeof(REAL),Framework[i].NumberOfBondDipoles[j],FilePtr); } } } fread(&Framework[i].NumberOfUreyBradleyDefinitions,sizeof(int),1,FilePtr); Framework[i].NumberOfUreyBradleys=(int*)calloc(Framework[i].NumberOfFrameworks,sizeof(int)); if(Framework[i].NumberOfUreyBradleyDefinitions>0) { // alloc memory Framework[i].UreyBradleyDefinitionType=(int*)calloc(Framework[i].NumberOfUreyBradleyDefinitions,sizeof(int)); Framework[i].UreyBradleyDefinitions=(TRIPLE*)calloc(Framework[i].NumberOfUreyBradleyDefinitions,sizeof(TRIPLE)); Framework[i].UreyBradleyArgumentDefinitions=(REAL(*)[MAX_UREYBRADLEY_POTENTIAL_ARGUMENTS]) calloc(Framework[i].NumberOfUreyBradleyDefinitions,sizeof(REAL[MAX_UREYBRADLEY_POTENTIAL_ARGUMENTS])); Framework[i].NumberOfUreyBradleysPerType=(int*)calloc(Framework[i].NumberOfUreyBradleyDefinitions,sizeof(int)); fread(Framework[i].UreyBradleyDefinitionType,sizeof(int),Framework[i].NumberOfUreyBradleyDefinitions,FilePtr); fread(Framework[i].UreyBradleyDefinitions,sizeof(TRIPLE),Framework[i].NumberOfUreyBradleyDefinitions,FilePtr); fread(Framework[i].UreyBradleyArgumentDefinitions,sizeof(REAL[MAX_UREYBRADLEY_POTENTIAL_ARGUMENTS]),Framework[i].NumberOfUreyBradleyDefinitions,FilePtr); fread(Framework[i].NumberOfUreyBradleysPerType,sizeof(int),Framework[i].NumberOfUreyBradleyDefinitions,FilePtr); Framework[i].MaxNumberOfUreyBradleys=(int*)calloc(Framework[i].NumberOfFrameworks,sizeof(int)); Framework[i].UreyBradleys=(TRIPLE**)calloc(Framework[i].NumberOfFrameworks,sizeof(TRIPLE*)); Framework[i].UreyBradleyType=(int**)calloc(Framework[i].NumberOfFrameworks,sizeof(int*)); Framework[i].UreyBradleyArguments=(REAL(**)[MAX_UREYBRADLEY_POTENTIAL_ARGUMENTS])calloc(Framework[i].NumberOfFrameworks, sizeof(REAL(*)[MAX_UREYBRADLEY_POTENTIAL_ARGUMENTS])); fread(Framework[i].NumberOfUreyBradleys,sizeof(int),Framework[i].NumberOfFrameworks,FilePtr); fread(Framework[i].MaxNumberOfUreyBradleys,sizeof(int),Framework[i].NumberOfFrameworks,FilePtr); for(j=0;j0) { Framework[i].UreyBradleys[j]=(TRIPLE*)calloc(Framework[i].NumberOfUreyBradleys[j],sizeof(TRIPLE)); Framework[i].UreyBradleyType[j]=(int*)calloc(Framework[i].NumberOfUreyBradleys[j],sizeof(int)); Framework[i].UreyBradleyArguments[j]=(REAL(*)[MAX_UREYBRADLEY_POTENTIAL_ARGUMENTS]) calloc(Framework[i].NumberOfUreyBradleys[j],sizeof(REAL[MAX_UREYBRADLEY_POTENTIAL_ARGUMENTS])); fread(Framework[i].UreyBradleys[j],sizeof(TRIPLE),Framework[i].NumberOfUreyBradleys[j],FilePtr); fread(Framework[i].UreyBradleyType[j],sizeof(int),Framework[i].NumberOfUreyBradleys[j],FilePtr); fread(Framework[i].UreyBradleyArguments[j],sizeof(REAL[MAX_UREYBRADLEY_POTENTIAL_ARGUMENTS]),Framework[i].NumberOfUreyBradleys[j],FilePtr); } } } fread(&Framework[i].NumberOfBendDefinitions,sizeof(int),1,FilePtr); Framework[i].NumberOfBends=(int*)calloc(Framework[i].NumberOfFrameworks,sizeof(int)); if(Framework[i].NumberOfBendDefinitions>0) { // alloc memory Framework[i].BendDefinitionType=(int*)calloc(Framework[i].NumberOfBendDefinitions,sizeof(int)); Framework[i].BendDefinitions=(QUAD*)calloc(Framework[i].NumberOfBendDefinitions,sizeof(QUAD)); Framework[i].BendArgumentDefinitions=(REAL(*)[MAX_BEND_POTENTIAL_ARGUMENTS]) calloc(Framework[i].NumberOfBendDefinitions,sizeof(REAL[MAX_BEND_POTENTIAL_ARGUMENTS])); Framework[i].NumberOfBendsPerType=(int*)calloc(Framework[i].NumberOfBendDefinitions,sizeof(int)); fread(Framework[i].BendDefinitionType,sizeof(int),Framework[i].NumberOfBendDefinitions,FilePtr); fread(Framework[i].BendDefinitions,sizeof(QUAD),Framework[i].NumberOfBendDefinitions,FilePtr); fread(Framework[i].BendArgumentDefinitions,sizeof(REAL[MAX_BEND_POTENTIAL_ARGUMENTS]),Framework[i].NumberOfBendDefinitions,FilePtr); fread(Framework[i].NumberOfBendsPerType,sizeof(int),Framework[i].NumberOfBendDefinitions,FilePtr); Framework[i].MaxNumberOfBends=(int*)calloc(Framework[i].NumberOfFrameworks,sizeof(int)); Framework[i].Bends=(QUAD**)calloc(Framework[i].NumberOfFrameworks,sizeof(QUAD*)); Framework[i].BendType=(int**)calloc(Framework[i].NumberOfFrameworks,sizeof(int*)); Framework[i].BendArguments=(REAL(**)[MAX_BEND_POTENTIAL_ARGUMENTS])calloc(Framework[i].NumberOfFrameworks, sizeof(REAL(*)[MAX_BEND_POTENTIAL_ARGUMENTS])); fread(Framework[i].NumberOfBends,sizeof(int),Framework[i].NumberOfFrameworks,FilePtr); fread(Framework[i].MaxNumberOfBends,sizeof(int),Framework[i].NumberOfFrameworks,FilePtr); for(j=0;j0) { Framework[i].Bends[j]=(QUAD*)calloc(Framework[i].NumberOfBends[j],sizeof(QUAD)); Framework[i].BendType[j]=(int*)calloc(Framework[i].NumberOfBends[j],sizeof(int)); Framework[i].BendArguments[j]=(REAL(*)[MAX_BEND_POTENTIAL_ARGUMENTS]) calloc(Framework[i].NumberOfBends[j],sizeof(REAL[MAX_BEND_POTENTIAL_ARGUMENTS])); fread(Framework[i].Bends[j],sizeof(QUAD),Framework[i].NumberOfBends[j],FilePtr); fread(Framework[i].BendType[j],sizeof(int),Framework[i].NumberOfBends[j],FilePtr); fread(Framework[i].BendArguments[j],sizeof(REAL[MAX_BEND_POTENTIAL_ARGUMENTS]),Framework[i].NumberOfBends[j],FilePtr); } } } fread(&Framework[i].NumberOfInversionBendDefinitions,sizeof(int),1,FilePtr); Framework[i].NumberOfInversionBends=(int*)calloc(Framework[i].NumberOfFrameworks,sizeof(int)); if(Framework[i].NumberOfInversionBendDefinitions>0) { // alloc memory Framework[i].InversionBendDefinitionType=(int*)calloc(Framework[i].NumberOfInversionBendDefinitions,sizeof(int)); Framework[i].InversionBendDefinitions=(QUAD*)calloc(Framework[i].NumberOfInversionBendDefinitions,sizeof(QUAD)); Framework[i].InversionBendArgumentDefinitions=(REAL(*)[MAX_INVERSION_BEND_POTENTIAL_ARGUMENTS]) calloc(Framework[i].NumberOfInversionBendDefinitions,sizeof(REAL[MAX_INVERSION_BEND_POTENTIAL_ARGUMENTS])); Framework[i].NumberOfInversionBendsPerType=(int*)calloc(Framework[i].NumberOfInversionBendDefinitions,sizeof(int)); fread(Framework[i].InversionBendDefinitionType,sizeof(int),Framework[i].NumberOfInversionBendDefinitions,FilePtr); fread(Framework[i].InversionBendDefinitions,sizeof(QUAD),Framework[i].NumberOfInversionBendDefinitions,FilePtr); fread(Framework[i].InversionBendArgumentDefinitions,sizeof(REAL[MAX_INVERSION_BEND_POTENTIAL_ARGUMENTS]),Framework[i].NumberOfInversionBendDefinitions,FilePtr); fread(Framework[i].NumberOfInversionBendsPerType,sizeof(int),Framework[i].NumberOfInversionBendDefinitions,FilePtr); Framework[i].MaxNumberOfInversionBends=(int*)calloc(Framework[i].NumberOfFrameworks,sizeof(int)); Framework[i].InversionBends=(QUAD**)calloc(Framework[i].NumberOfFrameworks,sizeof(QUAD*)); Framework[i].InversionBendType=(int**)calloc(Framework[i].NumberOfFrameworks,sizeof(int*)); Framework[i].InversionBendArguments=(REAL(**)[MAX_INVERSION_BEND_POTENTIAL_ARGUMENTS])calloc(Framework[i].NumberOfFrameworks, sizeof(REAL(*)[MAX_INVERSION_BEND_POTENTIAL_ARGUMENTS])); fread(Framework[i].NumberOfInversionBends,sizeof(int),Framework[i].NumberOfFrameworks,FilePtr); fread(Framework[i].MaxNumberOfInversionBends,sizeof(int),Framework[i].NumberOfFrameworks,FilePtr); for(j=0;j0) { Framework[i].InversionBends[j]=(QUAD*)calloc(Framework[i].NumberOfInversionBends[j],sizeof(QUAD)); Framework[i].InversionBendType[j]=(int*)calloc(Framework[i].NumberOfInversionBends[j],sizeof(int)); Framework[i].InversionBendArguments[j]=(REAL(*)[MAX_INVERSION_BEND_POTENTIAL_ARGUMENTS]) calloc(Framework[i].NumberOfInversionBends[j],sizeof(REAL[MAX_INVERSION_BEND_POTENTIAL_ARGUMENTS])); fread(Framework[i].InversionBends[j],sizeof(QUAD),Framework[i].NumberOfInversionBends[j],FilePtr); fread(Framework[i].InversionBendType[j],sizeof(int),Framework[i].NumberOfInversionBends[j],FilePtr); fread(Framework[i].InversionBendArguments[j],sizeof(REAL[MAX_INVERSION_BEND_POTENTIAL_ARGUMENTS]),Framework[i].NumberOfInversionBends[j],FilePtr); } } } fread(&Framework[i].NumberOfTorsionDefinitions,sizeof(int),1,FilePtr); Framework[i].NumberOfTorsions=(int*)calloc(Framework[i].NumberOfFrameworks,sizeof(int)); if(Framework[i].NumberOfTorsionDefinitions>0) { // alloc memory Framework[i].TorsionDefinitionType=(int*)calloc(Framework[i].NumberOfTorsionDefinitions,sizeof(int)); Framework[i].TorsionDefinitions=(QUAD*)calloc(Framework[i].NumberOfTorsionDefinitions,sizeof(QUAD)); Framework[i].TorsionArgumentDefinitions=(REAL(*)[MAX_TORSION_POTENTIAL_ARGUMENTS]) calloc(Framework[i].NumberOfTorsionDefinitions,sizeof(REAL[MAX_TORSION_POTENTIAL_ARGUMENTS])); Framework[i].NumberOfTorsionsPerType=(int*)calloc(Framework[i].NumberOfTorsionDefinitions,sizeof(int)); fread(Framework[i].TorsionDefinitionType,sizeof(int),Framework[i].NumberOfTorsionDefinitions,FilePtr); fread(Framework[i].TorsionDefinitions,sizeof(QUAD),Framework[i].NumberOfTorsionDefinitions,FilePtr); fread(Framework[i].TorsionArgumentDefinitions,sizeof(REAL[MAX_TORSION_POTENTIAL_ARGUMENTS]),Framework[i].NumberOfTorsionDefinitions,FilePtr); fread(Framework[i].NumberOfTorsionsPerType,sizeof(int),Framework[i].NumberOfTorsionDefinitions,FilePtr); Framework[i].MaxNumberOfTorsions=(int*)calloc(Framework[i].NumberOfFrameworks,sizeof(int)); Framework[i].Torsions=(QUAD**)calloc(Framework[i].NumberOfFrameworks,sizeof(QUAD*)); Framework[i].TorsionType=(int**)calloc(Framework[i].NumberOfFrameworks,sizeof(int*)); Framework[i].TorsionArguments=(REAL(**)[MAX_TORSION_POTENTIAL_ARGUMENTS])calloc(Framework[i].NumberOfFrameworks, sizeof(REAL(*)[MAX_TORSION_POTENTIAL_ARGUMENTS])); fread(Framework[i].NumberOfTorsions,sizeof(int),Framework[i].NumberOfFrameworks,FilePtr); fread(Framework[i].MaxNumberOfTorsions,sizeof(int),Framework[i].NumberOfFrameworks,FilePtr); for(j=0;j0) { Framework[i].Torsions[j]=(QUAD*)calloc(Framework[i].NumberOfTorsions[j],sizeof(QUAD)); Framework[i].TorsionType[j]=(int*)calloc(Framework[i].NumberOfTorsions[j],sizeof(int)); Framework[i].TorsionArguments[j]=(REAL(*)[MAX_TORSION_POTENTIAL_ARGUMENTS]) calloc(Framework[i].NumberOfTorsions[j],sizeof(REAL[MAX_TORSION_POTENTIAL_ARGUMENTS])); fread(Framework[i].Torsions[j],sizeof(QUAD),Framework[i].NumberOfTorsions[j],FilePtr); fread(Framework[i].TorsionType[j],sizeof(int),Framework[i].NumberOfTorsions[j],FilePtr); fread(Framework[i].TorsionArguments[j],sizeof(REAL[MAX_TORSION_POTENTIAL_ARGUMENTS]),Framework[i].NumberOfTorsions[j],FilePtr); } } } fread(&Framework[i].NumberOfImproperTorsionDefinitions,sizeof(int),1,FilePtr); Framework[i].NumberOfImproperTorsions=(int*)calloc(Framework[i].NumberOfFrameworks,sizeof(int)); if(Framework[i].NumberOfImproperTorsionDefinitions>0) { // alloc memory Framework[i].ImproperTorsionDefinitionType=(int*)calloc(Framework[i].NumberOfImproperTorsionDefinitions,sizeof(int)); Framework[i].ImproperTorsionDefinitions=(QUAD*)calloc(Framework[i].NumberOfImproperTorsionDefinitions,sizeof(QUAD)); Framework[i].ImproperTorsionArgumentDefinitions=(REAL(*)[MAX_IMPROPER_TORSION_POTENTIAL_ARGUMENTS]) calloc(Framework[i].NumberOfImproperTorsionDefinitions,sizeof(REAL[MAX_IMPROPER_TORSION_POTENTIAL_ARGUMENTS])); Framework[i].NumberOfImproperTorsionsPerType=(int*)calloc(Framework[i].NumberOfImproperTorsionDefinitions,sizeof(int)); fread(Framework[i].ImproperTorsionDefinitionType,sizeof(int),Framework[i].NumberOfImproperTorsionDefinitions,FilePtr); fread(Framework[i].ImproperTorsionDefinitions,sizeof(QUAD),Framework[i].NumberOfImproperTorsionDefinitions,FilePtr); fread(Framework[i].ImproperTorsionArgumentDefinitions,sizeof(REAL[MAX_IMPROPER_TORSION_POTENTIAL_ARGUMENTS]),Framework[i].NumberOfImproperTorsionDefinitions,FilePtr); fread(Framework[i].NumberOfImproperTorsionsPerType,sizeof(int),Framework[i].NumberOfImproperTorsionDefinitions,FilePtr); Framework[i].MaxNumberOfImproperTorsions=(int*)calloc(Framework[i].NumberOfFrameworks,sizeof(int)); Framework[i].ImproperTorsions=(QUAD**)calloc(Framework[i].NumberOfFrameworks,sizeof(QUAD*)); Framework[i].ImproperTorsionType=(int**)calloc(Framework[i].NumberOfFrameworks,sizeof(int*)); Framework[i].ImproperTorsionArguments=(REAL(**)[MAX_IMPROPER_TORSION_POTENTIAL_ARGUMENTS])calloc(Framework[i].NumberOfFrameworks, sizeof(REAL(*)[MAX_IMPROPER_TORSION_POTENTIAL_ARGUMENTS])); fread(Framework[i].NumberOfImproperTorsions,sizeof(int),Framework[i].NumberOfFrameworks,FilePtr); fread(Framework[i].MaxNumberOfImproperTorsions,sizeof(int),Framework[i].NumberOfFrameworks,FilePtr); for(j=0;j0) { Framework[i].ImproperTorsions[j]=(QUAD*)calloc(Framework[i].NumberOfImproperTorsions[j],sizeof(QUAD)); Framework[i].ImproperTorsionType[j]=(int*)calloc(Framework[i].NumberOfImproperTorsions[j],sizeof(int)); Framework[i].ImproperTorsionArguments[j]=(REAL(*)[MAX_IMPROPER_TORSION_POTENTIAL_ARGUMENTS]) calloc(Framework[i].MaxNumberOfImproperTorsions[j],sizeof(REAL[MAX_IMPROPER_TORSION_POTENTIAL_ARGUMENTS])); fread(Framework[i].ImproperTorsions[j],sizeof(QUAD),Framework[i].NumberOfImproperTorsions[j],FilePtr); fread(Framework[i].ImproperTorsionType[j],sizeof(int),Framework[i].NumberOfImproperTorsions[j],FilePtr); fread(Framework[i].ImproperTorsionArguments[j],sizeof(REAL[MAX_IMPROPER_TORSION_POTENTIAL_ARGUMENTS]),Framework[i].NumberOfImproperTorsions[j],FilePtr); } } } fread(&Framework[i].NumberOfOutOfPlaneDefinitions,sizeof(int),1,FilePtr); Framework[i].NumberOfOutOfPlanes=(int*)calloc(Framework[i].NumberOfFrameworks,sizeof(int)); if(Framework[i].NumberOfOutOfPlaneDefinitions>0) { // alloc memory Framework[i].OutOfPlaneDefinitionType=(int*)calloc(Framework[i].NumberOfOutOfPlaneDefinitions,sizeof(int)); Framework[i].OutOfPlaneDefinitions=(QUAD*)calloc(Framework[i].NumberOfOutOfPlaneDefinitions,sizeof(QUAD)); Framework[i].OutOfPlaneArgumentDefinitions=(REAL(*)[MAX_OUT_OF_PLANE_POTENTIAL_ARGUMENTS]) calloc(Framework[i].NumberOfOutOfPlaneDefinitions,sizeof(REAL[MAX_OUT_OF_PLANE_POTENTIAL_ARGUMENTS])); Framework[i].NumberOfOutOfPlanesPerType=(int*)calloc(Framework[i].NumberOfOutOfPlaneDefinitions,sizeof(int)); fread(Framework[i].OutOfPlaneDefinitionType,sizeof(int),Framework[i].NumberOfOutOfPlaneDefinitions,FilePtr); fread(Framework[i].OutOfPlaneDefinitions,sizeof(QUAD),Framework[i].NumberOfOutOfPlaneDefinitions,FilePtr); fread(Framework[i].OutOfPlaneArgumentDefinitions,sizeof(REAL[MAX_OUT_OF_PLANE_POTENTIAL_ARGUMENTS]),Framework[i].NumberOfOutOfPlaneDefinitions,FilePtr); fread(Framework[i].NumberOfOutOfPlanesPerType,sizeof(int),Framework[i].NumberOfOutOfPlaneDefinitions,FilePtr); Framework[i].MaxNumberOfOutOfPlanes=(int*)calloc(Framework[i].NumberOfFrameworks,sizeof(int)); Framework[i].OutOfPlanes=(QUAD**)calloc(Framework[i].NumberOfFrameworks,sizeof(QUAD*)); Framework[i].OutOfPlaneType=(int**)calloc(Framework[i].NumberOfFrameworks,sizeof(int*)); Framework[i].OutOfPlaneArguments=(REAL(**)[MAX_OUT_OF_PLANE_POTENTIAL_ARGUMENTS])calloc(Framework[i].NumberOfFrameworks, sizeof(REAL(*)[MAX_OUT_OF_PLANE_POTENTIAL_ARGUMENTS])); fread(Framework[i].NumberOfOutOfPlanes,sizeof(int),Framework[i].NumberOfFrameworks,FilePtr); fread(Framework[i].MaxNumberOfOutOfPlanes,sizeof(int),Framework[i].NumberOfFrameworks,FilePtr); for(j=0;j0) { Framework[i].OutOfPlanes[j]=(QUAD*)calloc(Framework[i].NumberOfOutOfPlanes[j],sizeof(QUAD)); Framework[i].OutOfPlaneType[j]=(int*)calloc(Framework[i].NumberOfOutOfPlanes[j],sizeof(int)); Framework[i].OutOfPlaneArguments[j]=(REAL(*)[MAX_OUT_OF_PLANE_POTENTIAL_ARGUMENTS]) calloc(Framework[i].MaxNumberOfOutOfPlanes[j],sizeof(REAL[MAX_OUT_OF_PLANE_POTENTIAL_ARGUMENTS])); fread(Framework[i].OutOfPlanes[j],sizeof(QUAD),Framework[i].NumberOfOutOfPlanes[j],FilePtr); fread(Framework[i].OutOfPlaneType[j],sizeof(int),Framework[i].NumberOfOutOfPlanes[j],FilePtr); fread(Framework[i].OutOfPlaneArguments[j],sizeof(REAL[MAX_OUT_OF_PLANE_POTENTIAL_ARGUMENTS]),Framework[i].NumberOfOutOfPlanes[j],FilePtr); } } } fread(&Framework[i].NumberOfBondBondDefinitions,sizeof(int),1,FilePtr); Framework[i].NumberOfBondBonds=(int*)calloc(Framework[i].NumberOfFrameworks,sizeof(int)); if(Framework[i].NumberOfBondBondDefinitions>0) { // alloc memory Framework[i].BondBondDefinitionType=(int*)calloc(Framework[i].NumberOfBondBondDefinitions,sizeof(int)); Framework[i].BondBondDefinitions=(TRIPLE*)calloc(Framework[i].NumberOfBondBondDefinitions,sizeof(TRIPLE)); Framework[i].BondBondArgumentDefinitions=(REAL(*)[MAX_BOND_BOND_POTENTIAL_ARGUMENTS]) calloc(Framework[i].NumberOfBondBondDefinitions,sizeof(REAL[MAX_BOND_BOND_POTENTIAL_ARGUMENTS])); Framework[i].NumberOfBondBondsPerType=(int*)calloc(Framework[i].NumberOfBondBondDefinitions,sizeof(int)); fread(Framework[i].BondBondDefinitionType,sizeof(int),Framework[i].NumberOfBondBondDefinitions,FilePtr); fread(Framework[i].BondBondDefinitions,sizeof(TRIPLE),Framework[i].NumberOfBondBondDefinitions,FilePtr); fread(Framework[i].BondBondArgumentDefinitions,sizeof(REAL[MAX_BOND_BOND_POTENTIAL_ARGUMENTS]),Framework[i].NumberOfBondBondDefinitions,FilePtr); fread(Framework[i].NumberOfBondBondsPerType,sizeof(int),Framework[i].NumberOfBondBondDefinitions,FilePtr); Framework[i].MaxNumberOfBondBonds=(int*)calloc(Framework[i].NumberOfFrameworks,sizeof(int)); Framework[i].BondBonds=(TRIPLE**)calloc(Framework[i].NumberOfFrameworks,sizeof(TRIPLE*)); Framework[i].BondBondType=(int**)calloc(Framework[i].NumberOfFrameworks,sizeof(int*)); Framework[i].BondBondArguments=(REAL(**)[MAX_BOND_BOND_POTENTIAL_ARGUMENTS])calloc(Framework[i].NumberOfFrameworks, sizeof(REAL(*)[MAX_BOND_BOND_POTENTIAL_ARGUMENTS])); fread(Framework[i].NumberOfBondBonds,sizeof(int),Framework[i].NumberOfFrameworks,FilePtr); fread(Framework[i].MaxNumberOfBondBonds,sizeof(int),Framework[i].NumberOfFrameworks,FilePtr); for(j=0;j0) { Framework[i].BondBonds[j]=(TRIPLE*)calloc(Framework[i].NumberOfBondBonds[j],sizeof(TRIPLE)); Framework[i].BondBondType[j]=(int*)calloc(Framework[i].NumberOfBondBonds[j],sizeof(int)); Framework[i].BondBondArguments[j]=(REAL(*)[MAX_IMPROPER_TORSION_POTENTIAL_ARGUMENTS]) calloc(Framework[i].MaxNumberOfBondBonds[j],sizeof(REAL[MAX_BOND_BOND_POTENTIAL_ARGUMENTS])); fread(Framework[i].BondBonds[j],sizeof(TRIPLE),Framework[i].NumberOfBondBonds[j],FilePtr); fread(Framework[i].BondBondType[j],sizeof(int),Framework[i].NumberOfBondBonds[j],FilePtr); fread(Framework[i].BondBondArguments[j],sizeof(REAL[MAX_BOND_BOND_POTENTIAL_ARGUMENTS]),Framework[i].NumberOfBondBonds[j],FilePtr); } } } fread(&Framework[i].NumberOfBondBendDefinitions,sizeof(int),1,FilePtr); Framework[i].NumberOfBondBends=(int*)calloc(Framework[i].NumberOfFrameworks,sizeof(int)); if(Framework[i].NumberOfBondBendDefinitions>0) { // alloc memory Framework[i].BondBendDefinitionType=(int*)calloc(Framework[i].NumberOfBondBendDefinitions,sizeof(int)); Framework[i].BondBendDefinitions=(TRIPLE*)calloc(Framework[i].NumberOfBondBendDefinitions,sizeof(TRIPLE)); Framework[i].BondBendArgumentDefinitions=(REAL(*)[MAX_BOND_BEND_POTENTIAL_ARGUMENTS]) calloc(Framework[i].NumberOfBondBendDefinitions,sizeof(REAL[MAX_BOND_BEND_POTENTIAL_ARGUMENTS])); Framework[i].NumberOfBondBendsPerType=(int*)calloc(Framework[i].NumberOfBondBendDefinitions,sizeof(int)); fread(Framework[i].BondBendDefinitionType,sizeof(int),Framework[i].NumberOfBondBendDefinitions,FilePtr); fread(Framework[i].BondBendDefinitions,sizeof(TRIPLE),Framework[i].NumberOfBondBendDefinitions,FilePtr); fread(Framework[i].BondBendArgumentDefinitions,sizeof(REAL[MAX_BOND_BEND_POTENTIAL_ARGUMENTS]),Framework[i].NumberOfBondBendDefinitions,FilePtr); fread(Framework[i].NumberOfBondBendsPerType,sizeof(int),Framework[i].NumberOfBondBendDefinitions,FilePtr); Framework[i].MaxNumberOfBondBends=(int*)calloc(Framework[i].NumberOfFrameworks,sizeof(int)); Framework[i].BondBends=(TRIPLE**)calloc(Framework[i].NumberOfFrameworks,sizeof(TRIPLE*)); Framework[i].BondBendType=(int**)calloc(Framework[i].NumberOfFrameworks,sizeof(int*)); Framework[i].BondBendArguments=(REAL(**)[MAX_BOND_BEND_POTENTIAL_ARGUMENTS])calloc(Framework[i].NumberOfFrameworks, sizeof(REAL(*)[MAX_BOND_BEND_POTENTIAL_ARGUMENTS])); fread(Framework[i].NumberOfBondBends,sizeof(int),Framework[i].NumberOfFrameworks,FilePtr); fread(Framework[i].MaxNumberOfBondBends,sizeof(int),Framework[i].NumberOfFrameworks,FilePtr); for(j=0;j0) { Framework[i].BondBends[j]=(TRIPLE*)calloc(Framework[i].NumberOfBondBends[j],sizeof(TRIPLE)); Framework[i].BondBendType[j]=(int*)calloc(Framework[i].NumberOfBondBends[j],sizeof(int)); Framework[i].BondBendArguments[j]=(REAL(*)[MAX_IMPROPER_TORSION_POTENTIAL_ARGUMENTS]) calloc(Framework[i].MaxNumberOfBondBends[j],sizeof(REAL[MAX_BOND_BEND_POTENTIAL_ARGUMENTS])); fread(Framework[i].BondBends[j],sizeof(TRIPLE),Framework[i].NumberOfBondBends[j],FilePtr); fread(Framework[i].BondBendType[j],sizeof(int),Framework[i].NumberOfBondBends[j],FilePtr); fread(Framework[i].BondBendArguments[j],sizeof(REAL[MAX_BOND_BEND_POTENTIAL_ARGUMENTS]),Framework[i].NumberOfBondBends[j],FilePtr); } } } fread(&Framework[i].NumberOfBendBendDefinitions,sizeof(int),1,FilePtr); Framework[i].NumberOfBendBends=(int*)calloc(Framework[i].NumberOfFrameworks,sizeof(int)); if(Framework[i].NumberOfBendBendDefinitions>0) { // alloc memory Framework[i].BendBendDefinitionType=(int*)calloc(Framework[i].NumberOfBendBendDefinitions,sizeof(int)); Framework[i].BendBendDefinitions=(QUAD*)calloc(Framework[i].NumberOfBendBendDefinitions,sizeof(QUAD)); Framework[i].BendBendArgumentDefinitions=(REAL(*)[MAX_BEND_BEND_POTENTIAL_ARGUMENTS]) calloc(Framework[i].NumberOfBendBendDefinitions,sizeof(REAL[MAX_BEND_BEND_POTENTIAL_ARGUMENTS])); Framework[i].NumberOfBendBendsPerType=(int*)calloc(Framework[i].NumberOfBendBendDefinitions,sizeof(int)); fread(Framework[i].BendBendDefinitionType,sizeof(int),Framework[i].NumberOfBendBendDefinitions,FilePtr); fread(Framework[i].BendBendDefinitions,sizeof(QUAD),Framework[i].NumberOfBendBendDefinitions,FilePtr); fread(Framework[i].BendBendArgumentDefinitions,sizeof(REAL[MAX_BEND_BEND_POTENTIAL_ARGUMENTS]),Framework[i].NumberOfBendBendDefinitions,FilePtr); fread(Framework[i].NumberOfBendBendsPerType,sizeof(int),Framework[i].NumberOfBendBendDefinitions,FilePtr); Framework[i].MaxNumberOfBendBends=(int*)calloc(Framework[i].NumberOfFrameworks,sizeof(int)); Framework[i].BendBends=(QUAD**)calloc(Framework[i].NumberOfFrameworks,sizeof(QUAD*)); Framework[i].BendBendType=(int**)calloc(Framework[i].NumberOfFrameworks,sizeof(int*)); Framework[i].BendBendArguments=(REAL(**)[MAX_BEND_BEND_POTENTIAL_ARGUMENTS])calloc(Framework[i].NumberOfFrameworks, sizeof(REAL(*)[MAX_BEND_BEND_POTENTIAL_ARGUMENTS])); fread(Framework[i].NumberOfBendBends,sizeof(int),Framework[i].NumberOfFrameworks,FilePtr); fread(Framework[i].MaxNumberOfBendBends,sizeof(int),Framework[i].NumberOfFrameworks,FilePtr); for(j=0;j0) { Framework[i].BendBends[j]=(QUAD*)calloc(Framework[i].NumberOfBendBends[j],sizeof(QUAD)); Framework[i].BendBendType[j]=(int*)calloc(Framework[i].NumberOfBendBends[j],sizeof(int)); Framework[i].BendBendArguments[j]=(REAL(*)[MAX_IMPROPER_TORSION_POTENTIAL_ARGUMENTS]) calloc(Framework[i].MaxNumberOfBendBends[j],sizeof(REAL[MAX_BEND_BEND_POTENTIAL_ARGUMENTS])); fread(Framework[i].BendBends[j],sizeof(QUAD),Framework[i].NumberOfBendBends[j],FilePtr); fread(Framework[i].BendBendType[j],sizeof(int),Framework[i].NumberOfBendBends[j],FilePtr); fread(Framework[i].BendBendArguments[j],sizeof(REAL[MAX_BEND_BEND_POTENTIAL_ARGUMENTS]),Framework[i].NumberOfBendBends[j],FilePtr); } } } fread(&Framework[i].NumberOfBondTorsionDefinitions,sizeof(int),1,FilePtr); Framework[i].NumberOfBondTorsions=(int*)calloc(Framework[i].NumberOfFrameworks,sizeof(int)); if(Framework[i].NumberOfBondTorsionDefinitions>0) { // alloc memory Framework[i].BondTorsionDefinitionType=(int*)calloc(Framework[i].NumberOfBondTorsionDefinitions,sizeof(int)); Framework[i].BondTorsionDefinitions=(QUAD*)calloc(Framework[i].NumberOfBondTorsionDefinitions,sizeof(QUAD)); Framework[i].BondTorsionArgumentDefinitions=(REAL(*)[MAX_BOND_TORSION_POTENTIAL_ARGUMENTS]) calloc(Framework[i].NumberOfBondTorsionDefinitions,sizeof(REAL[MAX_BOND_TORSION_POTENTIAL_ARGUMENTS])); Framework[i].NumberOfBondTorsionsPerType=(int*)calloc(Framework[i].NumberOfBondTorsionDefinitions,sizeof(int)); fread(Framework[i].BondTorsionDefinitionType,sizeof(int),Framework[i].NumberOfBondTorsionDefinitions,FilePtr); fread(Framework[i].BondTorsionDefinitions,sizeof(QUAD),Framework[i].NumberOfBondTorsionDefinitions,FilePtr); fread(Framework[i].BondTorsionArgumentDefinitions,sizeof(REAL[MAX_BOND_TORSION_POTENTIAL_ARGUMENTS]),Framework[i].NumberOfBondTorsionDefinitions,FilePtr); fread(Framework[i].NumberOfBondTorsionsPerType,sizeof(int),Framework[i].NumberOfBondTorsionDefinitions,FilePtr); Framework[i].MaxNumberOfBondTorsions=(int*)calloc(Framework[i].NumberOfFrameworks,sizeof(int)); Framework[i].BondTorsions=(QUAD**)calloc(Framework[i].NumberOfFrameworks,sizeof(QUAD*)); Framework[i].BondTorsionType=(int**)calloc(Framework[i].NumberOfFrameworks,sizeof(int*)); Framework[i].BondTorsionArguments=(REAL(**)[MAX_BOND_TORSION_POTENTIAL_ARGUMENTS])calloc(Framework[i].NumberOfFrameworks, sizeof(REAL(*)[MAX_BOND_TORSION_POTENTIAL_ARGUMENTS])); fread(Framework[i].NumberOfBondTorsions,sizeof(int),Framework[i].NumberOfFrameworks,FilePtr); fread(Framework[i].MaxNumberOfBondTorsions,sizeof(int),Framework[i].NumberOfFrameworks,FilePtr); for(j=0;j0) { Framework[i].BondTorsions[j]=(QUAD*)calloc(Framework[i].NumberOfBondTorsions[j],sizeof(QUAD)); Framework[i].BondTorsionType[j]=(int*)calloc(Framework[i].NumberOfBondTorsions[j],sizeof(int)); Framework[i].BondTorsionArguments[j]=(REAL(*)[MAX_IMPROPER_TORSION_POTENTIAL_ARGUMENTS]) calloc(Framework[i].MaxNumberOfBondTorsions[j],sizeof(REAL[MAX_BOND_TORSION_POTENTIAL_ARGUMENTS])); fread(Framework[i].BondTorsions[j],sizeof(QUAD),Framework[i].NumberOfBondTorsions[j],FilePtr); fread(Framework[i].BondTorsionType[j],sizeof(int),Framework[i].NumberOfBondTorsions[j],FilePtr); fread(Framework[i].BondTorsionArguments[j],sizeof(REAL[MAX_BOND_TORSION_POTENTIAL_ARGUMENTS]),Framework[i].NumberOfBondTorsions[j],FilePtr); } } } fread(&Framework[i].NumberOfBendTorsionDefinitions,sizeof(int),1,FilePtr); Framework[i].NumberOfBendTorsions=(int*)calloc(Framework[i].NumberOfFrameworks,sizeof(int)); if(Framework[i].NumberOfBendTorsionDefinitions>0) { // alloc memory Framework[i].BendTorsionDefinitionType=(int*)calloc(Framework[i].NumberOfBendTorsionDefinitions,sizeof(int)); Framework[i].BendTorsionDefinitions=(QUAD*)calloc(Framework[i].NumberOfBendTorsionDefinitions,sizeof(QUAD)); Framework[i].BendTorsionArgumentDefinitions=(REAL(*)[MAX_BEND_TORSION_POTENTIAL_ARGUMENTS]) calloc(Framework[i].NumberOfBendTorsionDefinitions,sizeof(REAL[MAX_BEND_TORSION_POTENTIAL_ARGUMENTS])); Framework[i].NumberOfBendTorsionsPerType=(int*)calloc(Framework[i].NumberOfBendTorsionDefinitions,sizeof(int)); fread(Framework[i].BendTorsionDefinitionType,sizeof(int),Framework[i].NumberOfBendTorsionDefinitions,FilePtr); fread(Framework[i].BendTorsionDefinitions,sizeof(QUAD),Framework[i].NumberOfBendTorsionDefinitions,FilePtr); fread(Framework[i].BendTorsionArgumentDefinitions,sizeof(REAL[MAX_BEND_TORSION_POTENTIAL_ARGUMENTS]),Framework[i].NumberOfBendTorsionDefinitions,FilePtr); fread(Framework[i].NumberOfBendTorsionsPerType,sizeof(int),Framework[i].NumberOfBendTorsionDefinitions,FilePtr); Framework[i].MaxNumberOfBendTorsions=(int*)calloc(Framework[i].NumberOfFrameworks,sizeof(int)); Framework[i].BendTorsions=(QUAD**)calloc(Framework[i].NumberOfFrameworks,sizeof(QUAD*)); Framework[i].BendTorsionType=(int**)calloc(Framework[i].NumberOfFrameworks,sizeof(int*)); Framework[i].BendTorsionArguments=(REAL(**)[MAX_BEND_TORSION_POTENTIAL_ARGUMENTS])calloc(Framework[i].NumberOfFrameworks, sizeof(REAL(*)[MAX_BEND_TORSION_POTENTIAL_ARGUMENTS])); fread(Framework[i].NumberOfBendTorsions,sizeof(int),Framework[i].NumberOfFrameworks,FilePtr); fread(Framework[i].MaxNumberOfBendTorsions,sizeof(int),Framework[i].NumberOfFrameworks,FilePtr); for(j=0;j0) { Framework[i].BendTorsions[j]=(QUAD*)calloc(Framework[i].NumberOfBendTorsions[j],sizeof(QUAD)); Framework[i].BendTorsionType[j]=(int*)calloc(Framework[i].NumberOfBendTorsions[j],sizeof(int)); Framework[i].BendTorsionArguments[j]=(REAL(*)[MAX_IMPROPER_TORSION_POTENTIAL_ARGUMENTS]) calloc(Framework[i].MaxNumberOfBendTorsions[j],sizeof(REAL[MAX_BEND_TORSION_POTENTIAL_ARGUMENTS])); fread(Framework[i].BendTorsions[j],sizeof(QUAD),Framework[i].NumberOfBendTorsions[j],FilePtr); fread(Framework[i].BendTorsionType[j],sizeof(int),Framework[i].NumberOfBendTorsions[j],FilePtr); fread(Framework[i].BendTorsionArguments[j],sizeof(REAL[MAX_BEND_TORSION_POTENTIAL_ARGUMENTS]),Framework[i].NumberOfBendTorsions[j],FilePtr); } } } Framework[i].NumberOfIntraVDW=(int*)calloc(Framework[i].NumberOfFrameworks,sizeof(int)); Framework[i].NumberOfExcludedIntraVDW=(int*)calloc(Framework[i].NumberOfFrameworks,sizeof(int)); fread(Framework[i].NumberOfIntraVDW,sizeof(int),Framework[i].NumberOfFrameworks,FilePtr); fread(Framework[i].NumberOfExcludedIntraVDW,sizeof(int),Framework[i].NumberOfFrameworks,FilePtr); Framework[i].NumberOfIntraCharges=(int*)calloc(Framework[i].NumberOfFrameworks,sizeof(int)); Framework[i].NumberOfIntraChargeBondDipoles=(int*)calloc(Framework[i].NumberOfFrameworks,sizeof(int)); Framework[i].NumberOfIntraBondDipoles=(int*)calloc(Framework[i].NumberOfFrameworks,sizeof(int)); fread(Framework[i].NumberOfIntraCharges,sizeof(int),Framework[i].NumberOfFrameworks,FilePtr); fread(Framework[i].NumberOfIntraChargeBondDipoles,sizeof(int),Framework[i].NumberOfFrameworks,FilePtr); fread(Framework[i].NumberOfIntraBondDipoles,sizeof(int),Framework[i].NumberOfFrameworks,FilePtr); Framework[i].NumberOfExcludedIntraChargeCharge=(int*)calloc(Framework[i].NumberOfFrameworks,sizeof(int)); Framework[i].MaxNumberOfExcludedIntraChargeCharge=(int*)calloc(Framework[i].NumberOfFrameworks,sizeof(int)); fread(Framework[i].NumberOfExcludedIntraChargeCharge,sizeof(int),Framework[i].NumberOfFrameworks,FilePtr); fread(Framework[i].MaxNumberOfExcludedIntraChargeCharge,sizeof(int),Framework[i].NumberOfFrameworks,FilePtr); Framework[i].ExcludedIntraChargeCharge=(PAIR**)calloc(Framework[i].NumberOfFrameworks,sizeof(PAIR*)); Framework[i].NumberOfExcludedIntraChargeBondDipole=(int*)calloc(Framework[i].NumberOfFrameworks,sizeof(int)); Framework[i].MaxNumberOfExcludedIntraChargeBondDipole=(int*)calloc(Framework[i].NumberOfFrameworks,sizeof(int)); fread(Framework[i].NumberOfExcludedIntraChargeBondDipole,sizeof(int),Framework[i].NumberOfFrameworks,FilePtr); fread(Framework[i].MaxNumberOfExcludedIntraChargeBondDipole,sizeof(int),Framework[i].NumberOfFrameworks,FilePtr); Framework[i].ExcludedIntraChargeBondDipole=(PAIR**)calloc(Framework[i].NumberOfFrameworks,sizeof(PAIR*)); Framework[i].NumberOfExcludedIntraBondDipoleBondDipole=(int*)calloc(Framework[i].NumberOfFrameworks,sizeof(int)); Framework[i].MaxNumberOfExcludedIntraBondDipoleBondDipole=(int*)calloc(Framework[i].NumberOfFrameworks,sizeof(int)); fread(Framework[i].NumberOfExcludedIntraBondDipoleBondDipole,sizeof(int),Framework[i].NumberOfFrameworks,FilePtr); fread(Framework[i].MaxNumberOfExcludedIntraBondDipoleBondDipole,sizeof(int),Framework[i].NumberOfFrameworks,FilePtr); Framework[i].ExcludedIntraBondDipoleBondDipole=(PAIR**)calloc(Framework[i].NumberOfFrameworks,sizeof(PAIR*)); if(Framework[i].FrameworkModel==FLEXIBLE) { for(j=0;j0) { Framework[i].ExcludedIntraChargeCharge[j]=(PAIR*)calloc(Framework[i].NumberOfExcludedIntraChargeCharge[j],sizeof(PAIR)); fread(Framework[i].ExcludedIntraChargeCharge[j],sizeof(PAIR),Framework[i].NumberOfExcludedIntraChargeCharge[j],FilePtr); } Framework[i].MaxNumberOfExcludedIntraChargeBondDipole[j]=Framework[i].NumberOfExcludedIntraChargeBondDipole[j]; if(Framework[i].NumberOfExcludedIntraChargeBondDipole[j]) { Framework[i].ExcludedIntraChargeBondDipole[j]=(PAIR*)calloc(Framework[i].NumberOfExcludedIntraChargeBondDipole[j],sizeof(PAIR)); fread(Framework[i].ExcludedIntraChargeBondDipole[j],sizeof(PAIR),Framework[i].NumberOfExcludedIntraChargeBondDipole[j],FilePtr); } Framework[i].MaxNumberOfExcludedIntraBondDipoleBondDipole[j]=Framework[i].NumberOfExcludedIntraBondDipoleBondDipole[j]; if(Framework[i].NumberOfExcludedIntraBondDipoleBondDipole[j]>0) { Framework[i].ExcludedIntraBondDipoleBondDipole[j]=(PAIR*)calloc(Framework[i].NumberOfExcludedIntraBondDipoleBondDipole[j],sizeof(PAIR)); fread(Framework[i].ExcludedIntraBondDipoleBondDipole[j],sizeof(PAIR),Framework[i].NumberOfExcludedIntraBondDipoleBondDipole[j],FilePtr); } } } } // rather then store the exclusion matrix, recompute it when all required information is read CurrentSystem=i; MakeExclusionMatrix(i); // Add by Ambroise de Izarra //------------------------------------------------------------------- //AllocateList14atomsVDWandEwald(i); //printInteractionIndexAtoms(i); //------------------------------------------------------------------- } } fread(&NumberOfSingleSubstitutionRules,sizeof(int),1,FilePtr); if(NumberOfSingleSubstitutionRules>0) { SubstitutionSingleFrameworkAtom=(char(*)[3][256])calloc(NumberOfSingleSubstitutionRules,sizeof(char[3][256])); SubstitutionSingleFrameworkAtomTypes=(int(*)[3])calloc(NumberOfSingleSubstitutionRules,sizeof(int[3])); fread(SubstitutionSingleFrameworkAtom,sizeof(char[3][256]),NumberOfSingleSubstitutionRules,FilePtr); fread(SubstitutionSingleFrameworkAtomTypes,sizeof(int[3]),NumberOfSingleSubstitutionRules,FilePtr); } fread(&NumberOfSubstitutionRules,sizeof(int),1,FilePtr); fread(&NumberOfRandomSubstitutions,sizeof(int),1,FilePtr); if(NumberOfSubstitutionRules>0) { SubstitutionFrameworkAtoms=(char(*)[3][256])calloc(NumberOfSubstitutionRules,sizeof(char[3][256])); SubstitutionFrameworkAtomTypes=(int(*)[3])calloc(NumberOfSubstitutionRules,sizeof(int[3])); fread(SubstitutionFrameworkAtoms,sizeof(char[3][256]),NumberOfSubstitutionRules,FilePtr); fread(SubstitutionFrameworkAtomTypes,sizeof(int[3]),NumberOfSubstitutionRules,FilePtr); } fread(&NumberOfSubstitutions,sizeof(int),1,FilePtr); if(NumberOfSubstitutions>0) fread(ListOfAtomSubstitutions,sizeof(int[3]),NumberOfSubstitutions,FilePtr); // read the framework atom modification rules fread(&NumberOfModificationRules,sizeof(int),1,FilePtr); if(NumberOfModificationRules>0) { ModificationRuleType=(int*)calloc(NumberOfModificationRules,sizeof(int)); ModifyFrameworkAtoms=(char(*)[10][256])calloc(NumberOfModificationRules,sizeof(char[10][256])); ModifyFrameworkAtomTypes=(int(*)[10])calloc(NumberOfModificationRules,sizeof(int[10])); fread(ModificationRuleType,sizeof(int),NumberOfModificationRules,FilePtr); fread(ModifyFrameworkAtoms,sizeof(char[10][256]),NumberOfModificationRules,FilePtr); fread(ModifyFrameworkAtomTypes,sizeof(int[10]),NumberOfModificationRules,FilePtr); } fread(&NumberOfForbiddenConnectivityRules,sizeof(int),1,FilePtr); if(NumberOfForbiddenConnectivityRules>0) { ForbiddenConnectivityAtoms=(char(*)[3][256])calloc(NumberOfForbiddenConnectivityRules,sizeof(char[3][256])); ForbiddenConnectivityTypes=(int(*)[3])calloc(NumberOfForbiddenConnectivityRules,sizeof(int[3])); fread(ForbiddenConnectivityAtoms,sizeof(char[3][256]),NumberOfForbiddenConnectivityRules,FilePtr); fread(ForbiddenConnectivityTypes,sizeof(int[3]),NumberOfForbiddenConnectivityRules,FilePtr); } for(CurrentSystem=0;CurrentSystem1e-10) { fprintf(stderr, "Error in binary restart-file (ReadRestartFramework)\n"); ContinueAfterCrash=FALSE; } } // Added by Ambroise de Izarra //------------------------------------------------------------------- /********************************************************************************************************* * Name | printInteractionIndexAtoms (Added by A. de Izarra) * * ----------------------------------------------------------------------------------------------------- * * Function | print a list of bonds, bends, torsions (dihedrals) of a flexible framework * * Note | int system => index of the system. * *********************************************************************************************************/ void printInteractionIndexAtoms(int system) { int f1,i,j,index; FILE *FilePtr; char buffer[256]; for(f1=0;f1