Example #1
0
/* ********************************************************************************************* */
void getEnergyAndVirial(ifstream &ifil,solreal &theener,solreal &thevir)
{
   string line;
   getline(ifil,line);
   int pos;
   pos=line.find_first_of('=');
   line.erase(0,pos+1);
   while (line[0]==' ') {line.erase(0,1);}
   pos=line.find_first_of(' ');
   theener=(solreal)atof((line.substr(0,pos)).c_str());
   pos=line.find_first_of('=');
   line.erase(0,pos+1);
   while (line[0]==' ') {line.erase(0,1);}
   thevir=(solreal)atof(line.c_str());
}
Example #2
0
void CONFIGVARIABLE::Set(string newval)
{
	newval = strTrim(newval);
	
	val_i = atoi(newval.c_str());
	val_f = atof(newval.c_str());
	val_s = newval;
	
	val_b = false;
	if (val_i == 0)
		val_b = false;
	if (val_i == 1)
		val_b = true;
	if (strLCase(newval) == "true")
		val_b = true;
	if (strLCase(newval) == "false")
		val_b = false;
	if (strLCase(newval) == "on")
		val_b = true;
	if (strLCase(newval) == "off")
		val_b = false;
	
	//now process as vector information
	int pos = 0;
	int arraypos = 0;
	string::size_type nextpos = newval.find(",", pos);
	string frag;
	
	while (nextpos < /*(int)*/ newval.length() && arraypos < 3)
	{
		frag = newval.substr(pos, nextpos - pos);
		val_v[arraypos] = atof(frag.c_str());
		
		pos = nextpos+1;
		arraypos++;
		nextpos = newval.find(",", pos);
	}
	
	//don't forget the very last one
	if (arraypos < 3)
	{
		frag = newval.substr(pos, newval.length() - pos);
		val_v[arraypos] = atof(frag.c_str());
	}
}
Example #3
0
VoxelBuffer * VoxelBuffer::factory(const string& filename)
{
	ifstream fin(filename);
	string inputBuffer;
	VoxelBuffer * tempBuffer;

	fin >> inputBuffer;		// "DELT"
	fin >> inputBuffer;		// Delta value
	float delta = (float)atof(inputBuffer.c_str());

	fin >> inputBuffer;		// "XYZC"
	fin >> inputBuffer;
	ivec3 dimensions;
	dimensions.x = atoi(inputBuffer.c_str());
	fin >> inputBuffer;
	dimensions.y = atoi(inputBuffer.c_str());
	fin >> inputBuffer;
	dimensions.z = atoi(inputBuffer.c_str());

	tempBuffer = new VoxelBuffer(delta, dimensions);
	float tempDensity/*, tempLight*/;		// Omit reading in lights temporarily
	voxel tempVoxel;
	int voxelBufferSize = dimensions.x * dimensions.y * dimensions.z;
	tempBuffer->voxels = new voxel[voxelBufferSize];
	int i = 0;

	// Read in voxel densities (and lights...later)
	while (!fin.eof()) {
		fin >> inputBuffer;
		tempDensity = (float)atof(inputBuffer.c_str());
		tempVoxel.density = tempDensity;
		tempVoxel.light = -1.0;
		tempBuffer->voxels[i++] = tempVoxel;	// Add voxel to the 1D array
	}

	return tempBuffer;
}
Example #4
0
double last_in_line(const string& str)
{
    typedef string::const_iterator iter;
    vector<string> ret;
    
    iter i = str.begin();
    while (i != str.end()) {
        i = find_if(i, str.end(), not_space);
        iter j = find_if(i, str.end(), space);
        
        if (i != str.end())
            ret.push_back(string(i, j));
        i = j;
    }
    return atof(ret[ret.size() - 1].c_str());
}
Example #5
0
/* ********************************************************************************************* */
void processMolecularOrbitalPropsAndCoefs(ifstream &ifil,const int norb,const int npr
                                 ,solreal* &ocn,solreal* &moe,solreal* &moc)
{
   alloc1DRealArray("moc",(norb*npr),moc);
   alloc1DRealArray("ocn",norb,ocn);
   alloc1DRealArray("moe",norb,moe);
   int pos;
   /* Getting the molecular orbital occupation number, energies, and coefficients */
   string line;
   int count=0;
   int nolines;
   nolines=floor(npr/5);
   //cout << "npr: " << npr << " nolines: " << npr/5 << endl;
   if ((npr%5)>0) {nolines++;}
   for (int k=0; k<norb; k++) {
      pos=ifil.tellg();
      ifil.seekg(pos+35);
      ifil >> ocn[k];
      ifil.seekg(pos+63);
      ifil >> moe[k];
      count=0;
      for (int i=0; i<nolines; i++) {
         pos=ifil.tellg();
         getline(ifil,line);
         if (line.length()==0) {getline(ifil,line); pos++;}
         for (int j=0; j<5; j++) {
            if (count<npr) {
               if ((line[12]=='D')||(line[12]=='d')) {
                  line[12]='e';
               }
               moc[(k*npr)+count]=(solreal)atof((line.substr(0,16)).c_str());
               count++;
               line.erase(0,16);
            }
         }
      }
   }
}
Example #6
0
double String2Dbl (string& iStlString)
{
    return atof (iStlString.c_str());
}
Example #7
0
/* ********************************************************************************************* */
void processPrimitivesWFN(ifstream &ifil,const int npr,int* &pricen,int* &primty,solreal* &prexp)
{
   alloc1DIntArray("pricen",npr,pricen);
   alloc1DIntArray("primty",npr,primty);
   alloc1DRealArray("prexp",npr,prexp);
   int count=0;
   int pos;
   /* Getting the primitive centers */
   pos=ifil.tellg();
   ifil.seekg(pos+20);
   for (int i=0; i<npr; i++) {
      ifil >> pricen[i];
      pricen[i]--;
      count++;
      if (count==20) {
         pos=ifil.tellg();
         ifil.seekg(pos+20);
         count=0;
      }
      //cout << pricen[i] << " ";
   }
   if ((npr%20)==0) {
      pos=ifil.tellg();
      ifil.seekg(pos-20);
   }
   /* Getting the primitive types */
   pos=ifil.tellg();
   ifil.seekg(pos+20);
   count=0;
   for (int i=0; i<npr; i++) {
      ifil >> primty[i];
      primty[i]--;
      count++;
      if (count==20) {
         pos=ifil.tellg();
         ifil.seekg(pos+20);
         count=0;
      }
      //cout << primty[i] << " ";
   }
   if ((npr%20)==0) {
      pos=ifil.tellg();
      ifil.seekg(pos-20);
   }
   /* Getting the primitive exponents */
   string line;
   int nolines;
   nolines=floor(npr/5);
   if ((npr%5)>0) {nolines++;}
   count=0;
   for (int i=0; i<nolines; i++) {
      pos=ifil.tellg();
      getline(ifil,line); 
      if (line.length()==0) {getline(ifil,line); pos++;}
      line.erase(0,10);
      for (int j=0; j<5; j++) {
         if (count<npr) {
            if ((line[10]=='D')||(line[10]=='d')) {
               line[10]='e';
            }
            prexp[count]=(solreal)atof((line.substr(0,14)).c_str());
            count++;
            line.erase(0,14);
         }
      }
   }
}
Example #8
0
double Arguments::asDouble(int index) const {
    return atof(argList[index].c_str());
}