Skip to content

Commit

Permalink
adding functional file
Browse files Browse the repository at this point in the history
  • Loading branch information
Olender committed Jul 29, 2024
1 parent 90ce60b commit 0803a56
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion spyro/solvers/inversion.py
Original file line number Diff line number Diff line change
Expand Up @@ -380,7 +380,11 @@ def get_functional(self, c=None):

self.functional_history.append(Jm)
self.functional = Jm
print(f"Functional: {Jm} at iteration: {self.current_iteration}", flush=True)
# Save the functional value to a text file
if self.comm.ensemble_comm.rank == 0 and self.comm.comm.rank == 0:
print(f"Functional: {Jm} at iteration: {self.current_iteration}", flush=True)
with open("functional_values.txt", "a") as file:
file.write(f"Iteration: {self.current_iteration}, Functional: {Jm}\n")

return Jm

Expand Down

0 comments on commit 0803a56

Please sign in to comment.