Skip to content

Commit

Permalink
Fix a bug in setting constraint matrix for FC2XML and FC3XML
Browse files Browse the repository at this point in the history
  • Loading branch information
ttadano committed Jun 6, 2022
1 parent 41f389a commit edd8f71
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions src/constraint.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2749,9 +2749,13 @@ void Constraint::generate_fix_constraint(const Symmetry *symmetry,

mother = fcs->get_fc_table()[order][ihead].mother;
found_element = false;
// sign_mother may be -1 (which is confusing and should be fixed in the future),
// so keep its sign so that the sign of the fixed parameter becomes consistent.
const auto sign_mother = fcs->get_fc_table()[order][ihead].sign;

for (auto j = 0; j < fcs->get_nequiv()[order][ui]; ++j) {
index_tmp = fcs->get_fc_table()[order][ihead + j].elems;

it_found = std::lower_bound(fc_fix_table.begin(),
fc_fix_table.end(),
ForceConstantTable(0.0, index_tmp));
Expand All @@ -2765,7 +2769,7 @@ void Constraint::generate_fix_constraint(const Symmetry *symmetry,

if (found_element) {
const_fix[order].emplace_back(ConstraintTypeFix(mother,
sign * (*it_found).fc_value));
sign_mother * sign * (*it_found).fc_value));
}
ihead += fcs->get_nequiv()[order][ui];
}
Expand Down Expand Up @@ -2804,6 +2808,9 @@ void Constraint::generate_fix_constraint(const Symmetry *symmetry,

mother = fcs->get_fc_table()[order][ihead].mother;
found_element = false;
// sign_mother may be -1 (which is confusing and should be fixed in the future),
// so keep its sign so that the sign of the fixed parameter becomes consistent.
const auto sign_mother = fcs->get_fc_table()[order][ihead].sign;

for (auto j = 0; j < fcs->get_nequiv()[order][ui]; ++j) {
index_tmp = fcs->get_fc_table()[order][ihead + j].elems;
Expand All @@ -2820,7 +2827,7 @@ void Constraint::generate_fix_constraint(const Symmetry *symmetry,

if (found_element) {
const_fix[order].emplace_back(ConstraintTypeFix(mother,
sign * (*it_found).fc_value));
sign_mother * sign * (*it_found).fc_value));
}
ihead += fcs->get_nequiv()[order][ui];
}
Expand Down

0 comments on commit edd8f71

Please sign in to comment.