bool Engine::setFunction(QString n, ELAM::Function p) { if(p==0)return false; if(!d->cclass.isName(n))return false; if(hasConstant(n))return false; if(hasVariable(n))return false; d->funcs.insert(n,p); return true; }
void Programme::setVariable(Variable& var) { if(hasArgument(var.getNom())) { arguments[indexOfVar(arguments, var.getNom())] = var; } else if(hasVariable(var.getNom())) { variables[indexOfVar(variables, var.getNom())] = var; } else { throw "La variable \""+var.getNom()+"\" n'existe pas dans le programme \""+nom+"\"."; } }
Variable Programme::getVariable(std::string var) const { if(hasArgument(var)) { return arguments[indexOfVar(arguments, var)]; } else if(hasVariable(var)) { return variables[indexOfVar(variables, var)]; } else { throw "Le programme \""+nom+"\" ne dispose d'aucune variable \""+var+"\"."; } }
bool planning_models::KinematicModel::RevoluteJointModel::isValueWithinVariableBounds(const std::string& variable, const double& value, bool& within_bounds) const { if(!continuous_) { return JointModel::isValueWithinVariableBounds(variable, value, within_bounds); } if(!hasVariable(variable)) { return false; } within_bounds = true; return true; }
void RMemoryStorage::setVariable(const QString& key, const QVariant& value, bool overwrite) { if (!overwrite && hasVariable(key)) { return; } if (variables.contains(key) && variables[key]==value) { // no change: return; } // remove existing variable with same name (case insensitive comparison): if (variableCaseMap.contains(key.toLower()) && variableCaseMap[key.toLower()]!=key) { variables.remove(variableCaseMap[key.toLower()]); } variableCaseMap[key.toLower()] = key; variables[key] = value; setModified(true); }
vTrimGain::vTrimGain(sCurveAnalysis &anAnalysis) : sCurveAnalysis(anAnalysis) { for (std::map<QString, std::map<std::string, TH2F*> >::iterator hIt = histogramSum2D.begin(); hIt != histogramSum2D.end(); ++ hIt) { gainPoint_ [hIt->first] = new TGraph(); gainPointX_[hIt->first] = new TGraph(); gainPointY_[hIt->first] = new TGraph(); } if (!hasVariable("25. Vcal vs 11. Vtrim")) { std::cout << "No plot available for finding the VTrim gain: VTrim vs VCal needed!" << std::endl; isGainAnalysisPossible_ = false; return; } isGainAnalysisPossible_ = true; minThreashold_ = 0; std::cout << "Be sure that TrimBit is 15 now!\n"; }
void gkDebugPropertyPage::addVariable(gkVariable* prop) { if (hasVariable(prop)) return; m_props.push_back(prop); gkScalar strWidth = PROP_SIZE * prop->getName().size(); gkScalar nh = m_cont->getHeight() + PROP_SIZE; m_cont->setHeight(nh); if (m_key->getWidth() < strWidth || m_props.size() == 1) { gkScalar diffw = strWidth - m_key->getWidth(); m_cont->setWidth(m_cont->getWidth() + diffw); gkScalar half = m_cont->getWidth() / 2.f; m_key->setWidth(half); m_val->setWidth(half); m_val->setPosition(m_props.size() == 1 ? strWidth : half, 0); } }
bool Potential1210::extractSection (ForceFieldParameters& parameters, const String& section_name) { // clear the fields first clear(); // check whether the parameters are valid if (!parameters.isValid()) { return false; } // extract the basis information ParameterSection::extractSection(parameters, section_name); // check whether all variables we need are defined, terminate otherwise if (!hasVariable("A") || !hasVariable("B")) { return false; } // build a two dimensional array of the atom types // loop variable Size i; AtomTypes& atom_types = parameters.getAtomTypes(); number_of_atom_types_ = atom_types.getNumberOfTypes(); // allocate two onedimensional fields for the two parameters A_.resize(number_of_atom_types_ * number_of_atom_types_); B_.resize(number_of_atom_types_ * number_of_atom_types_); is_defined_.resize(number_of_atom_types_ * number_of_atom_types_); for (i = 0; i < number_of_atom_types_ * number_of_atom_types_; i++) { is_defined_[i] = false; } StringHashMap<Index>::Iterator it; // determine the factor to convert the parameters to the standard units used // as a default, energies are assumend to be in kJ/mol and distances in Angstrom double factor_A = 1.0; double factor_B = 1.0; if (options.has("unit_A")) { if (options["unit_A"] == "kcal/mol*A^12") { factor_A = Constants::JOULE_PER_CAL; } else { Log.warn() << "unknown unit for parameter A: " << options["unit_A"] << endl; } } if (options.has("unit_B")) { if (options["unit_B"] == "kcal/mol*A^10") { factor_B = Constants::JOULE_PER_CAL; } else { Log.warn() << "unknown unit for parameter B: " << options["unit_B"] << endl; } } Atom::Type type_I; Atom::Type type_J; String type_name_I; String type_name_J; String key; Index index = 0; for (it = section_entries_.begin(); !(it == section_entries_.end()); ++it) { key = (*it).first; if ((key.size() > 0) && (key.find_first_of(" ", 0) > 0)) { type_name_I = key.before(" ", 0); type_name_J = key.after(" ", 0); if ((atom_types.hasType(type_name_I)) && (atom_types.hasType(type_name_J))) { type_I = atom_types.getType(type_name_I); type_J = atom_types.getType(type_name_J); index = (Index)(type_I * number_of_atom_types_ + type_J); is_defined_[index] = true; A_ [index] = getValue(key, "A").toFloat() * factor_A; B_ [index] = getValue(key, "B").toFloat() * factor_B; index = (Index)(type_I + number_of_atom_types_ * type_J); is_defined_[index] = true; A_ [index] = getValue(key, "A").toFloat() * factor_A; B_ [index] = getValue(key, "B").toFloat() * factor_B; } } } return true; }
bool QgsExpressionContextScope::isReadOnly( const QString &name ) const { return hasVariable( name ) ? mVariables.value( name ).readOnly : false; }
QVariant QgsExpressionContextScope::variable( const QString &name ) const { return hasVariable( name ) ? mVariables.value( name ).value : QVariant(); }
bool Engine::hasValue(QString n) const { return hasVariable(n) || hasConstant(n); }
QVariant Engine::getValue(QString n) const { if(hasConstant(n))return getConstant(n); if(hasVariable(n))return getVariable(n); return QVariant(); }
QString QgsExpressionContextScope::description( const QString &name ) const { return hasVariable( name ) ? mVariables.value( name ).description : QString(); }
bool QgsExpressionContextScope::isStatic( const QString &name ) const { return hasVariable( name ) ? mVariables.value( name ).isStatic : false; }
bool CosineTorsion::extractSection(ForceFieldParameters& parameters, const String& section_name) { // check whether the parameters are valid if (!parameters.isValid()) { return false; } // extract the section information if (!ParameterSection::extractSection(parameters, section_name)) { Log.error() << "CosineTorison::extractSection: Could not find section " << section_name << " in parameter file!" << std::endl; return false; } // check whether all variables we need are defined, terminate otherwise if (!hasVariable("div") || !hasVariable("V") || !hasVariable("phi0") || !hasVariable("f")) { Log.error() << "CosineTorsion::extractSection: CosineTorsion section (" << section_name << ") needs columns div, V, phi0, and f!" << std::endl; return false; } // build a two dimensional array of the atom types // loop variable Size i; const AtomTypes& atom_types = parameters.getAtomTypes(); number_of_atom_types_ = atom_types.getNumberOfTypes(); // clear all old torsions // - torsions_ is a vector containing Values objects // - torsion_hash_map_ hashes the product of the atom types (I + number_of_atom_types_ * J +...) // to a the index in torsions_ torsions_.clear(); torsion_hash_map_.clear(); // determine the units of the phase and potential wall // (if given in options) float factor_phase = 1.0; if (options.has("unit_phase")) { if (options["unit_phase"] == "rad") { factor_phase = 180.0 / Constants::PI; } } float factor_V = 1.0; if (options.has("unit_V")) { if (options["unit_V"] == "kcal/mol") { factor_V = Constants::JOULE_PER_CAL; } } Atom::Type type_I; Atom::Type type_J; Atom::Type type_K; Atom::Type type_L; String key; String fields[5]; StringHashMap<Index>::Iterator it; for (it = section_entries_.begin(); it != section_entries_.end(); ++it) { key = it->first; if (key.split(fields, 5) == 5) { // the first of line for each torsion has to contain N as last part of the key. // this line only contains the number of torsion terms in "div" if (fields[4] == "N") { // determine all atom types type_I = atom_types.getType(fields[0]); type_J = atom_types.getType(fields[1]); type_K = atom_types.getType(fields[2]); type_L = atom_types.getType(fields[3]); // retrieve the number of torsion terms Size n = getValue(key, "div").toUnsignedInt(); if ((n < 1) || (n > 4)) { Log.error() << "CosineTorsion::extractSection: wrong number of torsion terms for " << key << ": " << n << std::endl; } else { // create a new torsion and store // it in the vector of torsions Size array_idx = (Size)torsions_.size(); torsions_.push_back(Values(n)); // try to find the torsion terms for (i = 0; i < n; i++) { // calculate the correct key: "I J K L <number>" String term_key(key, 0, (Size)key.size() - 1); term_key += (String)(i + 1); // lookup the corresponding entry torsions_[array_idx].values[i].n = getValue(term_key, "div").toFloat(); torsions_[array_idx].values[i].phase = getValue(term_key, "phi0").toFloat() * factor_phase; torsions_[array_idx].values[i].f = getValue(term_key, "f").toFloat(); torsions_[array_idx].values[i].V = getValue(term_key, "V").toFloat() * factor_V; } // insert the array index and the atom type key into the // hash map // calculate a unique number for each possible combination of // atom types and use it to hash the torsion parameters Size index = type_I + type_J * number_of_atom_types_ + type_K * number_of_atom_types_ * number_of_atom_types_ + type_L * number_of_atom_types_ * number_of_atom_types_ * number_of_atom_types_; torsion_hash_map_.insert(pair<Size, Size>(index, array_idx)); } } } else { Log.error() << "CosineTorsion::extractSection: could not interpret key " << key << std::endl; } } return true; }