## Model a Refrigeration Cycle

This example explains how to model a closed-loop refrigeration cycle. A refrigeration cycle simulation requires properly tuned component parameters. Imbalances in net energy transfer can cause runaway system pressure and temperature. Because the refrigerant undergoes energy transfer that causes substantial and rapid density changes, start by modeling and verifying the response of individual components. You then integrate the components into an open-loop system. Then, close the loop.

This example walks through developing the model in the Refrigeration Cycle (Air Conditioning) example. In this example you:

1. Use a P-H Diagram (2P) block to define the operating region of your refrigeration system.

2. Build a test harness for the evaporator using the System-Level Condenser Evaporator (2P-MA) block with an ideal flow source and reservoir blocks for boundary conditions.

3. Substitute a Thermostatic Expansion Valve (2P) block into the evaporator test harness.

4. Build a test harness for the condenser using the System-Level Condenser Evaporator (2P-MA) block with a Positive-Displacement Compressor (2P) block, and use two-phase and moist air reservoir blocks for the boundary conditions.

5. Use a Receiver Accumulator (2P) block to connect the harness from step 3 to the harness from step 4.

6. Remove two-phase reservoir blocks and connect the systems before verifying your results.

After each step, test the components at the desired steady-state nominal conditions to make sure the components are stable and the results are what you expect.

After you assemble a stable refrigeration cycle model, you can simulate conditions beyond nominal values by adjusting the reservoir blocks that represent the environment. Keep the nominal parameters in the model component the same, as they represent the nominal sizing of the component.

### Step 1: Determine the Pressure-Enthalpy Diagram

You must define parameters for the evaporator, condenser, thermostatic expansion valve, and receiver-accumulator. Before you can define these parameters, you must create a pressure-enthalpy diagram for the cycle you want to simulate.

1. Determine the nominal operating conditions for the system based on your design requirement. This example uses these requirements:

 Ambient temperature 30 °C Desired indoor temperature 22 °C Area of the house 200 m2 Cooling capacity 16 kW or 4.5 tons of refrigeration
2. Choose the appropriate refrigerant based on the design requirements. Then, select the four points of the refrigeration cycle on a P-h diagram for that refrigerant. The example model uses R-410a.

To plot fluid property contours on a pressure-enthalpy diagram, right-click on a Two-Phase Fluid Predefined Properties (2P) block or a Two-Phase Fluid Properties (2P) block. Select Foundation Library > Plot Fluid Properties (Contours). Then select Enthalpy Axis.

You can use data tips to read pressure, specific enthalpy, and temperature contour values to help you decide on the location of the four points of the refrigeration cycle.

3. Set the condensing temperature, or the saturation temperature in the condenser, to be higher than the outdoor temperature to enable heat transfer from the refrigerant to the outdoor environment.

The example model uses a 45 °C refrigerant temperature to provide a 15 °C temperature difference with ambient.

4. Set the evaporating temperature, or the saturation temperature in the evaporator, to be lower than the desired indoor temperature to enable heat transfer from the indoor air to the refrigerant.

The example model uses a 5 °C evaporator outlet temperature to remove heat from the 22 °C house.

5. To estimate the specific enthalpy end points of the high and low pressure lines in the cycle, set the amount of subcooling at the condenser outlet.

6. Compile the information to find estimates for the four points of the P-h diagram. The example model uses these values:

LocationPoint NumberSpecific Pressure (p)Specific Enthalpy (h)Notes
Evaporator outlet10.934 MPa430 kJ/kgCorresponds to a superheat of 5 °C
Condenser inlet22.734 MPa457 kJ/kgCorresponds to an estimated temperature of 65 °C
Condenser outlet32.734 MPa267 kJ/kgCorresponds to a subcooling of 5 °C
Evaporator inlet40.934 MPa267 kJ/kgCorresponds to a vapor quality of 0.27

As you develop and refine your model, you can modify these values to be more accurate or precise.

7. Draw the four points onto the refrigerant P-h plot by entering:

```hold on plot([430 457 267 267 430], [0.934 2.734 2.734 0.934 0.934], 'k-o', LineWidth = 2) ```

Note

Instead of using data tips, you can create a simple model with a reservoir and the desired sensor blocks.

• There is no flow to or from the reservoir, so sensor blocks measure fluid property values in the reservoir.

• Adjust the reservoir conditions as needed to get fluid property values at different conditions from the sensors.

To view the example model created in this step, enter:

`sscfluids_refrigeration_step1`

### Step 2: Set Up the Evaporator Test Harness

Next, represent the evaporator interaction between the refrigerant and the volume of air in the house. Build the test harness around a System-Level Condenser Evaporator (2P-MA) block. Represent the boundary conditions with the Reservoir (2P) and Reservoir (MA) blocks. Parameterize these blocks using the values you chose in step 1.

