geo-fluid-dynamics / phaseflow-fenics

Phaseflow simulates the convection-coupled melting and solidification of phase-change materials.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Try using the melting rate as a goal

agzimmerman opened this issue · comments

This could be a small extension from the goal we've used so far, and directly relate our model to the scientific question of basal melting rates.

This worked just as expected! I did this before EGU; but was apparently too lazy to document it here until now.

import phaseflow


end_time = 80.

class Simulation(phaseflow.benchmark_phasechange_simulation.\
        ConvectionCoupledMeltingOctadecanePCMBenchmarkPCSimulation):
    
    def __init__(self):
        
        phaseflow.benchmark_phasechange_simulation.ConvectionCoupledMeltingOctadecanePCMBenchmarkPCSimulation.__init__(self)
        
        self.end_time = end_time
        
        self.initial_hot_wall_refinement_cycles = 6
        
        self.output_dir += "melting_rate/"
        
        self.coarsen_between_timesteps = False  # Coarsening hurts the time accuracy.
        
        self.nonlinear_solver_absolute_tolerance = 1.e-9
        
        self.second_order_time_discretization = True
        
        
    def setup_adaptive_goal_form(self):
        
        u_t, T_t, phi_t = self.make_time_discrete_terms()
        
        melting_rate = -phi_t
        
        self.adaptive_goal_form = melting_rate*self.integration_metric

    
    def verify(self):
    
        pass
        
        
if __name__ == "__main__":

    for epsilon_M in [8.e-5, 4.e-5, 2.e-5]
    
        for dt in [4., 2., 1.]:
    
            sim = Simulation()
            
            sim.timestep_size = dt
            
            sim.adaptive_goal_tolerance = epsilon_M
            
            sim.output_dir += "dt" + str(dt) + "/" + "epsilonM" + str(epsilon_M) + "/"
            
            sim.run()