X-Git-Url: http://git.osdn.net/view?a=blobdiff_plain;f=MolLib%2FMolecule.h;h=5bc83642429352f3fcfe5aa114e67da2f148e3d0;hb=388f1f455139811b1c290d55131fcc1aebf6a5cd;hp=6d024d2e02ecc12896e95e9856247a0b2dab074f;hpb=9d98193ab634c1e755dd84ca27341186e6549c2e;p=molby%2FMolby.git diff --git a/MolLib/Molecule.h b/MolLib/Molecule.h index 6d024d2..5bc8364 100755 --- a/MolLib/Molecule.h +++ b/MolLib/Molecule.h @@ -21,6 +21,8 @@ #include "Object.h" #include "IntGroup.h" +#include + #ifdef __cplusplus extern "C" { #endif @@ -44,6 +46,7 @@ typedef struct Aniso { char has_bsig; /* Has sigma values? */ Double bsig[6]; /* sigma values */ Mat33 pmat; /* A 3x3 matrix whose three column vectors are the principal axes of the ellipsoid. Note: If the B matrix is not positive definite, the axis length corresponding to the negative eigenvalue is replaced with 0.001. */ + Double eigval[3]; /* Eigenvalues of the B matrix; this should be all non-negative */ } Aniso; /* Symmetry operation */ @@ -114,6 +117,7 @@ typedef struct Atom { Vector fix_pos; Byte mm_exclude; /* If nonzero, then this atom is excluded from MM/MD calculations */ Byte periodic_exclude; /* If nonzero, then this atom is excluded from periodic calculations */ + char uff_type[6]; /* UFF type string */ } Atom; extern Int gSizeOfAtomRecord; @@ -196,8 +200,10 @@ enum { kGTOType_P, kGTOType_D, kGTOType_D5, - kGTOtype_F, + kGTOType_F, kGTOType_F7, + kGTOType_G, + kGTOType_G9, kGTOType_UU }; @@ -213,6 +219,7 @@ typedef struct ShellInfo { signed char sym; /* Symmetry of the basis; S, P, ... */ signed char ncomp; /* Number of components (S: 1, P: 3, SP: 4, etc.) */ signed char nprim; /* Number of primitives for this shell */ + signed char add_exp; /* Additional exponent (for JANPA-Molden only) */ Int p_idx; /* Index to the PrimInfo (exponent/coefficient) table */ Int cn_idx; /* Index to the normalized (cached) contraction coefficient table */ Int a_idx; /* Index to the atom which this primitive belongs to */ @@ -227,26 +234,67 @@ typedef struct BasisSet { PrimInfo *priminfos; /* Primitive information table */ Int ncns; /* Number of normalized (cached) contraction coefficient values */ Double *cns; /* Normalized (cached) contraction coefficients; (up to 10 values for each primitive) */ - Int natoms; /* Number of atoms; separately cached here because MO info should be invariant during editing */ - Vector *pos; /* Positions of atoms; the unit is bohr, not angstrom */ + Int natoms_bs; /* Number of atoms; separately cached here because MO info should be invariant during editing */ Double *nuccharges; /* Nuclear charges (for ECP atoms) */ Int ne_alpha, ne_beta; /* Number of alpha/beta electrons */ Int rflag; /* 0: UHF, 1: RHF, 2:ROHF */ Int ncomps; /* Number of AO components; equal to sum of shells[i].ncomp */ Int nmos; /* Number of MOs; equal to ncomps if close shell, ncomps*2 if open shell */ Double *mo; /* MO matrix (mo[i][j] represents the j-th AO coefficient for the i-th MO) */ + /* Memory are allocated for (2*nmos+1) entries; the last entry is for displaying arbitrary vector */ Double *moenergies; /* MO energies */ Double *scfdensities; /* SCF densities; lower triangle of a symmetric matrix (size nmos*(nmos+1)/2) */ Int ncubes; /* Number of calculated MOs */ Cube **cubes; /* Calculated MOs (an array of pointers to Cubes) */ } BasisSet; +/* Marching Cube (for drawing isosurface) */ +typedef struct MCubePoint { + Int key; /* key = ((ix*ny+iy)*nz+iz)*3+ii, ii=0/1/2 for x/y/z direction, respectively */ + float d; /* offset toward the direction; 0 <= d < 1 */ + float pos[3]; /* cartesian coordinate of the point */ + float grad[3]; /* gradient vector */ +} MCubePoint; + +typedef struct MCube { + char hidden; /* If non-zero, then this MCube is not drawn */ + Int idn; /* MO number */ + Vector origin; /* Cube origin */ + Double dx, dy, dz; /* Cube steps */ + Int nx, ny, nz; /* Cube dimension (must be multiples of 8) */ + Double thres; /* Threshold value */ + Double *dp; /* Value for point (ix, iy, iz) is in dp[(ix*ny+iy)*nz+iz] */ + Int nradii; + Double *radii; /* Estimated radius (with margin) for each atom */ + Double expand; /* Expand the estimated radius by this value (default: 1.0) */ + struct { + /* Flags for cube (ix, iy, iz)-(ix+1, iy+1, iz+1). It is an 8-bit */ + /* integer representing whether the values at the 8 corners are */ + /* larger than the threshold value or not. As special cases, */ + /* the values 0 and 255 (all corners are below or above the threshold) */ + /* are represented as 255, and the value 0 is used to indicate "yet undefined". */ + unsigned char *fp; + /* Cube points and triangles: for positive and negative surfaces */ + Int ncubepoints; + MCubePoint *cubepoints; + Int ntriangles; + Int *triangles; /* Triangles; indices to cubepoints[] */ + float rgba[4]; /* Surface color */ + } c[2]; +} MCube; + /* Electrostatic potential */ typedef struct Elpot { Vector pos; Double esp; } Elpot; +/* Properties (total energy etc.; specific for each frame) */ +typedef struct MolProp { + char *propname; + Double *propvals; +} MolProp; + /* Molecule record */ typedef struct Molecule { Object base; @@ -271,7 +319,6 @@ typedef struct Molecule { recalculated from the atoms if it is -1 */ Int cframe; /* The current frame number */ -/* Byte useFlexibleCell; *//* Obsolete (since 0.6.5; unit cell is frame dependent in all cases) */ Int nframe_cells; Vector *frame_cells; /* The cell vectors for frames; (nframe_cells*4) array of Vectors */ @@ -293,13 +340,24 @@ typedef struct Molecule { /* Information for basis sets and MOs */ BasisSet *bset; + /* Marching cube */ + MCube *mcube; + /* Electrostatic potential */ Int nelpots; Elpot *elpots; + /* Properties */ + Int nmolprops; + MolProp *molprops; + /* Parameters specific for this molecule */ struct Parameter *par; + /* Bond order (not to be used in MM/MD, but may be necessary to hold this info) */ + Int nbondOrders; + Double *bondOrders; + /* Flag to request rebuilding MD internal information */ Byte needsMDRebuild; @@ -321,6 +379,9 @@ typedef struct Molecule { /* Mutex object. If non-NULL, it should be locked before modifying molecule */ void *mutex; + /* Flag to prohibit modification from user interface */ + Byte dontModifyFromGUI; + /* Ruby pointer (see ruby_bind.c) */ void *exmolobj; Byte exmolobjProtected; @@ -329,6 +390,8 @@ typedef struct Molecule { int strlen_limit(const char *s, int limit); +void BasisSetRelease(BasisSet *bset); + Molecule *MoleculeNew(void); int MoleculeLoadFile(Molecule *mp, const char *fname, const char *ftype, char **errbuf); int MoleculeLoadPsfFile(Molecule *mp, const char *fname, char **errbuf); @@ -348,10 +411,12 @@ Molecule *MoleculeRetain(Molecule *mp); void MoleculeRelease(Molecule *mp); void MoleculeExchange(Molecule *mp1, Molecule *mp2); -int MoleculeAddGaussianOrbitalShell(Molecule *mol, Int sym, Int nprims, Int a_idx); +int MoleculeAddGaussianOrbitalShell(Molecule *mol, Int a_idx, Int sym, Int nprims, Int add_exp); int MoleculeAddGaussianPrimitiveCoefficients(Molecule *mol, Double exponent, Double contraction, Double contraction_sp); +int MoleculeGetGaussianComponentInfo(Molecule *mol, Int comp_idx, Int *outAtomIdx, char *outLabel, Int *outShellIdx); int MoleculeSetMOCoefficients(Molecule *mol, Int idx, Double energy, Int ncomps, Double *coeffs); -int MoleculeAllocateBasisSetRecord(Molecule *mol, Int rflag, Int ne_alpha, Int ne_beta); +int MoleculeGetMOCoefficients(Molecule *mol, Int idx, Double *energy, Int *ncoeffs, Double **coeffs); +int MoleculeSetMOInfo(Molecule *mol, Int rflag, Int ne_alpha, Int ne_beta); void MoleculeIncrementModifyCount(Molecule *mp); void MoleculeClearModifyCount(Molecule *mp); @@ -365,11 +430,14 @@ void MoleculeSetCell(Molecule *mp, Double a, Double b, Double c, Double alpha, D void MoleculeSetAniso(Molecule *mp, int n1, int type, Double x11, Double x22, Double x33, Double x12, Double x13, Double x23, const Double *sigmap); void MoleculeSetAnisoBySymop(Molecule *mp, int idx); int MoleculeSetPeriodicBox(Molecule *mp, const Vector *ax, const Vector *ay, const Vector *az, const Vector *ao, const char *periodic, int convertCoordinates); +int MoleculeCalculateCellFromAxes(XtalCell *cp, int calc_abc); int MoleculeReadCoordinatesFromFile(Molecule *mp, const char *fname, const char *ftype, char **errbuf); int MoleculeReadCoordinatesFromPdbFile(Molecule *mp, const char *fname, char **errbuf); int MoleculeReadCoordinatesFromDcdFile(Molecule *mp, const char *fname, char **errbuf); +int MoleculeLoadGamessDatFile(Molecule *mol, const char *fname, char **errbuf); + int MoleculeReadExtendedInfo(Molecule *mp, const char *fname, char **errbuf); int MoleculeWriteExtendedInfo(Molecule *mp, const char *fname, char **errbuf); @@ -378,6 +446,7 @@ int MoleculeWriteToPsfFile(Molecule *mp, const char *fname, char **errbuf); int MoleculeWriteToPdbFile(Molecule *mp, const char *fname, char **errbuf); int MoleculeWriteToDcdFile(Molecule *mp, const char *fname, char **errbuf); int MoleculeWriteToTepFile(Molecule *mp, const char *fname, char **errbuf); +int MoleculeWriteToMbsfFile(Molecule *mp, const char *fname, char **errbuf); void MoleculeDump(Molecule *mol); int MoleculePrepareMDArena(Molecule *mol, int check_only, char **retmsg); @@ -407,6 +476,8 @@ int MoleculeUnmerge(Molecule *src, Molecule **dstp, IntGroup *where, int resSeqO int MoleculeExtract(Molecule *src, Molecule **dstp, IntGroup *where, int dummyFlag); int MoleculeAddBonds(Molecule *mp, Int nbonds, const Int *bonds, IntGroup *where, Int autoGenerate); int MoleculeDeleteBonds(Molecule *mp, Int *bonds, IntGroup *where, Int **outRemoved, IntGroup **outRemovedPos); +int MoleculeAssignBondOrders(Molecule *mp, const Double *orders, IntGroup *where); +int MoleculeGetBondOrders(Molecule *mp, Double *outOrders, IntGroup *where); int MoleculeAddAngles(Molecule *mp, const Int *angles, IntGroup *where); int MoleculeDeleteAngles(Molecule *mp, Int *angles, IntGroup *where); int MoleculeAddDihedrals(Molecule *mp, const Int *dihedrals, IntGroup *where); @@ -418,16 +489,6 @@ int MoleculeLookupAngle(Molecule *mp, Int n1, Int n2, Int n3); int MoleculeLookupDihedral(Molecule *mp, Int n1, Int n2, Int n3, Int n4); int MoleculeLookupImproper(Molecule *mp, Int n1, Int n2, Int n3, Int n4); -/* -Int MoleculeReplaceAllAngles(Molecule *mol, Int nangles, const Int *angles, Int **outAngles); -Int MoleculeReplaceAllDihedrals(Molecule *mol, Int ndihedrals, const Int *dihedrals, Int **outDihedrals); -Int MoleculeReplaceAllImpropers(Molecule *mol, Int nimpropers, const Int *impropers, Int **outImpropers); - -Int MoleculeFindAllAngles(Molecule *mol, Int **outAngles); -Int MoleculeFindAllDihedrals(Molecule *mol, Int **outDihedrals); -Int MoleculeFindAllImpropers(Molecule *mol, Int **outImpropers); -*/ - Int MoleculeFindMissingAngles(Molecule *mol, Int **outAngles); Int MoleculeFindMissingDihedrals(Molecule *mol, Int **outDihedrals); Int MoleculeFindMissingImpropers(Molecule *mol, Int **outImpropers); @@ -447,7 +508,7 @@ int MoleculeLookupAtomInResidue(Molecule *mp, int n1, int resno); int MoleculeAnalyzeAtomName(const char *s, char *resName, int *resSeq, char *atomName); int MoleculeAtomIndexFromString(Molecule *mp, const char *s); -int MoleculeFindCloseAtoms(Molecule *mp, Int index, Double limit, Int *outNbonds, Int **outBonds, Int triangle); +int MoleculeFindCloseAtoms(Molecule *mp, const Vector *vp, Double radius, Double limit, Int *outNbonds, Int **outBonds, Int triangle); int MoleculeGuessBonds(Molecule *mp, Double limit, Int *outNbonds, Int **outBonds); int MoleculeRebuildTablesFromConnects(Molecule *mp); int MoleculeAreAtomsConnected(Molecule *mol, int idx1, int idx2); @@ -477,7 +538,6 @@ int MoleculeHideAtoms(Molecule *mp, IntGroup *ig); int MoleculeRenumberAtoms(Molecule *mp, const Int *new2old, Int *old2new_out, Int isize); void MoleculeTransform(Molecule *mp, Transform tr, IntGroup *group); -/*void MoleculeMove(Molecule *mp, Transform tr, IntGroup *group);*/ void MoleculeTranslate(Molecule *mp, const Vector *vp, IntGroup *group); void MoleculeRotate(Molecule *mp, const Vector *axis, Double angle, const Vector *center, IntGroup *group); int MoleculeCenterOfMass(Molecule *mp, Vector *center, IntGroup *group); @@ -507,7 +567,15 @@ int MoleculeInsertFrames(Molecule *mp, IntGroup *group, const Vector *inFrame, c int MoleculeRemoveFrames(Molecule *mp, IntGroup *group, Vector *outFrame, Vector *outFrameCell); int MoleculeSelectFrame(Molecule *mp, int frame, int copyback); int MoleculeFlushFrames(Molecule *mp); +int MoleculeReorderFrames(Molecule *mp, const Int *old_idx); +int MoleculeCreateProperty(Molecule *mp, const char *name); +int MoleculeLookUpProperty(Molecule *mp, const char *name); +int MoleculeDeletePropertyAtIndex(Molecule *mp, int idx); +int MoleculeSetProperty(Molecule *mp, int idx, IntGroup *ig, const Double *values); +int MoleculeGetProperty(Molecule *mp, int idx, IntGroup *ig, Double *outValues); + +void MoleculeUpdatePiAnchorPositions(Molecule *mol); void MoleculeCalculatePiAnchorPosition(Molecule *mol, int idx); int MoleculeSetPiAnchorList(Molecule *mol, Int idx, Int nentries, Int *entries, Double *weights, Int *nUndoActions, struct MolAction ***undoActions); @@ -518,8 +586,10 @@ int MoleculeLookUpCubeWithMONumber(Molecule *mp, Int mono); int MoleculeClearCubeAtIndex(Molecule *mp, Int index); int MoleculeOutputCube(Molecule *mp, Int index, const char *fname, const char *comment); -/*#define kMoleculePasteboardType "Molecule" -#define kParameterPasteboardType "Parameter" */ +MCube *MoleculeClearMCube(Molecule *mol, Int nx, Int ny, Int nz, const Vector *origin, Double dx, Double dy, Double dz); +int MoleculeUpdateMCube(Molecule *mol, int idn); +void MoleculeDeallocateMCube(MCube *mcube); + extern char *gMoleculePasteboardType; extern char *gParameterPasteboardType; extern char *gLoadSaveErrorMessage; @@ -542,8 +612,13 @@ STUB int MoleculeCallback_setDisplayName(Molecule *mol, const char *name); STUB void MoleculeCallback_lockMutex(void *mutex); STUB void MoleculeCallback_unlockMutex(void *mutex); +STUB void MoleculeCallback_disableModificationFromGUI(Molecule *mol); +STUB void MoleculeCallback_enableModificationFromGUI(Molecule *mol); + STUB void MoleculeCallback_cannotModifyMoleculeDuringMDError(Molecule *mol); +STUB int MoleculeCallback_callSubProcessAsync(Molecule *mol, const char **argv, int (*callback)(Molecule *, int), int (*timerCallback)(Molecule *, int), FILE *output, FILE *errout); + /* This is also defined in Molby_extern.h, but it may be called from functions in Molecule.c */ STUB int MyAppCallback_checkInterrupt(void);