def setUp(self):
     factory = Factory()
     params = dict()
     params["gamma"] = 1.4
     params["R"] = 290.0
     self.eos = factory.createObject("IdealGasEoS", params)
     self.derivative_tester = FunctionDerivativesTester()
Esempio n. 2
0
def outputPrintDoFVectorToFile(path):
    # create the DoF handler
    factory = Factory()
    n_cell = 5
    mesh_name = "mesh"
    mesh = factory.createObject("UniformMesh", {"name": mesh_name, "n_cell": n_cell})
    ics = [
        factory.createObject(
            "InitialConditions1Phase", {
                "mesh_name": mesh_name,
                "A": "1",
                "rho": "1",
                "u": "1",
                "p": "1"
            })
    ]
    dof_handler = factory.createObject("DoFHandler1Phase", {"meshes": [mesh], "ics": ics})

    # solution vector
    U = list(range((n_cell + 1) * 3))

    # capture the output
    captor = OutputCaptor()
    printDoFVector(U, dof_handler)
    out = captor.getCapturedOutput()

    # write the output file
    text_file = open(path + "print_dof_vector.txt", "w")
    text_file.write(out)
    text_file.close()
    def testJunctionConstraintDoFIndices(self):
        # create the factory
        factory = Factory()

        # create the meshes
        n_cells_list = [3, 5, 4, 1]
        meshes = list()
        for i, n_cells in enumerate(n_cells_list):
            name = "mesh" + str(i + 1)
            params = {"name": name, "n_cell": n_cells}
            meshes.append(factory.createObject("UniformMesh", params))

        # ICs
        ics = [
            factory.createObject(
                "InitialConditions1Phase", {
                    "mesh_name": meshes[0].name,
                    "A": "1",
                    "rho": "1",
                    "u": "1",
                    "p": "1"
                })
        ]

        # create the DoF handler
        params = {"meshes": meshes, "ics": ics}
        dof_handler = factory.createObject("DoFHandler1Phase", params)

        # create an EoS
        eos_list = [factory.createObject("TestEoS")]

        # create the junctions
        n_constraints_list = [2, 6, 3, 1]
        n_junctions = len(n_constraints_list)
        meshes_list = [
            ["mesh1", "mesh2"], ["mesh2", "mesh3"], ["mesh1", "mesh2"], ["mesh3", "mesh4"]
        ]
        sides_list = [["right", "left"]] * n_junctions
        junctions = list()
        for i in range(n_junctions):
            params = {
                "mesh_names": meshes_list[i],
                "mesh_sides": sides_list[i],
                "dof_handler": dof_handler,
                "eos_list": eos_list,
                "n_constraints": n_constraints_list[i]
            }
            junctions.append(factory.createObject("TestJunction", params))

        # update the DoF handler with the junction constraints
        dof_handler.updateWithJunctionConstraints(junctions)

        # check all of the constraint DoF indices are the expected
        expected_constraint_dof_indices = [[12, 13], [35, 36, 37, 38, 39, 40], [14, 15, 16], [56]]
        for i, junction in enumerate(junctions):
            self.assertEqual(junction.i_constraint, expected_constraint_dof_indices[i])
 def setUp(self):
     factory = Factory()
     params = dict()
     params["gamma"] = 1.4
     params["cv"] = 2.0
     params["q"] = -5.0
     params["p_inf"] = 0.75
     params["q_prime"] = 6.0
     self.eos = factory.createObject("StiffenedGasEoS", params)
     self.derivative_tester = FunctionDerivativesTester()
Esempio n. 5
0
def run(mods=list()):
    # parse the input file
    input_file_parser = InputFileParser()
    input_file_parser.parse("print_fluid_properties.in")

    # apply modifications to input parameters, if any
    for mod in mods:
        input_file_parser.applyModification(mod)

    # create the factory
    factory = Factory()

    # equation of state
    eos_param_data = input_file_parser.getBlockData("EoS")
    eos_class = eos_param_data["type"]
    eos = factory.createObject(eos_class, eos_param_data)

    # thermodynamic state
    state_data = input_file_parser.getBlockData("ThermodynamicState")
    state = factory.createObject("ThermodynamicState", state_data)
    state.computeRemainingProperties(eos)
    print(state)
