22#define CASM_GrandCanonicalSettings
33
44#include " casm/monte_carlo/MonteSettings.hh"
5+ #include " casm/external/boost.hh"
56
67namespace CASM {
78
@@ -43,7 +44,7 @@ namespace CASM {
4344
4445 // / \brief Construct MonteSamplers as specified in the MonteSettings
4546 template <typename SamplerInsertIterator>
46- SamplerInsertIterator samplers (const PrimClex &primclex, const Configuration &config, SamplerInsertIterator result) const ;
47+ SamplerInsertIterator samplers (const PrimClex &primclex, SamplerInsertIterator result) const ;
4748
4849 // / \brief Return true if all correlations should be sampled
4950 bool all_correlations () const ;
@@ -57,7 +58,7 @@ namespace CASM {
5758 GrandCanonicalConditions _conditions (const jsonParser &json) const ;
5859
5960 template <typename jsonParserIteratorType>
60- std::tuple<bool , double > _get_precision (jsonParserIteratorType it, std::string input_name ) const ;
61+ std::tuple<bool , double > _get_precision (jsonParserIteratorType it) const ;
6162
6263 template <typename jsonParserIteratorType, typename SamplerInsertIterator>
6364 SamplerInsertIterator _make_comp_samplers (const PrimClex &primclex, jsonParserIteratorType it, SamplerInsertIterator result) const ;
@@ -78,7 +79,7 @@ namespace CASM {
7879 SamplerInsertIterator _make_non_zero_eci_correlations_samplers (const PrimClex &primclex, jsonParserIteratorType it, SamplerInsertIterator result) const ;
7980
8081 template <typename jsonParserIteratorType, typename SamplerInsertIterator>
81- SamplerInsertIterator _make_query_samplers (const PrimClex &primclex, const Configuration &config, jsonParserIteratorType it, SamplerInsertIterator result) const ;
82+ SamplerInsertIterator _make_query_samplers (const PrimClex &primclex, jsonParserIteratorType it, SamplerInsertIterator result) const ;
8283
8384 };
8485
@@ -91,7 +92,6 @@ namespace CASM {
9192 template <typename SamplerInsertIterator>
9293 SamplerInsertIterator GrandCanonicalSettings::samplers (
9394 const PrimClex &primclex,
94- const Configuration &config,
9595 SamplerInsertIterator result) const {
9696
9797 if (method () == Monte::METHOD ::LTE1 ) {// hack
@@ -149,7 +149,7 @@ namespace CASM {
149149 // check if property found is in list of possible scalar properties
150150 if (std::find (scalar_possible.cbegin (), scalar_possible.cend (), prop_name) != scalar_possible.cend ()) {
151151
152- std::tie (must_converge, prec) = _get_precision (it, prop_name );
152+ std::tie (must_converge, prec) = _get_precision (it);
153153
154154 // if 'must converge'
155155 if (must_converge) {
@@ -221,7 +221,7 @@ namespace CASM {
221221 }
222222
223223 // custom query
224- _make_query_samplers (primclex, config, it, result);
224+ _make_query_samplers (primclex, it, result);
225225
226226 }
227227
@@ -237,7 +237,7 @@ namespace CASM {
237237 }
238238
239239 template <typename jsonParserIteratorType>
240- std::tuple<bool , double > GrandCanonicalSettings::_get_precision (jsonParserIteratorType it, std::string input_name ) const {
240+ std::tuple<bool , double > GrandCanonicalSettings::_get_precision (jsonParserIteratorType it) const {
241241 if (it->contains (" precision" )) {
242242 return std::make_tuple (true , (*it)[" precision" ]. template get <double >());
243243 }
@@ -262,7 +262,7 @@ namespace CASM {
262262
263263 print_name = std::string (" comp(" ) + std::string (1 , (char )(i + ((int ) ' a' ))) + " )" ;
264264
265- std::tie (must_converge, prec) = _get_precision (it, " comp " );
265+ std::tie (must_converge, prec) = _get_precision (it);
266266
267267 // if 'must converge'
268268 if (must_converge) {
@@ -298,7 +298,7 @@ namespace CASM {
298298
299299 print_name = std::string (" comp_n(" ) + primclex.composition_axes ().components ()[i] + " )" ;
300300
301- std::tie (must_converge, prec) = _get_precision (it, " comp_n " );
301+ std::tie (must_converge, prec) = _get_precision (it);
302302
303303 // if 'must converge'
304304 if (must_converge) {
@@ -332,7 +332,7 @@ namespace CASM {
332332 // SiteFracMonteSampler uses 'comp_n' to calculate 'site_frac'
333333 print_name = std::string (" site_frac(" ) + primclex.composition_axes ().components ()[i] + " )" ;
334334
335- std::tie (must_converge, prec) = _get_precision (it, " site_frac " );
335+ std::tie (must_converge, prec) = _get_precision (it);
336336
337337 // if 'must converge'
338338 if (must_converge) {
@@ -382,7 +382,7 @@ namespace CASM {
382382
383383 print_name = std::string (" atom_frac(" ) + primclex.composition_axes ().components ()[i] + " )" ;
384384
385- std::tie (must_converge, prec) = _get_precision (it, " atom_frac " );
385+ std::tie (must_converge, prec) = _get_precision (it);
386386
387387 // if 'must converge'
388388 if (must_converge) {
@@ -418,7 +418,7 @@ namespace CASM {
418418 prop_name = " corr" ;
419419 print_name = std::string (" corr(" ) + std::to_string (i) + " )" ;
420420
421- std::tie (must_converge, prec) = _get_precision (it, " all_correlations " );
421+ std::tie (must_converge, prec) = _get_precision (it);
422422
423423 // if 'must converge'
424424 if (must_converge) {
@@ -460,7 +460,7 @@ namespace CASM {
460460
461461 print_name = std::string (" corr(" ) + std::to_string (i) + " )" ;
462462
463- std::tie (must_converge, prec) = _get_precision (it, " non_zero_eci_correlations " );
463+ std::tie (must_converge, prec) = _get_precision (it);
464464
465465 // if 'must converge'
466466 if (must_converge) {
@@ -480,7 +480,6 @@ namespace CASM {
480480 template <typename jsonParserIteratorType, typename SamplerInsertIterator>
481481 SamplerInsertIterator GrandCanonicalSettings::_make_query_samplers (
482482 const PrimClex &primclex,
483- const Configuration &config,
484483 jsonParserIteratorType it,
485484 SamplerInsertIterator result) const {
486485
@@ -496,6 +495,10 @@ namespace CASM {
496495 std::shared_ptr<FormatterType> formatter = std::make_shared<FormatterType>(
497496 dict.parse (prop_name));
498497
498+ // make example config to test:
499+ Supercell tscel (const_cast <PrimClex *>(&primclex), simulation_cell_matrix ());
500+ Configuration config (tscel);
501+ config.init_occupation ();
499502 Eigen::VectorXd test = formatter->get ().evaluate_as_matrix (config).row (0 );
500503 auto col = formatter->get ().col_header (config);
501504
@@ -511,17 +514,20 @@ namespace CASM {
511514
512515 for (int i = 0 ; i < col.size (); ++i) {
513516
514- std::tie (must_converge, prec) = _get_precision (it, prop_name);
517+ std::string print_name = col[i];
518+ boost::algorithm::trim (print_name);
519+
520+ std::tie (must_converge, prec) = _get_precision (it);
515521
516522 // if 'must converge'
517523 if (must_converge) {
518- ptr = new QueryMonteSampler (formatter, i, col[i] , confidence (), data_maxlength);
524+ ptr = new QueryMonteSampler (formatter, i, print_name, prec , confidence (), data_maxlength);
519525 }
520526 else {
521- ptr = new QueryMonteSampler (formatter, i, col[i], prec , confidence (), data_maxlength);
527+ ptr = new QueryMonteSampler (formatter, i, print_name , confidence (), data_maxlength);
522528 }
523529
524- *result++ = std::make_pair (col[i] , notstd::cloneable_ptr<MonteSampler>(ptr));
530+ *result++ = std::make_pair (print_name , notstd::cloneable_ptr<MonteSampler>(ptr));
525531
526532 }
527533
0 commit comments