Skip to content

Commit 24ed0b4

Browse files
Fixed incorrect error raising in ExcitonConfiguration
1 parent 06ef738 commit 24ed0b4

File tree

1 file changed

+10
-7
lines changed

1 file changed

+10
-7
lines changed

src/ExcitonConfiguration.cpp

+10-7
Original file line numberDiff line numberDiff line change
@@ -133,19 +133,22 @@ void ExcitonConfiguration::checkContentCoherence(){
133133
if(excitonInfo.nbands == 0 && excitonInfo.bands.empty()){
134134
throw std::invalid_argument("Must specify 'nbands' or 'bandlist' parameters");
135135
};
136+
137+
bool potentialFound = false;
138+
bool exchangePotentialFound = false;
136139
for (auto potential : supportedPotentials){
137140
if(excitonInfo.potential == potential){
138-
break;
141+
potentialFound = true;
142+
}
143+
if(excitonInfo.exchange && excitonInfo.exchangePotential == potential){
144+
exchangePotentialFound = true;
139145
}
146+
}
147+
if (!potentialFound){
140148
throw std::invalid_argument("Specified 'potential' not supported. Use 'keldysh' or 'coulomb'");
141149
}
142-
if (excitonInfo.exchange){
143-
for (auto potential : supportedPotentials){
144-
if(excitonInfo.exchangePotential == potential){
145-
break;
146-
}
150+
if (excitonInfo.exchange && !exchangePotentialFound){
147151
throw std::invalid_argument("Specified 'exchange.potential' not supported. Use 'keldysh' or 'coulomb'");
148-
}
149152
}
150153
if (excitonInfo.mode != "realspace" && excitonInfo.mode != "reciprocalspace"){
151154
throw std::invalid_argument("Invalid mode. Use 'realspace' or 'reciprocalspace'");

0 commit comments

Comments
 (0)