import unittest

from sem_python.base.Factory import Factory
from ....src.testers.AuxDerivativesTester import AuxDerivativesTester

factory = Factory()

# viscous flux aux
test_aux = factory.createObject("EntropyMinimumMassFlux", {"phase": 0})

# volume fraction aux
vf_aux = factory.createObject("VolumeFractionPhase1", {"phase": 0})

# viscous coefficient aux
params = dict()
params["var"] = "visccoef_arhoA1"
params["other_vars"] = ["aA1", "arhoA1", "arhouA1", "arhoEA1", "arhoA2", "arhouA2", "arhoEA2"]
params["coefs"] = [1.5, 2.5, 3.5, 4.5, 1.1, 1.7, 2.1]
visccoef_arho_aux = factory.createObject("TestAux", params)

# density gradient aux
params = dict()
params["var"] = "grad_rho1"
params["other_vars"] = ["grad_aA1", "grad_arhoA1"]
params["coefs"] = [1.2, 2.4]
grad_rho_aux = factory.createObject("TestAux", params)

# density aux
params = dict()
params["var"] = "rho1"
params["other_vars"] = ["aA1", "arhoA1"]
Esempio n. 7
0
 def setUp(self):
     self.factory = Factory()
    def checkDerivatives(self, kernel_name, model_type, phase, aux_dependencies, \
                         aux_gradients=list(), kernel_params=dict(), fd_eps=1e-8):
        self.model_type = model_type
        self.phase = phase

        # factory
        factory = Factory()

        # mesh
        params = {"n_cell": 1}
        meshes = [factory.createObject("UniformMesh", params)]

        # DoF handler
        dof_handler_params = {"meshes": meshes}
        if self.model_type == ModelType.OnePhase:
            ic_params = {
                "mesh_name": meshes[0].name,
                "A": "2",
                "rho": "1",
                "u": "1",
                "p": "1"
            }
            ics = [factory.createObject("InitialConditions1Phase", ic_params)]
            dof_handler_class = "DoFHandler1Phase"
        else:
            ic_params = {
                "mesh_name": meshes[0].name,
                "A": "2",
                "vf1": "0.3",
                "rho1": "1",
                "u1": "1",
                "p1": "1",
                "rho2": "1",
                "u2": "1",
                "p2": "1"
            }
            ics = [factory.createObject("InitialConditions2Phase", ic_params)]
            if self.model_type == ModelType.TwoPhaseNonInteracting:
                dof_handler_class = "DoFHandler2PhaseNonInteracting"
            elif self.model_type == ModelType.TwoPhase:
                dof_handler_class = "DoFHandler2Phase"
        dof_handler_params["ics"] = ics
        dof_handler = factory.createObject(dof_handler_class,
                                           dof_handler_params)

        # quadrature
        n_q_points = 2
        quadrature_params = {"n_q_points": n_q_points}
        quadrature = factory.createObject("Quadrature", quadrature_params)

        # FE values
        fe_values_params = {
            "quadrature": quadrature,
            "dof_handler": dof_handler,
            "meshes": meshes
        }
        self.fe_values = factory.createObject("FEValues", fe_values_params)

        # kernel
        kernel_params["phase"] = phase
        kernel_params["dof_handler"] = dof_handler
        kernel = factory.createObject(kernel_name, kernel_params)

        # aux
        aux_list = list()
        for a, aux_name in enumerate(sorted(aux_dependencies.keys())):
            # "vf1" is a special case of aux because its name is also the name of
            # a solution variable (in 2-phase); therefore one needs to make sure that
            # it uses its own "identity" aux instead of the generic test aux
            if aux_name == "vf1":
                params = {"phase": 0, "size": n_q_points}
                aux_list.append(
                    factory.createObject("VolumeFractionPhase1", params))
            else:
                params = TestAuxParameters(factory)
                params.set("var", aux_name)
                params.set("other_vars", aux_dependencies[aux_name])
                coefs = list()
                for d, _ in enumerate(aux_dependencies[aux_name]):
                    coefs.append(a + 2.0 + d * 0.5)
                params.set("coefs", coefs)
                params.set("b", 1.0)
                params.set("size", n_q_points)
                aux_list.append(TestAux(params))

        # add the aux derivatives
        for aux_name in aux_gradients:
            params = {
                "aux": aux_name,
                "variable_names": aux_dependencies[aux_name],
                "size": n_q_points
            }
            aux_list.append(factory.createObject("AuxGradient", params))

        # data
        data = dict()
        aux_names = [aux.name for aux in aux_list]
        der = initializeDerivativeData(aux_names, n_q_points)
        for aux_name in aux_dependencies:
            for dep in aux_dependencies[aux_name]:
                der[aux_name][dep] = np.zeros(n_q_points)
        self.elem = 0
        i = 0
        j = 1
        q = 0
        data["htc_wall"] = 0.2
        data["T_wall"] = 1.3
        data["P_heat"] = 0.6
        data["grad_A"] = 0.3
        data["phi"] = self.fe_values.get_phi()
        data["grad_phi"] = self.fe_values.get_grad_phi(self.elem)
        data["JxW"] = self.fe_values.get_JxW(self.elem)

        # compute base solution
        U = np.zeros(dof_handler.n_dof)
        for k in range(dof_handler.n_dof):
            U[k] = k + 1.0
        self.computeSolutionDependentData(U, data)
        for aux in aux_list:
            aux.compute(data, der)

        # base calculation
        r = kernel.computeResidual(data, i)[q]
        J_hand_coded = dict()
        for var_index in kernel.var_indices:
            J_hand_coded[var_index] = kernel.computeJacobian(
                data, der, var_index, i, j)[q]

        # finite difference Jacobians
        rel_diffs = dict()
        J_fd = dict()
        for var_index in kernel.var_indices:
            # perturb solution and recompute aux
            U_perturbed = deepcopy(U)
            j_global = dof_handler.i(j, var_index)
            U_perturbed[j_global] += fd_eps
            self.computeSolutionDependentData(U_perturbed, data)
            for aux in aux_list:
                aux.compute(data, der)

            # compute finite difference Jacobian
            r_perturbed = kernel.computeResidual(data, i)[q]
            J_fd[var_index] = (r_perturbed - r) / fd_eps
            rel_diffs[var_index] = computeRelativeDifference(
                J_hand_coded[var_index], J_fd[var_index])

        # print results
        for var_index in kernel.var_indices:
            var = dof_handler.variable_names[var_index]
            print("\nDerivative variable:", var)
            print("  Hand-coded        =", J_hand_coded[var_index])
            print("  Finite difference =", J_fd[var_index])
            print("  Rel. difference   =", rel_diffs[var_index])

        # take the absolute value of the relative differences
        for x in rel_diffs:
            rel_diffs[x] = abs(rel_diffs[x])
        return rel_diffs
