예제 #1
0
void ReferenceGeneratorPanel::setParams() {
  verifyInputs();

  nh_local_.setParam("active", p_active_);
  nh_local_.setParam("trajectory_paused", p_paused_);
  nh_local_.setParam("trajectory_stopped", p_stopped_);

  nh_local_.setParam("trajectory_type", p_trajectory_type_);

  nh_local_.setParam("initial_x", p_x_0_);
  nh_local_.setParam("initial_y", p_y_0_);
  nh_local_.setParam("initial_theta", p_theta_0_);
  nh_local_.setParam("linear_velocity", p_v_);
  nh_local_.setParam("harmonic_period", p_T_);
  nh_local_.setParam("harmonic_radius_x", p_r_x_);
  nh_local_.setParam("harmonic_radius_y", p_r_y_);
  nh_local_.setParam("harmonic_multiplier_x", p_n_x_);
  nh_local_.setParam("harmonic_multiplier_y", p_n_y_);
}
예제 #2
0
void ConfigSetup::Init(const char *fileName)
{
	std::vector<std::string> line;

	//ADDED LINES TO GET PREFIX PATH AND 
	//CONVERT CHAR ARRY TO STRING TYPE TO GET PREFIX PATH
	//string prefix;
	std::string inputString(fileName);

	size_t found = inputString.rfind('/');
	if (found != std::string::npos)
		prefix = inputString.substr(0, inputString.find_last_of('/')) + '/';
	//END ADD LINE
	
	reader.Open(fileName);
	while(reader.readNextLine(line))
	{
		if(line[0] == "Restart") {
			in.restart.enable = checkBool(line[1]);
		} else if(line[0] == "FirstStep") {
			in.restart.step = stringtoi(line[1]);
		} else if(line[0] == "PRNG") {
			in.prng.kind = line[1];
		} else if(line[0] == "Random_Seed") {
			in.prng.seed = stringtoi(line[1]);
		} else if(line[0] == "ParaTypeCHARMM") {
			if(checkBool(line[1]))
			{
				in.ffKind.numOfKinds++;
				in.ffKind.isEXOTIC = false;
				in.ffKind.isMARTINI = false;
				in.ffKind.isCHARMM = true;
				std::cout << "REMINDER: CHARMM force field has been selected!" << std::endl;
			}
		} else if(line[0] == "ParaTypeEXOTIC") {
			if(checkBool(line[1]))
			{
				in.ffKind.numOfKinds++;
				in.ffKind.isCHARMM = false;
				in.ffKind.isMARTINI = false;
			        in.ffKind.isEXOTIC = true;
				std::cout << "REMINDER: EXOTIC force field has been selected!" << std::endl;
		}
		} else if(line[0] == "ParaTypeMARTINI") {
			if(checkBool(line[1]))
			{
				in.ffKind.numOfKinds ++;
				in.ffKind.isEXOTIC = false;
				in.ffKind.isMARTINI = true;
				in.ffKind.isCHARMM = true;
				std::cout << "REMINDER: MARTINI force field has been selected!" << std::endl;
			}
		} else if(line[0] == "Parameters") {
			in.files.param.name = prefix + line[1]; //ADDED PREFIX
		} else if(line[0] == "Coordinates") {
			uint boxnum = stringtoi(line[1]);
			if(boxnum >= BOX_TOTAL)
			{
				std::cout<< "Error: This simulation requires only " << BOX_TOTAL << " number of PDB file(s)!" << std::endl;
				exit(0);
			}
			in.files.pdb.name[boxnum] = prefix + line[2]; //ADDED PREFIX
		} else if(line[0] == "Structure") {
			uint boxnum = stringtoi(line[1]);
			if(boxnum >= BOX_TOTAL)
			{
				std::cout<< "Error: This simulation requires only " << BOX_TOTAL << " number of PSF file(s)!" << std::endl;
				exit(0);
			}
			in.files.psf.name[boxnum] = prefix + line[2]; //ADDED PREFIX
		}
#if ENSEMBLE == GEMC
		else if(line[0] == "GEMC")
		{
			if(line[1] == "NVT")
			{
				sys.gemc.kind = mv::GEMC_NVT;
				std::cout<< " NVT_GEMC simulation has been selected " << std::endl;
			}
			else if(line[1] == "NPT")
			{
				sys.gemc.kind = mv::GEMC_NPT;
				std::cout<< " NPT_GEMC simulation has been selected " << std::endl;
                        } 
		}
		else if(line[0] == "Pressure")
		{
			sys.gemc.pressure = stringtod(line[1]);
			std::cout<< " Pressure of system has been set to " << sys.gemc.pressure << " bar " << std::endl;
			sys.gemc.pressure *= unit::BAR_TO_K_MOLECULE_PER_A3;
		}
#endif
		else if(line[0] == "Temperature")
		{
			sys.T.inKelvin = stringtod(line[1]);
		}
		else if(line[0] == "Potential")
		{
			if(line[1] == "VDW")
				sys.ff.VDW_KIND = sys.ff.VDW_STD_KIND;
			else if(line[1] == "SHIFT")
				sys.ff.VDW_KIND = sys.ff.VDW_SHIFT_KIND;
			else if(line[1] == "SWITCH")
				sys.ff.VDW_KIND = sys.ff.VDW_SWITCH_KIND;
		}
		else if(line[0] == "LRC")
		{
			sys.ff.doTailCorr = checkBool(line[1]);
		}
		else if(line[0] == "Rswitch")
		{
			sys.ff.rswitch = stringtod(line[1]);
		}
		else if(line[0] == "Rcut")
		{
			sys.ff.cutoff = stringtod(line[1]);
		}
		else if(line[0] == "Exclude")
		{
			if(line[1] == sys.exclude.EXC_ONETWO)
				sys.exclude.EXCLUDE_KIND = sys.exclude.EXC_ONETWO_KIND;
			else if(line[1] == sys.exclude.EXC_ONETHREE)
				sys.exclude.EXCLUDE_KIND = sys.exclude.EXC_ONETHREE_KIND;
			else if(line[1] == sys.exclude.EXC_ONEFOUR)
				sys.exclude.EXCLUDE_KIND = sys.exclude.EXC_ONEFOUR_KIND;
		}
		else if(line[0] == "Ewald")
		{
			sys.elect.ewald = checkBool(line[1]);
			sys.elect.readEwald = true;
		}
		else if(line[0] == "ElectroStatic")
		{
			sys.elect.enable = checkBool(line[1]);
			sys.elect.readElect = true;
		}
		else if(line[0] == "Tolerance")
		{
			sys.elect.tolerance = stringtod(line[1]);
			sys.elect.alpha = sqrt(-1 * log(sys.elect.tolerance))/
			  sys.ff.cutoff;
			sys.elect.recip_rcut = 2 * (-log(sys.elect.tolerance))/
			  sys.ff.cutoff;
		}
		else if(line[0] == "1-4scaling")
		{
			sys.elect.oneFourScale = stringtod(line[1]);
		}
		else if(line[0] == "Dielectric")
		{
			sys.elect.dielectric = stringtod(line[1]);
		}
		else if(line[0] == "RunSteps")
		{
			sys.step.total = stringtoi(line[1]);
		}
		else if(line[0] == "EqSteps")
		{
			sys.step.equil = stringtoi(line[1]);
		}
		else if(line[0] == "AdjSteps")
		{
			sys.step.adjustment = stringtoi(line[1]);
		}
		else if(line[0] == "DisFreq")
		{
			sys.moves.displace = stringtod(line[1]);
		}
		else if(line[0] == "IntraSwapFreq")
		{
			sys.moves.intraSwap = stringtod(line[1]);
		}
		else if(line[0] == "RotFreq")
		{
			sys.moves.rotate = stringtod(line[1]);
		} 
#ifdef VARIABLE_VOLUME
		else if(line[0] == "VolFreq")
		{
			sys.moves.volume = stringtod(line[1]);
		}
#endif
#ifdef VARIABLE_PARTICLE_NUMBER
		else if(line[0] == "SwapFreq")
		{
#if ENSEMBLE == NVT
		        sys.moves.transfer = 0.000;
#else
			sys.moves.transfer = stringtod(line[1]);
#endif
		}
#endif
		else if(line[0] == "BoxDim") {
			uint box = stringtoi(line[1]);
			if(box < BOX_TOTAL)
			{
				XYZ temp;
				sys.volume.boxCoordRead++;
				sys.volume.hasVolume = (sys.volume.boxCoordRead == BOX_TOTAL);
				temp.x = stringtod(line[2]);
				temp.y = stringtod(line[3]);
				temp.z = stringtod(line[4]);

				sys.volume.axis.Set(box, temp);
			}
			else
			{
				std::cout<< "Error: This simulation requires only " << BOX_TOTAL << " number of box dimension(s)!" << std::endl;
				exit(0);
			}
		}
#ifdef VARIABLE_PARTICLE_NUMBER
		else if(line[0] == "CBMC_First")
		{
			sys.cbmcTrials.nonbonded.first = stringtoi(line[1]);
		}
		else if(line[0] == "CBMC_Nth")
		{
			sys.cbmcTrials.nonbonded.nth = stringtoi(line[1]);
		}
		else if(line[0] == "CBMC_Ang")
		{
			sys.cbmcTrials.bonded.ang = stringtoi(line[1]);
		} 
		else if(line[0] == "CBMC_Dih")
		{
			sys.cbmcTrials.bonded.dih = stringtoi(line[1]);
		}
#endif
#if ENSEMBLE == GCMC
		else if(line[0] == "ChemPot") {
			if(line.size() != 3)
			{
				std::cout << "Error: Chemical potential parameters have not been specified!" << std::endl;
				exit(0);
			}
			std::string resName = line[1];
			double val = stringtod(line[2]);
			sys.chemPot.cp[resName] = val;
		} 
#endif
		else if(line[0] == "OutputName") 
		{
			out.statistics.settings.uniqueStr.val = line[1];
		} 
		else if(line[0] == "CoordinatesFreq") 
		{
			out.state.settings.enable = checkBool(line[1]);
			out.state.settings.frequency = stringtoi(line[2]);
		} 
		else if(line[0] == "RestartFreq") 
		{
			out.restart.settings.enable = checkBool(line[1]);
			out.restart.settings.frequency = stringtoi(line[2]);
		} 
		else if(line[0] == "ConsoleFreq") 
		{
			out.console.enable = checkBool(line[1]);
			out.console.frequency = stringtoi(line[2]);
		} 
		else if(line[0] == "BlockAverageFreq") 
		{
			out.statistics.settings.block.enable = checkBool(line[1]);
			out.statistics.settings.block.frequency = stringtoi(line[2]);
		} 
		else if(line[0] == "FluctuationFreq") 
		{
			out.statistics.settings.fluct.enable = checkBool(line[1]);
			out.statistics.settings.fluct.frequency = stringtoi(line[2]);
		} 
#if ENSEMBLE == GCMC
		else if(line[0] == "HistogramFreq") 
		{
			out.statistics.settings.hist.enable = checkBool(line[1]);
			out.statistics.settings.hist.frequency = stringtoi(line[2]);
		}
		else if(line[0] == "DistName")
		{
			out.state.files.hist.histName = line[1];
		}
		else if(line[0] == "HistName")
		{
			out.state.files.hist.sampleName = line[1];
		} 
		else if(line[0] == "RunNumber") 
		{
			out.state.files.hist.number = line[1];
		} 
		else if(line[0] == "RunLetter") 
		{
			out.state.files.hist.letter = line[1];
		} 
		else if(line[0] == "SampleFreq") 
		{
			out.state.files.hist.stepsPerHistSample = stringtoi(line[1]);
		}
#endif
		else if(line[0] == "OutEnergy") {
			out.statistics.vars.energy.block = checkBool(line[1]);
			out.statistics.vars.energy.fluct = checkBool(line[2]);
			out.statistics.vars.energy.hist = checkBool(line[3]);
		} else if(line[0] == "OutPressure") {
			out.statistics.vars.pressure.block = checkBool(line[1]);
			out.statistics.vars.pressure.fluct = checkBool(line[2]);
			out.statistics.vars.pressure.hist = checkBool(line[3]);
		}
#ifdef VARIABLE_PARTICLE_NUMBER
		else if(line[0] == "OutMolNum") {
			out.statistics.vars.molNum.block = checkBool(line[1]);
			out.statistics.vars.molNum.fluct = checkBool(line[2]);
			out.statistics.vars.molNum.hist = checkBool(line[3]);
		} else if(line[0] == "OutAcceptAngles") {
			out.statistics.vars.acceptAngles.block = checkBool(line[1]);
			out.statistics.vars.acceptAngles.fluct = checkBool(line[2]);
			out.statistics.vars.acceptAngles.hist = checkBool(line[3]);
		}
#endif
#ifdef VARIABLE_DENSITY
		else if(line[0] == "OutDensity") {
			out.statistics.vars.density.block = checkBool(line[1]);
			out.statistics.vars.density.fluct = checkBool(line[2]);
			out.statistics.vars.density.hist = checkBool(line[3]);
		}
#endif
#ifdef VARIABLE_VOLUME
		else if(line[0] == "OutVolume") {
			out.statistics.vars.volume.block = checkBool(line[1]);
			out.statistics.vars.volume.fluct = checkBool(line[2]);
			out.statistics.vars.volume.hist = checkBool(line[3]);
		}
#endif
		else{
			cout << "Warning: Unknown input " << line[0] << "!" << endl;
		}
		// Clear and get ready for the next line
		line.clear();
	}

	//*********** Fill in the default values if not specified ***********//
	fillDefaults();

	//*********** Verify inputs ***********//
	verifyInputs();
}