- measure the in-cylinder pressure using a pressure sensor, so you get a physical signal for p(t).
- measure the piston speed using a translational sensor, so you get v(t).
- given cylinder area A, you can calculate p*v*A using PS product and you should have p*v*A = p*(dV/dt), where V is the cylinder volume.
- integrate the term you get from (3), using a PS integrator (so you don't worry about unit conversion), should get you the work term.

# Calculating Work done by a Closed Cylinder in Simulink and Simscape

9 views (last 30 days)

Show older comments

H All,

I am attempting to calculate the heat work done by a cylinder in an internal combustion engine over a single cycle (V1->V2->V1), using simulink blocks in my Simscape model.

Using the following

I have been able to calculate (with code) the Work Done for the compression stroke (V1 to V2) and combustion stroke (V2 to V1) individually then sum them to get the total work done for the cycle, is this assumption correct, as I am struggling to find an answer in the literature

Work Done during Compression (V1 to V2)

%Define the v1 and v2 pressure and volume array

P_comp = [1.4, 45.82]; % pressure v1 pressure at v2 [bar]

V_comp = [797.44, 64.75]; % volume at v1 and v2 [cc]

%Use numerical integration to calculate the work done

W_comp = trapz(V_comp, P_comp)

Work Done by Combustion (V2 to V1)

%Define the v2 and v1 pressure and volume array

P_comb = [45.82, 5.45]; % pressure v2 pressure at v1 [bar]

V_comb = [64.75, 775.07]; % volume at v2 and v1 [cc]

%Use numerical integration to calculate the work done

W_comb = trapz(V_comb, P_comb)

%Total Work done during a single cycle with both strokes (V1->V2->V1)

W = W_comp+W_comb

I have attemped to implement integrating the pressure and volume in my Simulink model (function block) where I have both pressure and volume as signals but it get an error. I can implement by using the arrays for P and V as above. Any suggestions of how to implement work done using the signals and simulink rather than code?

function W = calc_work(P_comp, V_comp)

% Use numerical integration to calculate the work done

W = trapz(V_comp, P_comp);

end

Thanks in advance,

Patrick

##### 0 Comments

### Accepted Answer

Yifeng Tang
on 22 Mar 2023

You mentioned that you are using Simscape for the simulation of the cylinder. If that is indeed the case, I believe it would be easier to compute and integrate for the work more directly from information available in Simscape.

Alternatively, you can also measure the force at the R port of the cylinder, and multiply by the velocity and integrate. The mechanical power obtained this way should match the fluid power; you may see some difference if you have some piston mass or friction set up.

Hope this makes sense.

### More Answers (0)

### See Also

### Categories

### Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!