Esempio n. 9
0
    def checkJacobian(self,
                      bc_name,
                      model_type=ModelType.OnePhase,
                      boundary="right",
                      bc_params=dict(),
                      fd_eps=1e-8):
        self.model_type = model_type

        # factory
        factory = Factory()

        # mesh
        params = {"n_cell": 1}
        meshes = [factory.createObject("UniformMesh", params)]

        # test node index
        if boundary == "left":
            k_test = 0
        else:
            k_test = 1

        # DoF handler
        dof_handler_params = {"meshes": meshes}
        if self.model_type == ModelType.OnePhase:
            ic_params = {
                "mesh_name": meshes[0].name,
                "A": "0.2",
                "rho": "1",
                "u": "1",
                "p": "1"
            }
            ics = [factory.createObject("InitialConditions1Phase", ic_params)]
            dof_handler_class = "DoFHandler1Phase"
        else:
            ic_params = {
                "mesh_name": meshes[0].name,
                "A": "0.2",
                "vf1": "0.3",
                "rho1": "1",
                "u1": "1",
                "p1": "1",
                "rho2": "1",
                "u2": "1",
                "p2": "1"
            }
            ics = [factory.createObject("InitialConditions2Phase", ic_params)]
            if self.model_type == ModelType.TwoPhaseNonInteracting:
                dof_handler_class = "DoFHandler2PhaseNonInteracting"
            elif self.model_type == ModelType.TwoPhase:
                dof_handler_class = "DoFHandler2Phase"
        dof_handler_params["ics"] = ics
        dof_handler = factory.createObject(dof_handler_class,
                                           dof_handler_params)
        n_dof = dof_handler.n_dof
        n_var = dof_handler.n_var

        # equation of state
        eos_params = dict()
        eos_params["gamma"] = 1.4
        eos_params["R"] = 2.0
        eos_list = [factory.createObject("IdealGasEoS", eos_params)]

        # BC
        bc_params["mesh_name"] = meshes[0].name
        bc_params["boundary"] = boundary
        bc_params["dof_handler"] = dof_handler
        bc_params["eos_list"] = eos_list
        bc = factory.createObject(bc_name, bc_params)

        # compute base solution
        U = np.zeros(n_dof)
        for i in range(n_dof):
            U[i] = i + 1.0

        # base calculation
        r = np.zeros(n_dof)
        J_hand_coded = np.zeros(shape=(n_dof, n_dof))
        bc.applyWeakBC(U, r, J_hand_coded)

        # finite difference Jacobians
        rel_diffs = np.zeros(shape=(n_var, n_var))
        J_fd = np.zeros(shape=(n_var, n_var))
        for var_index_j in range(dof_handler.n_var):
            # solution index to perturb
            j = dof_handler.i(k_test, var_index_j)

            # perturb solution
            U_perturbed = deepcopy(U)
            U_perturbed[j] += fd_eps

            # compute finite difference Jacobian
            r_perturbed = np.zeros(n_dof)
            J_perturbed = np.zeros(shape=(n_dof, n_dof))
            bc.applyWeakBC(U_perturbed, r_perturbed, J_perturbed)
            for var_index_i in range(n_var):
                # residual index tested
                i = dof_handler.i(k_test, var_index_i)

                J_fd[var_index_i][var_index_j] = (r_perturbed[i] -
                                                  r[i]) / fd_eps
                rel_diffs[var_index_i][
                    var_index_j] = computeRelativeDifference(
                        J_hand_coded[i][j], J_fd[var_index_i][var_index_j])

        # print results
        for var_index_i in range(n_var):
            i = dof_handler.i(k_test, var_index_i)
            var_i = dof_handler.variable_names[var_index_i]
            print("\nEquation variable:", var_i)
            for var_index_j in range(n_var):
                j = dof_handler.i(k_test, var_index_j)
                var_j = dof_handler.variable_names[var_index_j]
                print("\n  Derivative variable:", var_j)
                print("    Hand-coded        =", J_hand_coded[i][j])
                print("    Finite difference =",
                      J_fd[var_index_i][var_index_j])
                print("    Rel. difference   =",
                      rel_diffs[var_index_i][var_index_j])

        # take the absolute value of the relative differences
        return abs(rel_diffs)