1. Add the refrigerant mass flow rate to the harness by using the Mass Flow Rate Source (2P) block, and add the air mass flow rate by using the Mass Flow Rate Source (MA) block. You can approximate values and refine them after closing the loop. To learn about compressor sizing for microchannel heat exchangers, visit Considerations for Microchannel Heat Exchangers.

Set the Power added parameter to `None` for both blocks, because these blocks represent boundary conditions that do no work on the flow.

Note

To approximate mass flow rate values for step 2, use the information from step 1. To approximate a mass flow rate value for the:

• Refrigerant — Divide the cooling capacity by the difference between the evaporator outlet specific enthalpy and the evaporator inlet specific enthalpy. This example gives 16 kW / (430 kJ/kg - 267 kJ/kg) = 0.1 kg/s.

• Air — Divide the cooling capacity by the pressure coefficient of air, and divide that result by the desired temperature drop across the evaporator. This example gives 10 °C, which is equivalent to a temperature drop of 10 K. Consequently, 16 kW / 1 kg/kJ/K / 10 K = 1.6 kg/s. To calculate the volumetric flow rate, divide the mass flow rate of the air by the density of air, which gives 1.6 kg/s / 1.2 kg/m3

2. Run the simulation and check your results by using Simscape Results Explorer. The simulation should be close to steady-state. Check that the simulation outputs match your estimates from step 1.

3. Adjust the mass flow rate on both the Mass Flow Rate Source (2P) block and the System-Level Condenser Evaporator (2P-MA) block until your model meets the conditions of your P-h diagram.

Note

You can use a Condenser Evaporator (2P-MA) block to obtain a higher fidelity model, but you should first validate your model with the System-Level Condenser Evaporator (2P-MA) block.

4. Adjust the mass flow rate on the Mass Flow Rate Source (MA) block and the System-Level Condenser Evaporator (2P-MA) block until your model meets the desired setpoints.

The example model uses a volumetric flow rate of 1.2 m3/s. This flow rate corresponds to a temperature drop of about 10 °C across the evaporator, where the house temperature is 22 °C and the return air is 12 °C.

5. Choose an appropriate refrigerant tube size based on the refrigerant mass flow rate.

6. Choose an appropriate air duct size based on the air flow rate.

To view the example model created in this step, enter:

`sscfluids_refrigeration_step2`

### Step 3: Set Up the Thermostatic Expansion Valve Test Harness

Next, model a thermostatic expansion valve to control the performance of the evaporator. A thermostatic expansion valve modulates the flow into the evaporator based on the measured superheat.

1. Start with your test harness from step 2. Replace the Mass Flow Rate Source (2P) block with the Thermostatic Expansion Valve (2P) block.

1. Connect sensing port S to the evaporator outlet. This port measures the evaporator superheat.

2. Use the cycle data from step 1 to change the conditions in the Reservoir (2P) block upstream of the valve from the evaporator inlet conditions to the condenser outlet conditions.

2. Set the Thermostatic Expansion Valve (2P) parameters based on the cycle data from steps 1 and 2.

3. Run the model and use the Simscape Results Explorer to check the results. The results should be close to the results of step 2. The steady-state value of the opening_fraction plot for this model is close to 0.7. Check that the opening fraction for your model meets the design requirements.

To view the example model created in this step, enter:

`sscfluids_refrigeration_step3`

### Step 4: Set Up the Condenser Test Harness

Build the condenser test harness in the same way that you constructed the evaporator test harness in step 2. Unlike the mass flow rate sources, this compressor must do work on the flow.

1. Model the condenser, flow, and environmental conditions. Use a System-Level Condenser Evaporator (2P-MA) to represent a condenser that rejects heat to the outdoor environment.

2. Connect a Positive-Displacement Compressor (2P) block to drive the refrigerant flow through the condenser.

Note

To simplify initial parameterization, you can use a Mass Flow Rate Source (2P) block and set the Power added parameter to `Isentropic` to represent the compressor. Switch to the Positive-Displacement Compressor (2P) block before closing the loop in step 6, because a compressor provides more stability to the closed-loop system. This is because the flow rate varies in response to the pressure difference between the high-pressure line and the low-pressure line. In contrast, a mass flow rate source produces an idealized constant mass flow rate regardless of fluctuations in operating conditions.

3. Specify the parameters for the nominal operating condition parameters in the condenser block.

4. Use Reservoir (MA) blocks to set up boundary conditions for the external environment. Set the air flow rate with Mass Flow Rate (MA) block.

