Older stuff/NumericalInverse.py
def evaluate_one_inverse_step(self, init_q_adjustment=10):
        """
        Running one whole step of the inverse simulation, until the point
            we are satisfied with the results
        We are done with the step when the difference of two successive
            error values is less than the tolerance that was set in __init__
        """

        self.Sim.make_checkpoint()  # checkpoint previous state so we can revert to it
        q_adj = init_q_adjustment  # initial adjustments to heat flux being currently solved
        self.Sim.HeatFlux[self.current_q_idx] = self.Sim.HeatFlux[self.current_q_idx-1]  # explicit portion
        self.Sim.HeatFlux[self.current_q_idx+1] = self.Sim.HeatFlux[self.current_q_idx-1]  # implicit portion
        prev_error = self.evaluate_window_error_norm()
        iter_no = 0
        while True:
            # simulate few steps
            iter_no += 1
            self.Sim.evaluate_n_steps(n_steps=self.window_span, increment_simulation_time=False)
            new_error = self.evaluate_window_error_norm()

            if abs(prev_error - new_error) < self.tolerance:
                self.Sim.revert_to_checkpoint()  # revert simulation to last checkpoint
                self.Sim.evaluate_one_step()  # make one step only
                # print(f"Accepting Flux: %.2f at time %.2f s with Error: %.10f after %i iterations" % (self.Sim.HeatFlux[self.current_q_idx], self.Sim.t[self.current_q_idx], new_error, iter_no))
                break  # this Flux seems to be ok so stop adjusting it
            elif new_error < prev_error:
                prev_error = new_error
                self.Sim.revert_to_checkpoint()  # revert simulation to last checkpoint
                # and keep adjusting the heat flux the by the same value because the error is getting smaller
            elif new_error > prev_error:
                prev_error = new_error
                self.Sim.revert_to_checkpoint()  # revert simulation to last checkpoint
                q_adj *= -0.7  # and make adjustments to the heat flux smaller going in the opposite direction because the error got higher last time
            self.Sim.HeatFlux[self.current_q_idx] += q_adj  # adjust heatflux a little in the explicit portion
            self.Sim.HeatFlux[self.current_q_idx+1] += q_adj  # adjust heatflux a little in the implicit portion
        self.current_q_idx += 1

        Running one whole step of the inverse simulation, until the point
            we are satisfied with the results
        We are done with the step when the difference of two successive
            error values is less than the tolerance that was set in __init__
        
Running one whole step of the inverse simulation, until the point
we are satisfied with the results
We are done with the step when the difference of two successive
error values is less than the tolerance that was set in __init
Running one whole step of the inverse simulation until the point we are satisfied with the results We are done with the step when the difference of two successive error values is less than the tolerance that was set in __init
def evaluate_one_inverse_step(self, init_q_adjustment=10):
        self.Sim.make_checkpoint()  
        q_adj = init_q_adjustment  
        self.Sim.HeatFlux[self.current_q_idx] = self.Sim.HeatFlux[self.current_q_idx-1]  
        self.Sim.HeatFlux[self.current_q_idx+1] = self.Sim.HeatFlux[self.current_q_idx-1]  
        prev_error = self.evaluate_window_error_norm()
        iter_no = 0
        while True:
            iter_no += 1
            self.Sim.evaluate_n_steps(n_steps=self.window_span, increment_simulation_time=False)
            new_error = self.evaluate_window_error_norm()
            if abs(prev_error - new_error) < self.tolerance:
                self.Sim.revert_to_checkpoint()  
                self.Sim.evaluate_one_step()  
                break  
            elif new_error < prev_error:
                prev_error = new_error
                self.Sim.revert_to_checkpoint()  
            elif new_error > prev_error:
                prev_error = new_error
                self.Sim.revert_to_checkpoint()  
                q_adj *= -0.7  
            self.Sim.HeatFlux[self.current_q_idx] += q_adj  
            self.Sim.HeatFlux[self.current_q_idx+1] += q_adj  
        self.current_q_idx += 1
def evaluate_one_inverse_step ( self , init_q_adjustment = 10 ) : self . Sim . make_checkpoint ( ) q_adj = init_q_adjustment self . Sim . HeatFlux [ self . current_q_idx ] = self . Sim . HeatFlux [ self . current_q_idx - 1 ] self . Sim . HeatFlux [ self . current_q_idx + 1 ] = self . Sim . HeatFlux [ self . current_q_idx - 1 ] prev_error = self . evaluate_window_error_norm ( ) iter_no = 0 while True : iter_no += 1 self . Sim . evaluate_n_steps ( n_steps = self . window_span , increment_simulation_time = False ) new_error = self . evaluate_window_error_norm ( ) if abs ( prev_error - new_error ) < self . tolerance : self . Sim . revert_to_checkpoint ( ) self . Sim . evaluate_one_step ( ) break elif new_error < prev_error : prev_error = new_error self . Sim . revert_to_checkpoint ( ) elif new_error > prev_error : prev_error = new_error self . Sim . revert_to_checkpoint ( ) q_adj *= - 0.7 self . Sim . HeatFlux [ self . current_q_idx ] += q_adj self . Sim . HeatFlux [ self . current_q_idx + 1 ] += q_adj self . current_q_idx += 1
Running one whole step of the inverse simulation, until the point
we are satisfied with the results
We are done with the step when the difference of two successive
error values is less than the tolerance that was set in __init__
Running one whole step of the inverse simulation until the point we are satisfied with the results We are done with the step when the difference of two successive error values is less than the tolerance that was set in __init__
"""
        Running one whole step of the inverse simulation, until the point
            we are satisfied with the results
        We are done with the step when the difference of two successive
            error values is less than the tolerance that was set in __init__
        """ # checkpoint previous state so we can revert to it # initial adjustments to heat flux being currently solved # explicit portion # implicit portion # simulate few steps # revert simulation to last checkpoint # make one step only # print(f"Accepting Flux: %.2f at time %.2f s with Error: %.10f after %i iterations" % (self.Sim.HeatFlux[self.current_q_idx], self.Sim.t[self.current_q_idx], new_error, iter_no)) # this Flux seems to be ok so stop adjusting it # revert simulation to last checkpoint # and keep adjusting the heat flux the by the same value because the error is getting smaller # revert simulation to last checkpoint # and make adjustments to the heat flux smaller going in the opposite direction because the error got higher last time # adjust heatflux a little in the explicit portion # adjust heatflux a little in the implicit portion
self
init_q_adjustment