def test_CFD():
    #currently, not usable
    df = '../data/TestCFD.json'
    settings = load_settings(df)  # force python2 load ascii string
    #settings['case_folder'] = os.path.abspath(os.path.dirname(__file__)) + os.path.sep + "data"
    #
    from FenicsSolver import CoupledNavierStokesSolver
    solver = CoupledNavierStokesSolver.CoupledNavierStokesSolver(settings)
    solver.print()
    solver.solve()
    solver.plot()
예제 #2
0
def test_incompressible(using_elbow=True,
                        coupling_energy_equation=True,
                        Newtonian=True):
    s = setup(using_elbow, using_3D=False, compressible=False)
    s['solving_temperature'] = coupling_energy_equation
    # nonNewtonian diverges!

    if using_elbow:
        Re = 1e0  # see pressure change,     # stabilization_method seems make no difference
    else:
        s['fe_degree'] = 1  # test failed, can not finish JIT
        Re = 10  # mesh is good enough to simulate higher Re

    fluid = {
        'name': 'gas',
        'kinematic_viscosity': (length_scale * max_vel) / Re,
        'density': 1,
        'specific_heat_capacity': 420,
        'thermal_conductivity': 0.1,
        'Newtonian': Newtonian
    }
    s['material'] = fluid

    # Re=10 is working without G2, when Re=1e-3 got NaN error, it is not clear why
    #s['advection_settings'] = {'Re': Re, 'stabilization_method': 'G2' , 'kappa1': 4, 'kappa2': 2}
    print("Reynolds number = ", Re)

    from FenicsSolver import CoupledNavierStokesSolver
    solver = CoupledNavierStokesSolver.CoupledNavierStokesSolver(
        s)  # set a very large viscosity for the large inlet width
    #solver.using_nonlinear_solver = False
    if coupling_energy_equation:
        u, p, T = split(solver.solve())
    else:
        u, p = split(solver.solve())

    if interactively:
        solver.plot()

    if not coupling_energy_equation and False:  # not fully tested
        from FenicsSolver import ScalarTransportSolver
        solver_T = ScalarTransportSolver.ScalarTransportSolver(s)
        #Q = solver.function_space.sub(1)  # seem it is hard to share vel between. u is vectorFunction
        Q = solver_T.function_space
        cvel = VectorFunction(Q)
        cvel.interpolate(u)  # degree ?
        selver_T.convective_velocity = cvel
        T = solver_T.solve()
예제 #3
0
    s['solver_settings']['reference_values'] = {'velocity': (1, 1), "temperature": T_ambient, "pressure": p_outlet}
    s['solver_settings']['solver_parameters'] = {
                                    "relative_tolerance": 1e-9,  # mapping to solver.parameters of Fenics
                                    "maximum_iterations": 50,
                                    "relaximation_parameter": 0.001,
                                    "monitor_convergence": True,  # print to console
                                    },
    s['solving_temperature'] = coupling_energy_equation
    fluid = {'name': 'oil', 'kinematic_viscosity': mu/rho, 'density': rho, 
                'specific_heat_capacity': 4200, 'thermal_conductivity':  0.1, 'Newtonian': True}
    s['material'] = fluid

    #s['advection_settings'] = {'Re': Re, 'stabilization_method': 'G2' , 'kappa1': 4, 'kappa2': 2}

    from FenicsSolver import CoupledNavierStokesSolver
    solver = CoupledNavierStokesSolver.CoupledNavierStokesSolver(s)  # set a very large viscosity for the large inlet width
    solver.using_nonlinear_solver = False
    solver.transient_settings['transient']  = False
    from pprint import pprint
    #pprint(solver.settings)
    plot(solver.boundary_facets)
    up0 = solver.solve()  # get a realistic intial valve from static simulation
    solver.initial_values = up0
    solver.transient_settings['transient'] = transient_settings
    solver.solve()  # no need to transform static bc into transient bc

    if interactively:
        solver.plot()

if using_segegrate_solver:
    # Define expressions used in variational forms