5. Use the cycle data from step 1 to specify the Positive-Displacement Compressor (2P) block parameters. Set the Displacement specification parameter to `Nominal mass flow rate and shaft speed`. Then you use the value that you chose in step 2 for the Nominal mass flow rate parameter. The example model uses ```0.1 kg/s```.

In a refrigeration cycle, the compressor drives the refrigerant flow leaving the evaporator and sends it to the condenser. As the compressor does work on the flow, it increases the thermal load on the condenser. Because this portion of the model includes the compressor, you can use the Positive-Displacement Compressor (2P) block instead of the Mass Flow Rate Source (2P) block from step 2.

6. Run the model and use the Simscape Results Explorer to check the results. Check the temperatures of the Thermodynamic Properties Sensor (2P) blocks at the condenser inlet and evaporator outlet. Since the compressor does work on the refrigerant, the inlet temperature should be higher than the outlet.

Adjust the Nominal inlet temperature parameter in the System-Level Heat Exchanger (2P) block. Note that the condenser inlet and outlet specific enthalpy match the specific enthalpy end points of the high and low pressure lines in the cycle on the P-h diagram from step 1.

Because the boundary conditions in the reservoir match the nominal operating conditions in the System-Level Heat Exchanger (2P-MA) block and the initial conditions of the System-Level Heat Exchanger (2P-MA) are the same as the nominal operating conditions, the simulation of the test harness model should be close to steady state.

7. Check that the rate of heat transfer in the condenser is approximately equal to the combined rate of heat transfer in the evaporator from step 3 and the fluid power in the compressor. This is important to ensure that the closed-loop system has negligible net energy transfer, which prevents pressure divergence.

8. Adjust the air mass flow rate on both the Mass Flow Rate Source (MA) block and the System-Level Condenser Evaporator (2P-MA) block parameters to safely reject heat from the condenser. The example model uses a volumetric flow rate of 1.5 m3/s. This flow rate results in an air temperature rise of about 10 °C across the condenser, from 30 °C to 40 °C.

To view the example model created in this step, enter:

`sscfluids_refrigeration_step4`

### Step 5: Create a Model of the Open-Loop System

1. Create a model with all of the components in the system.

1. Use a Receiver Accumulator (2P) block to connect the condenser outlet from step 4 to the Thermostatic Expansion Valve (2P) block inlet from step 3.

The Receiver Accumulator (2P) block provides stability to the closed-loop system because it represents a large volume of refrigerant where the liquid level can rise and fall in response to fluctuating operating conditions.

The volume depends the size of the refrigeration system. Because the model is open-loop for this step, the flow rate through the condenser may not exactly match the flow rate through the evaporator, which causes the liquid level in the Receiver Accumulator (2P) block to rise and fall over time. This is acceptable for the test as long as the level does not change rapidly.

2. Keep the evaporator block outlet and the compressor inlet disconnected so that the model remains an open loop.

3. Ensure that both Reservoir (2P) blocks match the boundary conditions of the evaporator outlet defined in step 1.

2. Run the model and use Simscape Results Explorer to check the results. The results should be close the results from step 3 and step 4.

To view the example model created in this step, enter:

`sscfluids_refrigeration_step5`

### Step 6: Close the Loop

You are now ready to remove the reservoirs and connect the evaporator to the compressor.

1. Remove the reservoirs from step 5 and connect the evaporator outlet to the compressor inlet.

2. Run the model and use the Simscape Results Explorer to check your results. They should be close to the results from step 5.

1. If the pressure keeps increasing or decreasing, then it is likely that the condenser heat transfer does not match the combined evaporator heat transfer and compressor fluid power, which results in a net energy transfer to or from the refrigerant. Return to your harness from step 4.

2. Check that the liquid level in the Receiver Accumulator block is stable at the steady-state nominal operating condition. Adjust its volume, if necessary.

3. Check that the refrigerant mass flow rate, evaporator pressure, and condenser pressure are stable at the steady-state nominal operating conditions. If the condenser heat transfer does not match the evaporator heat transfer plus the compressor fluid power, the pressure may continue rising or falling during the simulation.

4. Check that the liquid level in the Receiver Accumulator (2P) block is stable at the steady-state nominal operating condition and adjust its volume if it is necessary.

5. To learn more about closing the loop for systems with microchannel heat exchangers, visit Considerations for Microchannel Heat Exchangers.

To view the example model created in this step, enter:

`sscfluids_refrigeration_step6`

### Make Additional Refinements to Fidelity

After you complete your model, you can continue to modify and refine the design to improve the fidelity of your system model. The Refrigeration Cycle (Air Conditioning) model demonstrates these refinements to the model from step 6:

• A house thermal network to represent the moist air network at the evaporator

• A Fan (MA) block in place of the Mass Flow Rate Source (MA) block for greater fidelity

• A controller that turns the system on and off to maintain a given indoor temperature