Esempio n. 10
0
 def setUp(self):
     factory = Factory()
     self.eos = factory.createObject("TestEoS")
     self.derivative_tester = FunctionDerivativesTester()
Esempio n. 11
0
def run(input_file, input_file_modifier=InputFileModifier()):
    # parse the input file
    input_file_parser_original = InputFileParser()
    input_file_parser_original.parse(input_file)

    # check if the input file was a differential input file
    if input_file_parser_original.blockExists("BaseInputFile"):
        # get the name of the base input file and parse it
        base_input_file = input_file_parser_original.getBlockData(
            "BaseInputFile")["base"]
        input_file_parser_base = InputFileParser()
        input_file_parser_base.parse(base_input_file)

        # apply modifications to base input file parser
        input_file_parser_base.applyDifferentialInputFileParser(
            input_file_parser_original)

        input_file_parser = input_file_parser_base
    else:
        input_file_parser = input_file_parser_original

    # apply modifications to input parameters, if any
    input_file_parser.applyModifications(input_file_modifier)

    # create the factory
    factory = Factory()

    # model
    model_param_data = input_file_parser.getBlockData("Model")
    model = factory.createObject("Model", model_param_data)
    model_type = model.model_type
    factory.storeObject(model, "model")
    factory.storeObject(model_type, "model_type")

    # mesh(es)
    mesh_subblocks = input_file_parser.getSubblockNames("Mesh")
    meshes = list()
    if len(mesh_subblocks) == 0:
        # single mesh; no subblock is required
        mesh_param_data = input_file_parser.getBlockData("Mesh")
        mesh = factory.createObjectOfType(mesh_param_data)
        meshes.append(mesh)
    else:
        # multiple meshes; subblocks are required
        for mesh_subblock in mesh_subblocks:
            mesh_param_data = input_file_parser.getSubblockData(
                "Mesh", mesh_subblock)
            mesh_param_data["name"] = mesh_subblock
            mesh = factory.createObjectOfType(mesh_param_data)
            meshes.append(mesh)
    # check that no meshes have the same name
    mesh_names = list()
    for mesh in meshes:
        if mesh.name in mesh_names:
            error("Multiple meshes with the name '" + mesh.name + "'.")
        else:
            mesh_names.append(mesh.name)
    # store meshes in factory
    factory.storeObject(meshes, "meshes")

    # equations of state
    eos_subblocks = input_file_parser.getSubblockNames("EoS")
    if model_type == ModelType.OnePhase:
        if len(eos_subblocks) != 1:
            error("Single-phase flow should have exactly 1 equation of state.")
    else:
        if len(eos_subblocks) != 2:
            error("Two-phase flow should have exactly 2 equations of state.")
    eos_list = list()
    phase_name_to_index = dict()
    for k, eos_subblock in enumerate(eos_subblocks):
        phase_name_to_index[eos_subblock] = k
        eos_param_data = input_file_parser.getSubblockData("EoS", eos_subblock)
        eos_list.append(factory.createObjectOfType(eos_param_data))
    factory.storeObject(eos_list, "eos_list")

    # initial conditions / initial guess
    ic_subblocks = input_file_parser.getSubblockNames("IC")
    ics = list()
    if len(ic_subblocks) == 0:
        # ICs are to be used for every mesh
        for mesh_name in mesh_names:
            ic_param_data = input_file_parser.getBlockData("IC")
            ic_param_data["mesh_name"] = mesh_name
            if model_type == ModelType.OnePhase:
                ics.append(
                    factory.createObject("InitialConditions1Phase",
                                         ic_param_data))
            else:
                ics.append(
                    factory.createObject("InitialConditions2Phase",
                                         ic_param_data))
    else:
        for ic_subblock in ic_subblocks:
            ic_param_data = input_file_parser.getSubblockData(
                "IC", ic_subblock)

            # for now, assume that IC blocks are named by corresponding mesh names
            ic_param_data["mesh_name"] = ic_subblock
            if model_type == ModelType.OnePhase:
                ics.append(
                    factory.createObject("InitialConditions1Phase",
                                         ic_param_data))
            else:
                ics.append(
                    factory.createObject("InitialConditions2Phase",
                                         ic_param_data))

    # quadrature
    quadrature = factory.createObject("Quadrature", {"n_q_points": 2})
    factory.storeObject(quadrature, "quadrature")

    # DoF handler
    dof_handler_params = {"ics": ics}
    if model_type == ModelType.OnePhase:
        dof_handler_class = "DoFHandler1Phase"
    elif model_type == ModelType.TwoPhaseNonInteracting:
        dof_handler_class = "DoFHandler2PhaseNonInteracting"
    elif model_type == ModelType.TwoPhase:
        dof_handler_class = "DoFHandler2Phase"
    dof_handler = factory.createObject(dof_handler_class, dof_handler_params)
    factory.storeObject(dof_handler, "dof_handler")

    # junctions
    junctions = list()
    if input_file_parser.blockExists("Junctions"):
        junction_subblocks = input_file_parser.getSubblockNames("Junctions")
        for junction_subblock in junction_subblocks:
            junction_param_data = input_file_parser.getSubblockData(
                "Junctions", junction_subblock)
            if "phase" in junction_param_data:
                junction_param_data["phase"] = phase_name_to_index[
                    junction_param_data["phase"]]

            junction = factory.createObjectOfType(junction_param_data)
            junctions.append(junction)

    # update DoF handler with junction constraints
    dof_handler.updateWithJunctionConstraints(junctions)

    # boundary conditions
    bcs = list()
    bc_subblocks = input_file_parser.getSubblockNames("BC")
    for bc_subblock in bc_subblocks:
        bc_param_data = input_file_parser.getSubblockData("BC", bc_subblock)

        # if there is only 1 mesh, add the mesh parameter if not supplied already
        if len(meshes) == 1:
            if "mesh_name" not in bc_param_data:
                bc_param_data["mesh_name"] = meshes[0].name

        if "phase" in bc_param_data:
            bc_param_data["phase"] = phase_name_to_index[
                bc_param_data["phase"]]

        bc = factory.createObjectOfType(bc_param_data)
        bcs.append(bc)

    # interface closures
    if model_type == ModelType.TwoPhase:
        interface_closures_params = input_file_parser.getBlockData(
            "InterfaceClosures")
        interface_closures = factory.createObjectOfType(
            interface_closures_params)
    else:
        interface_closures = None

    # gravity
    physics_param_data = input_file_parser.getBlockData("Physics")
    physics_params = factory.createParametersObject("Physics",
                                                    physics_param_data)
    gravity = physics_params.get("gravity")
    if len(gravity) != 3:
        error("Gravity vector must have 3 elements")

    # heat transfer data
    # initialize heat transfer data such that no heat transfer occurs
    ht_param_data_default = {"T_wall": 0, "htc_wall": 0, "P_heat": 1}
    ht_data_default = factory.createObject("HeatTransferData",
                                           ht_param_data_default)
    ht_data = [ht_data_default] * len(meshes)
    if input_file_parser.blockExists("HeatTransfer"):
        ht_subblocks = input_file_parser.getSubblockNames("HeatTransfer")
        if len(ht_subblocks) == 0:
            # use same heat transfer data for every mesh
            ht_data_params = input_file_parser.getBlockData("HeatTransfer")
            ht_data_mesh = factory.createObject("HeatTransferData",
                                                ht_data_params)
            ht_data = [ht_data_mesh] * len(meshes)
        else:
            for subblock in ht_subblocks:
                # sub-blocks should be named by the corresponding mesh names
                mesh_name = subblock
                i_mesh = dof_handler.mesh_name_to_mesh_index[mesh_name]
                ht_data_mesh = input_file_parser.getSubblockData(
                    "HeatTransfer", subblock)
                ht_data[i_mesh] = factory.createObject("HeatTransferData",
                                                       ht_data_mesh)

    # nonlinear solver options
    nonlinear_solver_params = input_file_parser.getBlockData("NonlinearSolver")
    nonlinear_solver = factory.createObject("NonlinearSolver",
                                            nonlinear_solver_params)
    factory.storeObject(nonlinear_solver, "nonlinear_solver")

    # stabilization
    if input_file_parser.blockExists("Stabilization"):
        stabilization_param_data = input_file_parser.getBlockData(
            "Stabilization")
        stabilization_class = stabilization_param_data["type"]
    else:
        stabilization_param_data = {}
        stabilization_class = "NoStabilization"
    stabilization = factory.createObject(stabilization_class,
                                         stabilization_param_data)

    # create and run the executioner
    executioner_param_data = input_file_parser.getBlockData("Executioner")
    executioner_type = executioner_param_data["type"]
    executioner_param_data["ics"] = ics
    executioner_param_data["bcs"] = bcs
    executioner_param_data["junctions"] = junctions
    executioner_param_data["interface_closures"] = interface_closures
    executioner_param_data["gravity"] = gravity
    executioner_param_data["ht_data"] = ht_data
    executioner_param_data["stabilization"] = stabilization
    executioner = factory.createObjectOfType(executioner_param_data)
    U = executioner.run()

    # perform post-processing

    if input_file_parser.blockExists("Output"):
        # get solution and compute aux quantities
        vf1, arhoA1, arhouA1, arhoEA1 = dof_handler.getPhaseSolution(U, 0)
        if (model_type != ModelType.OnePhase):
            vf2, arhoA2, arhouA2, arhoEA2 = dof_handler.getPhaseSolution(U, 1)
        rho1 = computeDensity(vf1, arhoA1, dof_handler.A)[0]
        u1 = computeVelocity(arhoA1, arhouA1)[0]
        v1 = computeSpecificVolume(rho1)[0]
        E1 = computeSpecificTotalEnergy(arhoA1, arhoEA1)[0]
        e1 = computeSpecificInternalEnergy(u1, E1)[0]
        eos1 = eos_list[0]
        p1 = eos1.p(v1, e1)[0]
        T1 = eos1.T(v1, e1)[0]
        h1 = computeSpecificEnthalpy(e1, p1, rho1)[0]
        H1 = h1 + 0.5 * u1**2
        s1 = eos1.s(v1, e1)[0]
        # overflow can occur in p(h,s) with small gamma values
        with warnings.catch_warnings():
            warnings.simplefilter("ignore")
            p01 = eos1.p_from_h_s(H1, s1)[0]
        if (model_type != ModelType.OnePhase):
            rho2 = computeDensity(vf2, arhoA2, dof_handler.A)[0]
            u2 = computeVelocity(arhoA2, arhouA2)[0]
            v2 = computeSpecificVolume(rho2)[0]
            E2 = computeSpecificTotalEnergy(arhoA2, arhoEA2)[0]
            e2 = computeSpecificInternalEnergy(u2, E2)[0]
            eos2 = eos_list[1]
            p2 = eos2.p(v2, e2)[0]
            T2 = eos2.T(v2, e2)[0]
            h2 = computeSpecificEnthalpy(e2, p2, rho2)[0]
            H2 = h2 + 0.5 * u2**2
            s2 = eos2.s(v2, e2)[0]
            # overflow can occur in p(h,s) with small gamma values
            with warnings.catch_warnings():
                warnings.simplefilter("ignore")
                p02 = eos2.p_from_h_s(H2, s2)[0]

        # create an ordered data dictionary
        data = OrderedDict()
        data["x"] = dof_handler.x
        data["A"] = dof_handler.A
        if model_type == ModelType.OnePhase:
            data["rhoA"] = arhoA1
            data["rhouA"] = arhouA1
            data["rhoEA"] = arhoEA1
            data["rho"] = rho1
            data["u"] = u1
            data["v"] = v1
            data["E"] = E1
            data["e"] = e1
            data["p"] = p1
            data["T"] = T1
            data["h"] = h1
            data["H"] = H1
            data["s"] = s1
            data["p0"] = p01
        else:
            # phase 1
            data["vf1"] = vf1
            data["arhoA1"] = arhoA1
            data["arhouA1"] = arhouA1
            data["arhoEA1"] = arhoEA1
            data["rho1"] = rho1
            data["u1"] = u1
            data["v1"] = v1
            data["E1"] = E1
            data["e1"] = e1
            data["p1"] = p1
            data["T1"] = T1
            data["h1"] = h1
            data["H1"] = H1
            data["s1"] = s1
            data["p01"] = p01

            # phase 2
            data["vf2"] = vf2
            data["arhoA2"] = arhoA2
            data["arhouA2"] = arhouA2
            data["arhoEA2"] = arhoEA2
            data["rho2"] = rho2
            data["u2"] = u2
            data["v2"] = v2
            data["E2"] = E2
            data["e2"] = e2
            data["p2"] = p2
            data["T2"] = T2
            data["h2"] = h2
            data["H2"] = H2
            data["s2"] = s2
            data["p02"] = p02

        if model_type == ModelType.OnePhase:
            default_print_list = ["rho", "u", "p"]
        elif model_type == ModelType.TwoPhaseNonInteracting:
            default_print_list = ["rho1", "u1", "p1", "rho2", "u2", "p2"]
        else:  # model_type == ModelType.TwoPhase
            default_print_list = [
                "vf1", "rho1", "u1", "p1", "rho2", "u2", "p2"
            ]

        # create and run outputs
        output_subblocks = input_file_parser.getSubblockNames("Output")
        for output_subblock in output_subblocks:
            # extract the output parameter data
            output_param_data = input_file_parser.getSubblockData(
                "Output", output_subblock)
            output_class = output_param_data["type"]
            output_param_data["dof_handler"] = dof_handler
            # add additional parameters for specific classes
            if output_class == "ScreenOutput":
                if "data_names" not in output_param_data:
                    output_param_data["data_names"] = default_print_list
            # create the output
            output = factory.createObject(output_class, output_param_data)

            # run the output
            output.run(data)