Skip to content

Conversation

steffi7574
Copy link
Member

Corrects the setup of system matrices when Hamiltonians are read from file and when running the Lindblad solver on multiple Petsc-processors are used:

  • A matrix elements should only be set if the processor owns the row
  • Matrix elements should be added up, rather than inserted in the LIndblad case.

@steffi7574 steffi7574 requested a review from tdrwenski July 24, 2025 00:16
Comment on lines +89 to +94
if (fabs(imag) > 1e-15 && ilow <= row && row < iupp) MatSetValue(Ad, rowk, colk, imag, ADD_VALUES);
if (fabs(real) > 1e-15 && ilow <= row && row < iupp) MatSetValue(Bd, rowk, colk, -real, ADD_VALUES);
rowk = col * dim_rho + k;
colk = row * dim_rho + k;
if (fabs(imag) > 1e-15) MatSetValue(Ad, rowk, colk, -imag, INSERT_VALUES);
if (fabs(real) > 1e-15) MatSetValue(Bd, rowk, colk, real, INSERT_VALUES);
if (fabs(imag) > 1e-15 && ilow <= row && row < iupp) MatSetValue(Ad, rowk, colk, -imag, ADD_VALUES);
if (fabs(real) > 1e-15 && ilow <= row && row < iupp) MatSetValue(Bd, rowk, colk, real, ADD_VALUES);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should you check rowk instead of row in the if statements since this is what is being set in the matrices?

@steffi7574 steffi7574 merged commit a8a15d1 into main Jul 28, 2025
10 checks passed
@steffi7574 steffi7574 deleted the bugfix-hamiltonianreader branch July 28, 2025 20:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants