Skip to content

Commit

Permalink
fix too large right_dims of csf constructed mps
Browse files Browse the repository at this point in the history
  • Loading branch information
hczhai committed Nov 3, 2023
1 parent da9d655 commit b86276b
Showing 1 changed file with 57 additions and 0 deletions.
57 changes: 57 additions & 0 deletions src/dmrg/determinant.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -283,6 +283,25 @@ struct DeterminantTRIE<S, FL, typename S::is_sz_t>
}
r->tensors[k] = t;
}
for (int i = n_sites - 1; i >= 0; i--)
if (info->right_dims[i]->n_states_total >
(total_bond_t)dets.size()) {
total_bond_t new_total = 0;
for (int k = 0; k < info->right_dims[i]->n; k++) {
uint64_t new_n_states =
(uint64_t)(ceil((double)info->right_dims[i]
->n_states[k] *
dets.size() /
info->right_dims[i]->n_states_total) +
0.1);
assert(new_n_states != 0);
info->right_dims[i]->n_states[k] =
(ubond_t)min((uint64_t)new_n_states,
(uint64_t)numeric_limits<ubond_t>::max());
new_total += info->right_dims[i]->n_states[k];
}
info->right_dims[i]->n_states_total = new_total;
}
info->check_bond_dimensions();
info->save_mutable();
return r;
Expand Down Expand Up @@ -633,6 +652,25 @@ struct DeterminantTRIE<S, FL, typename S::is_su2_t>
}
r->tensors[k] = t;
}
for (int i = n_sites - 1; i >= 0; i--)
if (info->right_dims[i]->n_states_total >
(total_bond_t)dets.size()) {
total_bond_t new_total = 0;
for (int k = 0; k < info->right_dims[i]->n; k++) {
uint64_t new_n_states =
(uint64_t)(ceil((double)info->right_dims[i]
->n_states[k] *
dets.size() /
info->right_dims[i]->n_states_total) +
0.1);
assert(new_n_states != 0);
info->right_dims[i]->n_states[k] =
(ubond_t)min((uint64_t)new_n_states,
(uint64_t)numeric_limits<ubond_t>::max());
new_total += info->right_dims[i]->n_states[k];
}
info->right_dims[i]->n_states_total = new_total;
}
info->check_bond_dimensions();
info->save_mutable();
return r;
Expand Down Expand Up @@ -914,6 +952,25 @@ struct DeterminantTRIE<S, FL, typename S::is_sg_t>
}
r->tensors[k] = t;
}
for (int i = n_sites - 1; i >= 0; i--)
if (info->right_dims[i]->n_states_total >
(total_bond_t)dets.size()) {
total_bond_t new_total = 0;
for (int k = 0; k < info->right_dims[i]->n; k++) {
uint64_t new_n_states =
(uint64_t)(ceil((double)info->right_dims[i]
->n_states[k] *
dets.size() /
info->right_dims[i]->n_states_total) +
0.1);
assert(new_n_states != 0);
info->right_dims[i]->n_states[k] =
(ubond_t)min((uint64_t)new_n_states,
(uint64_t)numeric_limits<ubond_t>::max());
new_total += info->right_dims[i]->n_states[k];
}
info->right_dims[i]->n_states_total = new_total;
}
info->check_bond_dimensions();
info->save_mutable();
return r;
Expand Down

0 comments on commit b86276b

Please sign in to comment.