• https://me.yahoo.com

# work

Computes the work done by a thermal machine. Computes the work done by a thermal machine.
Controller: johnylol
Contents

C++

## Work

 doublework( double in_heat double out_heat int cycle )[inline]
According to Thermodynamics second law, a thermal machine works in cycles receiving and losing heat and receiving or doing work. (Act as a machine or refrigerator)

$Q_{1}&space;-&space;Q_{2}&space;=&space;W$

$Q_{1}&space;~~&space;is&space;~the~&space;incoming~&space;heat\par&space;&space;Q_{2}&space;~~&space;is~&space;the~&space;lost~&space;heat\par&space;&space;W&space;~~&space;is~&space;the~&space;work~&space;done~/~received$

### Example 1

The work done by a machine receiving 10J of heat and losing 4J to ambient, with cycle in clockwise direction
`printf("%d",work(10,4,1));`
Output: 6
`Output: 6`

### Note

Input for cycle must be -1 or 1 (counter-clockwise and clockwise), if a value different from those is inputted, the function will return 0.

### Parameters

 in_heat The incoming heat (Any value) out_heat The lost heat to ambient(Any value) cycle The cycle direction ( 1 for clockwise, -1 for counter-clockwise )

### Returns

The work done by the machine

### Authors

Johny Void (November 2008)
##### Source Code

Source code is available when you agree to a GP Licence.

Not a member, then Register with CodeCogs. Already a Member, then Login.