Giter VIP home page Giter VIP logo

sapphire's People

Contributors

agzimmerman avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

sapphire's Issues

Plot manufactured solutions, and double check initial values for time dependent MMS

I copied the code from assigning initial values to create the following for plotting manufactured solutions:

def plot_manufactured_solution(
        Model,
        meshsize = 128,
        parameters = {},
        time = None):
        
    MMSVerificationModel = make_mms_verification_model_class(Model)
    
    model = MMSVerificationModel(meshsize = meshsize)

    model.init_manufactured_solution()
    
    if time is not None:
    
        model.time.assign(time)
    
    for u_m, V in zip(
            model.manufactured_solution, model.function_space):

        model.solution.assign(fe.interpolate(u_m, V))

    model.plot()

but this did not have the expected result; which makes me worry about how initial values are being assigned in the MMS code. By nature the MMS code shouldn't be passing if the initial values aren't being set correctly, so why is the behavior different here?

Damp SNES line search for convection-coupled phase-change

Patrick Farrell showed me that applying the following patch allows us to solve the nonlinear problem often with much less regularization:

diff --git a/sapphire/simulations/convection_coupled_phasechange.py b/sapphire/simulations/convection_coupled_phasechange.py
index f043774..c31fb6c 100644
--- a/sapphire/simulations/convection_coupled_phasechange.py
+++ b/sapphire/simulations/convection_coupled_phasechange.py
@@ -274,6 +274,9 @@ class Simulation(sapphire.simulation.Simulation):
                 "snes_max_it": 24,
                 "snes_monitor": None,
                 "snes_converged_reason": False,
+                "snes_linesearch_type": "l2",
+                "snes_linesearch_maxstep": 1.0,
+                "snes_linesearch_damping": 0.9,
                 "ksp_type": "preonly", 
                 "pc_type": "lu", 
                 "mat_type": "aij",

This worked fine for the octadecane melting regression test. I want to try it with even smaller $\sigma$, both for octadecane melting and water freezing regression tests, and then for higher fidelity simulations to the simulated times where we compare to benchmarks in our paper.

Add benchmark test for "heat transfer during the melting of ice around a horizontal, isothermal cylinder"

Based on this paper: https://www.researchgate.net/publication/226804783_Heat_transfer_during_the_melting_of_ice_around_a_horizontal_isothermal_cylinder

