static void SortTemp(int low, int high) { TempStruct tmpMid, tmpSwap; int lowMid, highMid, nLen; nLen = high - low + 1; if (nLen > TEMP_BUFFER_SIZE) { lowMid = low; highMid = high; tmpMid = GetTemp((low + high) / 2); while (lowMid <= highMid) { while (lowMid < high && GetTemp(lowMid) < tmpMid) { lowMid ++; } while (low < highMid && tmpMid < GetTemp(highMid)) { highMid --; } if (lowMid <= highMid) { tmpSwap = GetTemp(lowMid); SetTemp(lowMid, GetTemp(highMid)); SetTemp(highMid, tmpSwap); lowMid ++; highMid --; } } if (low < highMid) { SortTemp(low, highMid); } if (lowMid < high) { SortTemp(lowMid, high); } } else { ReadTemp(low, MakeBook2.TempBuffer, nLen); if (nLen > 1) { SortMem(0, nLen - 1); } WriteTemp(low, MakeBook2.TempBuffer, nLen); } }
void DSKY::ProcessChannel11Bit(int bit, bool val) { // // Channel 011 has bits to control the lights on the DSKY. // switch (bit) { // 2 - Comp Acty case 2: SetCompActy(val); break; // 3 - Uplink case 3: SetUplink(val); break; // 4 - Temp caution case 4: SetTemp(val); break; // 5 - Kbd Rel case 5: SetKbRel(val); break; // 6 - flash verb and noun case 6: if (val) { SetVerbDisplayFlashing(); SetNounDisplayFlashing(); } else { ClearVerbDisplayFlashing(); ClearNounDisplayFlashing(); } break; // 7 - Opr Err case 7: SetOprErr(val); break; } }
void DSKY::ProcessChannel11(ChannelValue val) { ChannelValue val11; val11 = val; SetCompActy(val11[LightComputerActivity]); SetUplink(val11[LightUplink]); SetTemp(val11[LightTempCaution]); SetKbRel(val11[LightKbRel]); SetOprErr(val11[LightOprErr]); if (val11[FlashVerbNoun]) { SetVerbDisplayFlashing(); SetNounDisplayFlashing(); } else { ClearVerbDisplayFlashing(); ClearNounDisplayFlashing(); } }
inline void AddTemp(const TempStruct &tmp) { SetTemp(MakeBook2.nTempLen, tmp); MakeBook2.nTempLen ++; }
int Forces::ReadConfDinamica(char *InFile){ SysType = 0; SysShape = 0; CalcMode = 0; FILE *FileToRead = fopen(InFile,"r"); if(FileToRead == NULL){ printf("The conf file %s is missing\n",InFile); return 1; } double buff[12]; char SysInit[20]; char *Line = (char *)malloc(256*sizeof(char)); //fgets(Line,256,FileToRead); int NNano = 0; for(int k=0;!(fgets(Line,256,FileToRead)==NULL);k++){ if(strstr(Line, "Rigid") == Line) NNano++; } SetNNano(NNano); NNano = 0; rewind(FileToRead); for(int k=0;!(fgets(Line,256,FileToRead)==NULL);k++){ //printf("%s",Line); if(1 == sscanf(Line,"NEdge %lf",buff) ) NEdge = (int)*buff; else if(1 == sscanf(Line,"SysShape %s",SysInit) ){ if(!strcmp(SysInit,"leaves") ) VAR_ADD_TYPE(SysShape,SYS_LEAVES); else if(!strcmp(SysInit,"pore") ) VAR_ADD_TYPE(SysShape,SYS_PORE); else if(!strcmp(SysInit,"1d") ) VAR_ADD_TYPE(SysShape,SYS_1D); else if(!strcmp(SysInit,"2d") ) VAR_ADD_TYPE(SysShape,SYS_2D); else if(!strcmp(SysInit,"3d") ) VAR_ADD_TYPE(SysShape,SYS_3D); else if(!strcmp(SysInit,"rod") ) VAR_ADD_TYPE(SysShape,SYS_ROD); else if(!strcmp(SysInit,"trial") ) VAR_ADD_TYPE(SysShape,SYS_TRIAL); else if(!strcmp(SysInit,"rigid") ) VAR_ADD_TYPE(SysShape,SYS_RIGID); else if(!strcmp(SysInit,"stalk") ) VAR_ADD_TYPE(SysShape,SYS_STALK); else if(!strcmp(SysInit,"md") ) VAR_ADD_TYPE(SysShape,SYS_MD); else if(!strcmp(SysInit,"mc") ) VAR_ADD_TYPE(SysShape,SYS_MC); else if(!strcmp(SysInit,"electro") ){ VAR_ADD_TYPE(SysShape,SYS_ELECTRO); //VAR_ADD_TYPE(SysShape,SYS_MC); } else{ printf("system type not recognized\n"); exit(1); } } else if(1 == sscanf(Line,"CalcMode %s",SysInit) ){ if(!strcmp(SysInit,"NVT") ) VAR_ADD_TYPE(CalcMode,CALC_NVT); else if(!strcmp(SysInit,"NcVT") ) VAR_ADD_TYPE(CalcMode,CALC_NcVT); else if(!strcmp(SysInit,"mcVT") ) VAR_ADD_TYPE(CalcMode,CALC_mcVT); else if(!strcmp(SysInit,"mVT") ) VAR_ADD_TYPE(CalcMode,CALC_mVT); else{ printf("calculation type not recognized\n"); exit(1); } } else if(1 == sscanf(Line,"Thermostat %s",SysInit) ){ if(!strcmp(SysInit,"Langevin") ) ThermMode = THERM_LANG; else if(!strcmp(SysInit,"Andersen") ) ThermMode = THERM_AND; else if(!strcmp(SysInit,"Berendsen") ) ThermMode = THERM_BERE; else if(!strcmp(SysInit,"no") ) ThermMode = THERM_NO; else{ printf("thermostat not recognized\n"); exit(1); } } else if(1 == sscanf(Line,"PotentialMode %s",SysInit) ){ if(!strcmp(SysInit,"Pair") ) VAR_ADD_TYPE(CalcMode,CALC_PAIR); else if(!strcmp(SysInit,"DensFunc") ) VAR_ADD_TYPE(CalcMode,CALC_DENS); else if(!strcmp(SysInit,"DensFuncCh") ) VAR_ADD_TYPE(CalcMode,CALC_DENS); } else if(1 == sscanf(Line,"Potential %s",SysInit) ){ if(!strcmp(SysInit,"LJ") ) VAR_ADD_TYPE(CalcMode,CALC_LJ); else if(!strcmp(SysInit,"LJ39") ) VAR_ADD_TYPE(CalcMode,CALC_LJ39); else if(!strcmp(SysInit,"Harmonic") ) VAR_ADD_TYPE(CalcMode,CALC_HARM); else if(!strcmp(SysInit,"Step") ) VAR_ADD_TYPE(CalcMode,CALC_STEP); else if(!strcmp(SysInit,"Electro") ) VAR_ADD_TYPE(CalcMode,CALC_ELECTRO); else{ printf("interaction potential not recognized\n"); exit(1); } } else if(1 == sscanf(Line,"IfInterp %lf",buff) ) IfInterp = (int)*buff; else if(1 == sscanf(Line,"Lap %lf",buff) ) Kf.Lap = *buff; else if(1 == sscanf(Line,"SLap %lf",buff) ) Kf.SLap = *buff; else if(1 == sscanf(Line,"Ext %lf",buff) ) Kf.Ext = *buff; else if(1 == sscanf(Line,"LJ %lf",buff) ) Kf.LJ = *buff; else if(1 == sscanf(Line,"LJMin %lf",buff) ) Kf.LJMin = *buff; else if(1 == sscanf(Line,"kSpr %lf",buff) ) SetkSpr(*buff); else if(1 == sscanf(Line,"SprRest %lf",buff) ) SetSprRest(*buff); else if(1 == sscanf(Line,"kBen %lf",buff) ) SetkBen(*buff); else if(1 == sscanf(Line,"SimLimit %lf",buff) ) SimLimit = (int)*buff; else if(1 == sscanf(Line,"CutOff %lf",buff) ) Kf.CutOff2 = SQR(*buff); else if(1 == sscanf(Line,"Cont %lf",buff) ) Kf.Cont = *buff; else if(1 == sscanf(Line,"NWrite %lf",buff) ) NWrite = (int)*buff; else if(1 == sscanf(Line,"NBin %lf",buff) ) NBin = (int)*buff; else if(1 == sscanf(Line,"NGrid %lf",buff) ) NGrid = (int)*buff; else if(1 == sscanf(Line,"NUpdate %lf",buff) ) NUpdate = (int)*buff; else if(strstr(Line, "Rigid") == Line){ NanoString(Line,NNano++); } #ifdef __glut_h__ else if(1 == sscanf(Line,"IfMovie %lf",buff) ) IfMovie = (int)*buff; else if(1 == sscanf(Line,"IfLine %lf",buff) ) IfLine = (int)*buff; else if(1 == sscanf(Line,"NSpline %lf",buff) ) NSpline = *buff; else if(1 == sscanf(Line,"IfSphere %lf",buff) ) IfSphere = (int)*buff; #endif else if(3 == sscanf(Line,"Edge %lf %lf %lf",buff,buff+1,buff+2) ){ SetEdge(buff[0],0); SetEdge(buff[1],1); SetEdge(buff[2],2); } else if(3 == sscanf(Line,"El %lf %lf %lf",buff,buff+1,buff+2) ){ Kf.El[0] = *buff; Kf.El[1] = *(buff+1); Kf.El[2] = *(buff+2); } else if(3 == sscanf(Line,"Elong %lf %lf %lf",buff,buff+1,buff+2) ){ Kf.Elong[0] = *buff; Kf.Elong[1] = *(buff+1); Kf.Elong[2] = *(buff+2); } else if(6 == sscanf(Line,"Boundary %lf %lf %lf %lf %lf %lf",buff,buff+1,buff+2,buff+3,buff+4,buff+5)){ BoundCond[0] = (int)buff[0]; BoundCond[1] = (int)buff[1]; BoundCond[2] = (int)buff[2]; BoundCond[3] = (int)buff[3]; BoundCond[4] = (int)buff[4]; BoundCond[5] = (int)buff[5]; } else if(3 == sscanf(Line,"Periodic %lf %lf %lf",buff,buff+1,buff+2)){ PeriodicImage[0] = (int)*buff; PeriodicImage[1] = (int)*(buff+1); PeriodicImage[2] = (int)*(buff+2); } else if(1 == sscanf(Line,"Deltat %lf",buff) ) Deltat = *buff; else if(1 == sscanf(Line,"Temp %lf",buff) ) SetTemp(buff[0]); else if(1 == sscanf(Line,"NChemPotId %lf",buff) ) NChemPotId = *buff; else if(1 == sscanf(Line,"NTrialBias %lf",buff) ){ NTrialBias =(int) *buff; } else if(1 == sscanf(Line,"ChemPotEx %lf",buff) ) ChemPotEx = *buff; else if(1 == sscanf(Line,"IfConfBias %lf",buff) ){ if((int)*buff == 1) VAR_ADD_TYPE(CalcMode,CALC_CONF_BIAS); } else if(1 == sscanf(Line,"IfBilBias %lf",buff) ){ if((int)*buff == 1){ VAR_ADD_TYPE(CalcMode,CALC_BIL_BIAS); StudySys(); } } else if(1 == sscanf(Line,"IfSphBias %lf",buff) ){ if((int)*buff == 1) VAR_ADD_TYPE(CalcMode,CALC_SPH_BIAS); } else if(1 == sscanf(Line,"Viscosity %lf",buff) ) Viscosity = *buff; else if(1 == sscanf(Line,"TNSlab %lf",buff) ) Tens.NSlab = (int)*buff; else if(1 == sscanf(Line,"TNComp %lf",buff) ) Tens.NComp = (int)*buff; else if(1 == sscanf(Line,"TCalcMode %s",SysInit) ){ if(!strcmp(SysInit,"2d") ){ VAR_ADD_TYPE(Tens.CalcMode,CALC_2d); Tens.NDim = 2; } else if(!strcmp(SysInit,"3d") ){ VAR_ADD_TYPE(Tens.CalcMode,CALC_3d); Tens.NDim = 3; } else{ printf("Pressure summation not recognized\n"); exit(1); } } } //for(int n=0;n<pNNano();n++) for(int d=0;d<3;d++) Nano[n].Pos[d] *= pEdge(d); ChemPotId = log(NChemPotId/pVol()); printf("Sys] NEdge %d SysShape %d %s Interp %d \n",NEdge,SysShape,SysInit,IfInterp); printf("Forces] Lap %lf SLap %lf Ext %lf LJ %lf Cont %lf El %lf %lf %lf Elong %lf %lf %lf\n",Kf.Lap,Kf.SLap,Kf.Ext,Kf.LJ,Kf.Cont,Kf.El[0],Kf.El[1],Kf.El[2],Kf.Elong[0],Kf.Elong[1],Kf.Elong[2]); printf("External] Center %lf %lf %lf Rad %lf Hei %lf\n",Nano->Pos[0],Nano->Pos[1],Nano->Pos[2],Nano->Rad,Nano->Height); fclose(FileToRead); return 0; }