From 671e8b49b9ba9a0da969edbf967349a4a12db3b7 Mon Sep 17 00:00:00 2001 From: Paul Romano Date: Tue, 10 Dec 2019 15:12:53 -0600 Subject: [PATCH] Allow Cell::set_temperature to work when not all temperatures were originally specified --- src/cell.cpp | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/cell.cpp b/src/cell.cpp index 94bae32ebc..9496dbba22 100644 --- a/src/cell.cpp +++ b/src/cell.cpp @@ -258,8 +258,13 @@ Cell::set_temperature(double T, int32_t instance) } if (instance >= 0) { + // If temperature vector is not big enough, resize it first + if (sqrtkT_.size() != n_instances_) sqrtkT_.resize(n_instances_, sqrtkT_[0]); + + // Set temperature for the corresponding instance sqrtkT_.at(instance) = std::sqrt(K_BOLTZMANN * T); } else { + // Set temperature for all instances for (auto& T_ : sqrtkT_) { T_ = std::sqrt(K_BOLTZMANN * T); }