The current enthalpy-porosity model should be enough for a nice qualitative result. A nice quantitative result, and perhaps easier set up in general, would first require phase-dependent heat capacity and thermal conductivity (for which we have issue #37).

This would be our first demonstration of an interesting geometry.

Update examples in README

  • Replace portfolio/benchmarks section with examples section
    - [ ] Scale streamline thickness with max speed from entire simulation
    - [ ] Update octadecane melting gif
  • Add water freezing gif
  • Add gallium melting gif
  • Add freezing salt water from above (with brine plume) once that simulation is in the master branch. Use matplotlib.cm.ocean colormap if showing porosity

Verify binary alloy enthalpy model

First, reproduce this result from Phaseflow (See geo-fluid-dynamics/phaseflow-fenics#83):

image

I have been trying to resolve a sharper interface, and it's making it so that the freezing front is stuck:

image

Before digging into that, I should make sure we get the first result with the oversmoothed interface. Also note that, for the old Phaseflow result, not as much work was put into setting up the example with physically relevant parameters. While the movement of the interface is qualitatively wrong for the latest FemPy result, the magnitude of the concentration at the solidification front is about right.

Generalize regularization of convection-coupled phase-change nonlinear problem

Our current approach to regularizing the convection-coupled phase-change nonlinear problem works very well for the benchmarks we simulate. In short, we solve for small $sigma$ via first solving a sequence of over-regularized (larger $sigma$) problems, which essentially improve the initial guess for Newton's method. Similar approaches are referred to as "continuation".

Patrick Farrell, who develops UFL/FEniCS/Firedrake, said he has been working on a general regularization method for problems with local nonlinearities/irregularities, and that it might work well for our convection-coupled phase-change problem.

So now I've made this branch and added a test to try his idea, or perhaps to try other regularization methods.

The existing regression test (here) for melting octadecane passes. I ran it with

$ python3 -m pytest -v -s -k "validate and melt_octadecane and (not without_auto_smoothing)" sapphire/tests/ > log__test_melt_octadecane_with_auto_smoothing.txt

which output log__test_melt_octadecane_with_auto_smoothing.txt

I added a new test to the same script which uses a simple default solver

class OctadecaneMeltingSimulationWithoutAutoSmoothing(
        OctadecaneMeltingSimulation):
    
    def solve(self, *args, **kwargs):
    
        return sapphire.simulation.Simulation.solve(
            self,
            *args,
            parameters = {
                "snes_type": "newtonls",
                "snes_max_it": 50,
                "snes_monitor": True,
                "snes_converged_reason": True,
                "ksp_type": "preonly", 
                "pc_type": "lu", 
                "mat_type": "aij",
                "pc_factor_mat_solver_type": "mumps"},
            **kwargs)
            
    def run(self, *args, **kwargs):
        
        return sapphire.benchmarks.melt_octadecane_in_cavity.Simulation.run(
            self,
            *args,
            solve = self.solve,
            **kwargs)

We currently expect the test to fail, which it does. I run it with

$ python3 -m pytest -v -s -k "validate and melt_octadecane and without_auto_smoothing" sapphire/tests/ > log__test_melt_octadecane_without_auto_smoothing.txt

which output log__test_melt_octadecane_without_auto_smoothing.txt

Ideally there would be a set of solver parameters, which we could set in the definition of solve above, for which the test passes. With that, we would want to try the same for the water freezing benchmark, and for even smaller $sigma$, e.g. on the order of 0.001 which has been commonly used for some of my recent results.

Clarify dependencies

e.g. to what extent do we depend on VTK? I personally had trouble getting Python VTK set up on my Ubuntu 18.04 system. For now I should at least document how I got VTK working on my system.

Monitor condition number of the Jacobian

I asked how to do this on Slack and it seems there's a way for us to redefine a SNES Monitor:

"
Julian Andrej [3:54 PM]
"I'd implement a SNES Monitor for that
You can then access the jacobian after every nonlinear iteration
so if you have

solver = NonlinearVariationalSolver(...)
mysnes = solver.snes

def monitor(snes, its, fgnorm):
  myjacobian = snes.jacobian

snes.setMonitor(monitor)

myjacobian then contains a Petsc Mat
"

Try using scipy instead of PETSc

In this case, we'd only use Firedrake for its key capabilities, which include assembling system matrices (with Dirichlet BC's) and symbolically deriving Jacobians. We would try ignoring the PETSc interface component of Firedrake and see how far we can get with scipy.

NSB first-order time accuracy verification fails with latest Firedrake

In tests/verification/test__unsteady_navier_stokes_boussinesq.py::test__verify_first_order_temporal_convergence_via_mms, after generating

Delta_t, errors, temporal_orders
0.5, [None, 0.011107126169912135, 0.025971296457037198], None
0.25, [None, 0.006439718841114489, 0.014279010781708205], [None, 0.7864159791056798, 0.8630219973726072]
0.125, [None, 0.003462654871468789, 0.007475212830499297], [None, 0.8951191025760915, 0.9337094754111044]

the nonlinear solver diverges with Delta_t = 0.06125 after solving at t = 0.8125.

Map robustness of enthalpy method for convection-coupled phase-change

Some old notes, running binary alloy model:

parameters = {
"temperature_rayleigh_number": 8.,
"concentration_rayleigh_number": -9.,
"prandtl_number": 7.,
"stefan_number": 0.2,
"schmidt_number": 6.,
"pure_liquidus_temperature": 0.,
"liquidus_slope": -0.11,
"phase_interface_smoothing": 1./16.,
"autosmooth_maxcount": 16}

m, Delta_t, smin
4, 1./4., 0.0870
4, 1./8., 0.1519
4, 1./16., 0.0758
4, 1./32., 0.0917
4, 1./64., 0.0640
4, 1./128., 0.0625
4, 1./256., 0.0661
4, 1./512., 0.0635
8, 1./64., 0.0804
16, 1./64., 0.0842
32, 1./64., 0.0867

I also have many results with different parameters from running Phaseflow.

Implement self-adjoint time discretization schemes

Right now we're only using fully implicit backward difference formulas of first, second, and third order. Thankfully, the time discretization of any of our models is well encapsulated, so we can test mixed explicit-implicit methods such as Crank Nicholson and Runge-Kutta. @tomoleary said that Crank Nicholson and RK4 are needed for plugging our models into inverse problems because they are self-adjoint.

Add checkpointing/restarting with HDF5

Right now, solutions are only written to VTK files. For post-processing, this is only accurate for CG1 bases. For restarting simulations, this is mostly useless.

sapphire.Simulation should have a simplified interface to firedrake.DumbCheckpoint for checkpointing and restarting.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.