Skip to content

Commit

Permalink
Postprocessing
Browse files Browse the repository at this point in the history
  • Loading branch information
MartinAchondo committed Jul 10, 2024
1 parent 2f50151 commit 61eba3e
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 4 deletions.
2 changes: 1 addition & 1 deletion xppbe/Post/Post_Template.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@
"metadata": {},
"outputs": [],
"source": [
"Iter = 20000\n",
"Iter = 'last'\n",
"simulation.load_model_for_Post(Iter, save=False)\n",
"Post = simulation.Post"
]
Expand Down
8 changes: 6 additions & 2 deletions xppbe/Post/Results_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,16 @@
import pandas as pd


def find_largest_iteration(folder_path):
def get_max_iteration(folder_path):
subdirectories = [d for d in os.listdir(folder_path) if os.path.isdir(os.path.join(folder_path, d))]
iteration_numbers = [int(d.split('_')[1]) for d in subdirectories if d.startswith('iter_')]
if not iteration_numbers:
return None
largest_iteration_folder = os.path.join(folder_path, f'iter_{max(iteration_numbers)}')
return max(iteration_numbers)

def find_largest_iteration(folder_path):
Iter = get_max_iteration(folder_path)
largest_iteration_folder = os.path.join(folder_path, f'iter_{Iter}')
return largest_iteration_folder

def find_loss_csv(folder_path):
Expand Down
6 changes: 5 additions & 1 deletion xppbe/Simulation.py
Original file line number Diff line number Diff line change
Expand Up @@ -175,14 +175,18 @@ def postprocessing(self, run_all=False, jupyter=False, plot_mesh=False, known_me
return self.Post


def load_model_for_Post(self,Iter,save=False):
def load_model_for_Post(self,Iter='last',save=False):

if self.num_networks == 2:
from xppbe.NN.NeuralNet import PINN_2Dom_NeuralNet as NeuralNet
elif self.num_networks == 1:
from xppbe.NN.NeuralNet import PINN_1Dom_NeuralNet as NeuralNet

self.PINN_solver.results_path = self.results_path
if Iter=='last':
from xppbe.Post.Results_utils import get_max_iteration
Iter = get_max_iteration(os.path.join(self.results_path,'iterations'))

self.PINN_solver.load_NeuralNet(NeuralNet,self.results_path,f'iter_{Iter}',Iter)
self.PINN_solver.N_iters = self.N_iters

Expand Down

0 comments on commit 61eba3e

Please sign in to comment.