# Cloudy Troubleshooting

Actors:

• Cloud: Service provider delivering an application over the internet.
• Client: Business using the Cloud
• Telco: Service provider operating part of the network infrastructure connecting them.
• elkement: Somebody who always ends up playing intermediary.

~

Client: Cloud logs us off ever so often! We can’t work like this!

elkement: Cloud, what timeouts do you use? Client was only idle for a short break and is logged off.

Cloud: Must be something about your infrastructure – we set the timeout to 1 hour.

Client: It’s becoming worse – Cloud logs us off every few minutes even we are in the middle of working.

[elkement does a quick test. Yes, it is true.]

elkement: Cloud, what’s going on? Any known issue?

Cloud: No issue in our side. We have thousands of happy clients online. If we’d have issues, our inboxes would be on fire.

[elkement does more tests. Different computers at Client. Different logon users. Different Client offices. Different speeds of internet connections. Computers at elkement office.]

elkement: It is difficult to reproduce. It seems like it works well for some computers or some locations for some time. But Cloud – we did not have any issues of that kind in the last year. This year the troubles started.

Cloud: The timing of our app is sensitive: If network cards in your computers turn on power saving that might appear as a disconnect to us.

[elkement learns what she never wanted to know about various power saving settings. To no avail.]

Cloud: What about your bandwidth?… Well, that’s really slow. If all people in the office are using that connection we can totally understand why our app sees your users disappearing.

[elkement on a warpath: Tracking down each application eating bandwidth. Learning what she never wanted to know about tuning the background apps, tracking down processes.]

elkement: Cloud, I’ve throttled everything. I am the only person using Clients’ computers late at night, and I still encounter these issues.

Cloud: Upgrade the internet connection! Our protocol might choke on a hardly noticeable outage.

[elkement has to agree. The late-night tests were done over a remote connections; so measurement may impact results, as in quantum physics.]

Client: Telco, we buy more internet!

[Telco installs more internet, elkement measures speed. Yeah, fast!]

Client: Nothing has changed, Clouds still kicks us out every few minutes.

elkement: Cloud, I need to badger you again….

Cloud: Check the power saving settings of your firewalls, switches, routers. Again, you are the only one reporting such problems.

[The router is a blackbox operated by Telco]

elkement: Telco, does the router use any power saving features? Could you turn that off?

Telco: No we don’t use any power saving at all.

[elkement dreams up conspiracy theories: Sometimes performance seems to degrade after business hours. Cloud running backup jobs? Telco’s lines clogged by private users streaming movies? But sometimes it’s working well even in the location with the crappiest internet connection.]

elkement: Telco, we see this weird issue. It’s either Cloud, Client’s infrastructure, or anything in between, e.g. you. Any known issues?

Telco: No, but [proposal of test that would be difficult to do]. Or send us a Wireshark trace.

elkement: … which is what I planned to do anyway…

[elkement on a warpath 2: Sniffing, tracing every process. Turning off all background stuff. Looking at every packet in the trace. Getting to the level where there are no other packets in between the stream of messages between Client’s computers and Cloud’s servers.]

elkement: Cloud, I tracked it down. This is not a timeout. Look at the trace: Server and client communicating nicely, textbook three-way handshake, server says FIN! And no other packet in the way!

Cloud: Try to connect to a specific server of us.

elkement: No – erratic as ever. Sometimes we are logged off, sometimes it works with crappy internet. Note that Client could work during vacation last summer with supper shaky wireless connections.

[Lots of small changes and tests by elkement and Cloud. No solution yet, but the collaboration is seamless. No politics and finger-pointing who to blame – just work. The thing that keeps you happy as a netadmin / sysadmin in stressful times.]

elkement: Client, there is another interface which has less features. I am going to test it…

[elkement: Conspiracy theory about protocols. More night-time testing].

elkement: Client, Other Interface has the same problems.

[elkement on a warpath 3: Testing again with all possible combinations of computers, clients, locations, internet connections. Suddenly a pattern emerges…]

elkement: I see something!! Cloud, I believe it’s user-dependent. Users X and Y are logged off all the time while A and B aren’t.

[elkement scratches head: Why was this so difficult to see? Tests were not that unambiguous until now!]

Cloud: We’ve created a replacement user – please test.

elkement: Yes – New User works reliably all the time! 🙂

Client: It works –  we are not thrown off in the middle of work anymore!

Cloud: Seems that something about the user on our servers is broken – never happened before…

elkement: But wait 😦 it’s not totally OK: Now logged off after 15 minutes of inactivity? But never mind – at least not as bad as logged off every 2 minutes in the middle of some work.

Cloud: Yeah, that could happen – an issue with Add-On Product. But only if your app looks idle to our servers!

elkement: But didn’t you tell us that every timeout ever is no less than 1 hour?

Cloud: No – that 1 hour was another timeout …

elkement: Wow – classic misunderstanding! That’s why it is was so difficult to spot the pattern. So we had two completely different problems, but both looked like unwanted logoffs after a brief period, and at the beginning both weren’t totally reproducible.

[elkement’s theory validated again: If anything qualifies elkement for such stuff at all it was experience in the applied physics lab – tracking down the impact of temperature, pressure and 1000 other parameters on the electrical properties of superconductors… and trying to tell artifacts from reproducible behavior.]

~

# Logging Fun with UVR16x2: Photovoltaic Generator – Modbus – CAN Bus

The Data Kraken wants to grow new tentacles.

I am playing with the CMI – Control and Monitoring Interface – the logger / ‘ethernet gateway’ connected to our control units (UVR1611, UVR16x2) via CAN bus. The CMI has become a little Data Kraken itself: Inputs and outputs can be created for CAN bus and Modbus, and data from most CAN devices can also be logged via JSON.

Are these features useful to integrate the datalogger of our photovoltaics inverter – Fronius Symo 4.5-3-M? I am now logging data to an USB stick and feed the CSV files to the SQL Server Data Kraken. The USB logger’s logging interval is 5 minutes whereas Modbus TCP allows for logging every few seconds. The inverter has built-in energy management features, but it can only ‘signal’ via a relay which also requires proper wiring. Modbus TCP, on the other hand, could use the existing WLAN connection of the inverter and the control unit could do something smarter with the sensor reading of the output power.

My motivation is to test if you – as an UVR16x2 user – can re-use a logger you  already have – the CMI – as much as possible, avoiding the need to run another ‘logging server’ all the time (Also my SQL Server is for analysis, not for real-time logging). I know that there are many open source Modbus clients available and that it is easy to write a Python script.

Activate Modbus on the inverter: I prefer floating numbers to integers plus a scaling factor, and I turn off the option to make changes via Modbus:

Modbus settings, Fronius Datalogger, inverter’s local web server. 502 is the TCO standard port. The alternative to floating numbers is integers plus a varying scaling factor (SF), to be found in another register.

Check Fronius documentation of its Modbus registers: The document is currently available here. There are different sets of registers related to the inverter or associated with one string of PV panels:

PDF p.97, Common Inverter Model. For logging AC output power you need:  Address 40092, type of register 3 (read and hold), datatype float32 (‘corresponds’ to two 16bit integer register, thus size 2).

The address to be configured on a Modbus client is smaller than this address by 1 – so 40091 needs to be set to log AC power.

Using these configuration parameters an analog Modbus Input is added at the CMI. The signal is ‘digital’ – but in field-bus-language everything that is not a single bit – 0/1 – seems to be ‘analog’.

Modbus input at the CMI. Input value:  32bits read from the bus interpreted as an integer. Actual value: Integer part of the ‘true value’ = the 32bits interpreted as 32-bit float.

Yes, I checked the network trace 😉 as the byte order dropdown menu confused me: According to the Modbus protocol specification Big Endian is required, not an option.

Factors and data types: Only integer values are understood by CAN devices. Decimal places might be indicated by a scaling factor. The PV power value in Watt has enough significant digits; so the integer part of the float number is fine. But for current in Ampere – typically about 15A maximum – a Factor of 10 would be better. It would not have helped to select int + scaling factor at the inverter: The scaling factor would be stored in a second register, there is a different factor for every parameter, and you cannot configure another ‘scaling factor register’ per input at the CMI. Theoretically you could log the scaling factor separately and re-scale the value in a custom application – but then I would use a separate, custom logger.

In any case, if you screw this up, you see non-sensible numbers of the CAN bus: Slowly evolving positive values – like PV power on a sunny day – are displayed as wild variations of signed integers between -32000 and 32000 😉

Where are the ‘logged’ data? The CMI is first and foremost the data logger for the control units. The CMI does not immediately store the data from Modbus inputs in a  local ‘logging database’. All I have achieved so far is to display the value on the Settings page. The CMI can only log values from the CAN bus or DL bus. So we need an…

… Analog CAN Output at the CMI:

The CMI has the default node number 56 on the CAN bus. Other CAN devices on the bus can query it for this parameter by specifying node 56 and output no 1.

These are the devices on our CAN bus:

CAN bus displayed on the CMI’s website. UVR1611 and UVR16x2 controllers can be managed by clicking their icons – which brings up a web page that resembles the controller’s local display.

The CMI’s Logging page looks tempting – can we simply select the CMI itself as a CAN logging source – CAN 56?

Configuration of the devices the CMI logs data from, via CAN bus. CAN 1 – UVR1611, CAN 2 – UVR16x3, CAN 41 – energy meter CAN-EZ.

Nothing stops you from selecting CAN 56 in this dropdown menu, but it does not end well:

CAN error message displayed at the logger CMI when you try to configure the CMI also as a logging source.

We need a round-trip: Data needs to be sent to a supported device first – one of the controllers on the CAN bus. We need an…

… Analog CAN input / network variable at the UVR16x2:

Configuration of a CAN input at the controller UVR16x2 (via CMI’s web interface to the controller).

The value of AC power is displayed as integer without scaling. Had a factor of 10 been used at the Modbus input it would be ‘corrected’ here, using the Unit called dimensionless,1.

Values received by the controller UVR16x2 over CAN bus.

Result of all this: UVR16x2 knows PV power and can use it do magic smart things when controlling the heat pump. On the other hand, CMI can log this value – in the same way it logs all other sensor readings.

Log files are retrieved by Winsol, the free logging software for the CMI …

Logged visualized with Winsol. Logfiles are downloaded from the CMI on the internal LAN or via Technsche Alternative’s web portal. PV power (PV.Leistung.Watt) is displayed together with global radiation on a vertical plane (GBS, at the solar/air collector for the theat pump), ambient temperature (red), temperature of solar/air collector (orange)

… or logging is configured at the web portal cmi.ta.co.at …

Configuration of logging at cmi.ta.co.at: Supported loggers are UVR1611 and UVR16x2. Values to be logged are selected from all direct inputs / outputs / functions and from CAN network inputs and outputs.

… and data can be viewed online:

Data visualized at cmi.ta.co.at. Data logged via CAN are sent from the CMI to the web portal.

Using this kind of logging for all values the inverter provides would be costly: It’s not just a column you add to a log file, but you occupy one of the limited inputs and outputs at the CMI and the controller. If you really need to know the voltage between phase 1 and 2 or apparent power you better stick with the USB file or use a separate Modbus logger like a Rasbperry Pi. This project is great and documented very well – data acqusition from a Symo inverter using Python plus a web front end.

Sending Modbus data back and forth from the CMI to UVR controllers is only worth the efforts if you need them for control, not for ‘nice-to-have’ logging.

# Can the Efficiency Be Greater Than One?

This is one of the perennial top search terms for this blog.

Anticlimactic answer: Yes, because input and output are determined also by economics, not only by physics.

Often readers search for the efficiency of a refrigerator. Its efficiency, the ratio of output and input energies, is greater than 1 because the ambient energy is free. System’s operators are interested in the money they pay the utility, in relation to the resulting energy for cooling.

If you use the same thermodynamic machine either as a refrigerator or as a heat pump, efficiencies differ: The same input energy drives the compressor, but the relevant output energy is either the energy released to the ‘hot side’ at the condenser or the energy used for evaporating the refrigerant at the ‘cool side’:

The same machine / cycle is used as a heat pump for heating (left) or a refrigerator or AC for cooling (right). (This should just highlight the principles and does not include any hydraulic details, losses etc. related to detailed differences between refrigerators / ACs and heat pumps.)

For photovoltaic panels the definition has sort of the opposite bias: The sun does not send a bill – as PV installers say in their company’s slogan – but the free solar ambient energy is considered, and thus their efficiency is ‘only’ ~20%.

Half of our generator, now operational for three years: 10 panels, oriented south-east, 265W each, efficiency 16%. (The other 8 panels are oriented south-west).

When systems are combined, you can invent all kinds of efficiencies, depending on system boundaries. If PV panels are ‘included’ in a heat pump system (calculation-wise) the nominal electrical input energy becomes lower. If solar thermal collectors are added to any heating system, the electrical or fossil fuel input decreases.

Output energy may refer to energy measured directly at the outlet of the heat pump or boiler. But it might also mean the energy delivered to the heating circuits – after the thermal losses of a buffer tank have been accounted for. But not 100% of these losses are really lost, if the buffer tank is located in the house.

I’ve seen many different definitions in regulations and related software tools, and you find articles about how to game interpret these guidelines to your advantage. Tools and standards also make arbitrary assumptions about storage tank losses, hysteresis parameter and the like – factors that might be critical for efficiency.

Then there are scaling effects: When the design heat loads of two houses differ by a factor of 2, and the smaller house would use a scaled down heat pump (hypothetically providing 50% output power at the same efficiency), the smaller system’s efficiency is likely to be a bit lower. Auxiliary consumers of electricity – like heating circuit pumps or control systems – will not be perfectly scalable. But the smaller the required output energy is, the better it can be aligned with solar energy usage and storage by a ‘smart’ system – and this might outweigh the additional energy needed for ‘smartness’. Perhaps intermittent negative market prices of electricity could be leveraged.

Definitions of efficiency are also culture-specific, tailored to an academic discipline or industry sector. There are different but remotely related concepts of rating how useful a source of energy is: Gibbs Free Energy is the maximum work a system can deliver, given that pressure and temperature do not change during the process considered – for example in a chemical reaction. On the other hand, Exergy is the useful ‘available’ energy ‘contained’ in a (part of a) system: Sources of energy and heat are rated; e.g. heat energy is only mechanically useful up to the maximum efficiency of an ideal Carnot process. Thus exergy depends on the temperature of the environment where waste heat ends up. The exergy efficiency of a Carnot process is 1, as waste heat is already factored in. On the other hand, the fuel used to drive the process may or may not be included and it may or may not be considered pure exergy – if it is, energy and exergy efficiency would be the same again. If heat energy flows from the hot to the cold part of a system in a heat exchanger, no energy is lost – but exergy is.

You could also extend the system’s boundary spatially and on the time axis: Include investment costs or the cost of harm done to the environment. Consider the primary fuel / energy / exergy to ‘generate’ electricity: If a thermal power plant has 40% efficiency then the heat pump’s efficiency needs to be at least 2,5 to ‘compensate’ for that.

In summary, ‘efficiency’ is the ratio of an output and an input energy, and the definitions may be rather arbitrary as and these energies are determined by a ‘sampling’  time, system boundaries, and additional ‘ratings’.

It is the the duty of a Webmaster to allocate URIs which you will be able to stand by in 2 years, in 20 years, in 200 years. This needs thought, and organization, and commitment. (https://www.w3.org/Provider/Style/URI)

Joel Spolsky did it:

I’m bending over backwards not to create “linkrot” — all old links to Joel on Software stories have been replaced with redirects, so they should still work. (November 2001)

More than once:

I owe a huge debt of gratitude to [several people] for weeks of hard work on creating this almost perfect port of 16 years of cruft, preserving over 1000 links with redirects… (December 2016).

Most of the outgoing URLs linked by Joel of Software have rotted, with some notable exceptions: Jakob Nielsen’s URLs do still work, so they live what he preached – in 1998:

… linkrot contributes to dissolving the very fabric of the Web: there is a looming danger that the Web will stop being an interconnected universal hypertext and turn into a set of isolated info-islands. Anything that reduces the prevalence and usefulness of cross-site linking is a direct attack on the founding principle of the Web.

No excuses if you are not Spolsky- or Nielsen-famous – I did it too, several times. In 2015 I rewrote the application for my websites from scratch and redirected every single .asp URL to a new friendly URL at a new subdomain.

I am obsessed with keeping old URLs working. I don’t like it if websites are migrated to a new content management system, changing all the URLs.

I checked all that again when migrating to HTTPS last year.

So I am a typical nitpicking dinosaur, waxing nostalgic about the time when web pages were still pages, and when Hyperlinks Subverted Hierarchy. When browsers were not yet running an OS written in Javascript and hogging 70% of your CPU for ad-tracking or crypto-mining.

The dinosaur is grumpy when it has to fix outgoing URLs on this blog. So. Many. Times. Like every second time I test a URL that shows up in my WordPress statistics as clicked, it 404s. Then I try to find equivalent content on the same site if the domain does still exist – and had not been orphaned and hijacked by malvertizers. If I am not successful I link to a version of this content on web.archive.org, track down the content owner’s new site, or find similar content elsewhere.

My heart breaks when I see that it’s specifically the interesting, unusual content that users want to follow from here – like hard-to-find historical information on how to build a heat pump from clay tablets and straw. My heart breaks even more when the technical content on the target site gets dumbed down more and more with every URL breaking website overhaul. But OK – you now have this terrific header image with a happy-people-at-work stock photo that covers all my desktop so that I have to scroll for anything, and the dumbed down content is shown in boxes that pop up and whirl – totally responsive, though clunky on a desktop computer.

And, yes: I totally know that site owners don’t own me anything. Just because you hosted that rare and interesting content for the last 10 years does not mean you have to do that forever.

But you marketing ninjas and website wranglers neglected an important point: We live in the age of silly gamification that makes 1990s link building pale: I like yours and you like mine. Buy Followers. Every time I read a puffed up Case Study for a project I was familiar with as an insider, I was laughing for minutes and then checked if it was not satire.

In this era of fake word-of-mouth marketing you get incoming links. People say something thoughtful, maybe even nice about you just because they found your content interesting and worth linking not because you play silly games of reciprocating. The most valuable links are set by people you don’t know and who did not anticipate you will ever notice their link. As Nassim Taleb says: Virtue is what you do when nobody is looking.

I would go to great lengths not to break links to my sites in those obscure DIY forums whose posts are hardly indexed by search engines. At least I would make a half-hearted attempt at redirecting to a custom 404 page that explains where you might the moved content. Or just keep the domain name intact. Which of course means not to register a catchy domain name for every product in the first place. Which I consider bad practice anyway – training users to fall for phishing, by getting them used to jumping from one weird but legit domain to another.

And, no, I don’t blame you personally, poor stressed out web admin who had to get the new site up and running before April 1st, because suits in your company said the world would come to an end otherwise. I just think that our internet culture that embraces natural linkrot so easily is as broken as the links.

I tag this as Rant, but it is a Plea: I beg you, I implore you to invest just a tiny part of the time, budget and efforts you allocated to Making the Experience of Your Website Better to making some attempt at keeping your URLs intact. They are actually valuable for others – something you should be proud of.

# Consequences of the Second Law of Thermodynamics

Why a Carnot process using a Van der Waals gas – or other fluid with uncommon equation of state – also runs at Carnot’s efficiency.

Textbooks often refer to an ideal gas when introducing Carnot’s cycle – it’s easy to calculate heat energies and work in this case. Perhaps this might imply that not only must the engine be ‘ideal’ – reversible – but also the working fluid has to be ‘ideal’ in some sense? No, it does not, as explicitly shown in this paper: The Carnot cycle with the Van der Waals equation of state.

In this post I am considering a class of substances which is more general than the Van der Waals gas, and I come to the same conclusion. Unsurprisingly. You only need to imagine Carnot’s cycle in a temperature-entropy (T-S) diagram: The process is represented by a rectangle for both ideal and Van der Waals gas. Heat energies and work needed to calculate efficiency can be read off, and the – universal – maximum efficiency can be calculated without integrating over potentially wiggly pressure-volume curves.

But the fact that we can use the T-S diagram or the fact that the concept of entropy makes sense is a consequence of the Second Law of Thermodynamics. It also states, that a Perpetuum Mobile of the Second Kind is not possible: You cannot build a machine that converts 100% of the heat energy in a temperature bath to mechanical energy. This statement sounds philosophical but it puts constraints on the way real materials can behave, and I think these constraints on the relations between physical properties are stronger than one might intuitively expect. If you pick an equation of state – the pressure as a function of volume and temperature, like the wavy Van der Waals curve, the behavior of specific heat is locked in. In a sense the functions describing the material’s properties have to conspire just in the right way to yield the simple rectangle in the T-S plane.

The efficiency of a perfectly reversible thermodynamic engine (converting heat to mechanical energy) has a maximum well below 100%. If the machine uses two temperature baths with constant temperatures $T_1$ and $T_2$, the heat energies exchanged between machine and baths $Q_1$ and $Q_2$ for an ideal reversible process are related by:

$\frac{Q_1}{T_1} + \frac{Q_2}{T_2} = 0$

(I wrote on the related proof by contradiction before – avoiding to use the notion of entropy at all costs). This ideal process and this ideal efficiency could also be used to actually define the thermodynamic temperature (as it emerges from statistical considerations; I have followed Landau and Lifshitz’s arguments in this post on statistical mechanics and entropy)

Any thermodynamic process using any type of substance can be imagined as being a combination of lots of Carnot engines operating between lots of temperature baths at different temperatures (see e.g. Feynman’s lecture). The area in the p-V diagram that is traced out in a cyclic process is being split into infinitely many Carnot processes. For each process small heat energies $\delta Q$ are transferred. Summing up the contributions of all processes only the loop at the edge remains and thus …

$\oint \frac{\delta Q}{T}$

which means that for a reversible process $\frac{\delta Q}{T}$ actually has to be a total differential of a function $dS$ … that is called entropy. This argument used in thermodynamics textbooks is kind of a ‘reverse’ argument to the statistical one – which introduces  ‘entropy first’ and ‘temperature second’.

What I  need in the following derivations are the relations between differentials that represent a version of First and Second Law:

The First Law of Thermodynamics states that heat is a form of energy, so

$dE = \delta Q - pdV$

The minus is due to the fact that energy is increased on increasing volume (There might be other thermodynamics degrees of freedom like the magnetization of a magnetic substance – so other pairs of variables like p and V).

Inserting the definition of entropy S as the total differential we obtain this relation …

$dS = \frac{dE + pdV}{T}$

… from which follow lots of relations between thermodynamic properties!

I will derive one the them to show how strong the constraints are that the Second Law actually imposes on the physical properties of materials: When the so-called equation of state is given – the pressure as a function of volume and temperature p(V,T) – then you also know something about its specific heat. For an ideal gas pV is simply a constant times temperature.

S is a function of the state, so picking independent variables V and T entropy’s total differential is:

$dS = (\frac{\partial S}{\partial T})_V dT + (\frac{\partial S}{\partial V})_T dV$

On the other hand, from the definition of entropy / the combination of 1st and 2nd Law given above it follows that

$dS = \frac{1}{T} \left \{ (\frac{\partial E }{\partial T})_V dT + \left [ (\frac{\partial E }{\partial V})_T + p \right ]dV \right \}$

Comparing the coefficients of dT and dV the partial derivatives of entropy with respect to volume and temperature can be expressed as functions of energy and pressure. The order of partial derivation does not matter:

$\left[\frac{\partial}{\partial V}\left(\frac{\partial S}{\partial T}\right)_V \right]_T = \left[\frac{\partial}{\partial T}\left(\frac{\partial S}{\partial V}\right)_T \right]_V$

Thus differentiating each derivative of S once more with respect to the other variable yields:

$[ \frac{\partial}{\partial V} \frac{1}{T} (\frac{\partial E }{\partial T})_V ]_T = [ \frac{\partial}{\partial T} \frac{1}{T} \left [ (\frac{\partial E }{\partial V})_T + p \right ] ]_V$

What I actually want, is a result for the specific heat: $(\frac{\partial E }{\partial T})_V$ – the energy you need to put in per degree Kelvin to heat up a substance at constant volume, usually called $C_v$. I keep going, hoping that something like this derivative will show up. The mixed derivative $\frac{1}{T} \frac{\partial^2 E}{\partial V \partial T}$ shows up on both sides of the equation, and these terms cancel each other. Collecting the remaining terms:

$0 = -\frac{1}{T^2} (\frac{\partial E }{\partial V})_T -\frac{1}{T^2} p + \frac{1}{T}(\frac{\partial p}{\partial T})_V$

Multiplying by $T^2$ and re-arranging …

$(\frac{\partial E }{\partial V})_T = -p +T(\frac{\partial p }{\partial T})_V = T^2(\frac{\partial}{\partial T}\frac{p}{T})_V$

Again, noting that the order of derivations does not matter, we can use this result to check if the specific heat for constant volume – $C_v = (\frac{\partial E }{\partial T})_V$ – depends on volume:

$(\frac{\partial C_V}{\partial V})_T = \frac{\partial}{\partial V}[(\frac{\partial E }{\partial T})_V]_T = \frac{\partial}{\partial T}[(\frac{\partial E }{\partial V})_T]_V$

But we know the last partial derivative already and insert the expression derived before – a function that is fully determined by the equation of state p(V,T):

$(\frac{\partial C_V}{\partial V})_T= \frac{\partial}{\partial T}[(-p +T(\frac{\partial p }{\partial T})_V)]_V = -(\frac{\partial p}{\partial T})_V + (\frac{\partial p}{\partial T})_V + T(\frac{\partial^2 p}{\partial T^2})_V = T(\frac{\partial^2 p}{\partial T^2})_V$

So if the pressure depends e.g. only linearly on temperature the second derivative re T is zero and $C_v$ does not depend on volume but only on temperature. The equation of state says something about specific heat.

The idealized Carnot process contains four distinct steps. In order to calculate efficiency for a certain machine and working fluid, you need to calculate the heat energies exchanged between machine and bath on each of these steps. Two steps are adiabatic – the machine is thermally insulated, thus no heat is exchanged. The other steps are isothermal, run at constant temperature – only these steps need to be considered to calculate the heat energies denoted $Q_1$ and $Q_2$:

Carnot process for an ideal gas: A-B: Isothermal expansion, B-C: Adiabatic expansion, C-D: isothermal compression, D-A: adiabatic compression. (Wikimedia, public domain, see link for details).

I am using the First Law again and insert the result for $(\frac{\partial E}{\partial V})_T$ which was obtained from the combination of both Laws – the goal is to express heat energy as a function of pressure and specific heat:

$\delta Q= dE + p(T,V)dV = (\frac{\partial E}{\partial T})_V dT + (\frac{\partial E}{\partial V})_T dV + p(T,V)dV$
$= C_V(T,V) dT + [-p +T(\frac{\partial p(T,V)}{\partial T})_V] dV + p(T,V)dV = C_V(T,V)dT + T(\frac{\partial p(T,V)}{\partial T})_V dV$

Heat Q is not a function of the state defined by V and T – that’s why the incomplete differential δQ is denoted by the Greek δ. The change in heat energy depends on how exactly you get from one state to another. But we know what the process should be in this case: It is isothermal, therefore dT is zero and heat energy is obtained by integrating over volume only.

We need p as a function of V and T. The equation of state for ideal gas says that pV is proportional to temperature. I am now considering a more general equation of state of the form …

$p = f(V)T + g(V)$

The Van der Waals equation of state takes into account that particles in the gas interact with each other and that they have a finite volume (Switching units, from capital volume V [m3] to small v [m3/kg] to use gas constant R [kJ/kgK] rather than absolute numbers of particles and to use the more common representation – so comparing to \$latex pv = RT) :

$p = \frac{RT}{v - b} - \frac{a}{v^2}$

This equation also matches the general pattern.

Van der Waals isotherms (curves of constant temperature) in the p-V plane: Depending on temperature, the functions show a more or less pronounced ‘wave’ with a maximum and a minimum, in contrast to the ideal-gas-like hyperbolas (p = RT/v) for high temperatures. (By Andrea insinga, Wikimedia, for details see link.)

In both cases pressure depends only linearly on temperature, and so $(\frac{\partial C_V}{\partial V})_T$ is 0. Thus specific heat does not depend on volume, and I want to stress that this is a consequence of the fundamental Laws and the p(T,V) equation of state, not an arbitrary, additional assumption about this substance.

The isothermal heat energies are thus given by the following, integrating $T(\frac{\partial p(T,V)}{\partial T})_V = T f(V)$ over V:

$Q_1 = T_1 \int_{V_A}^{V_B} f(V) dV$
$Q_2 = T_2 \int_{V_C}^{V_D} f(V) dV$

(So if $Q_1$ is positive, $Q_2$ has to be negative.)

In the adiabatic processes δQ is zero, thus

$C_V(T,V)dT = -T(\frac{\partial p(T,V)}{\partial T})_V dV = -T f(V) dV$
$\int \frac{C_V(T,V)}{T}dT = \int -f(V) dV$

This is useful as we already know that specific heat only depends on temperature for the class of substances considered, so for each adiabatic process…

$\int_{T_1}^{T_2} \frac{C_V(T)}{T}dT = \int_{V_B}^{V_C} -f(V) dV$
$\int_{T_2}^{T_1} \frac{C_V(T)}{T}dT = \int_{V_D}^{V_A} -f(V) dV$

Adding these equations, the two integrals over temperature cancel and

$\int_{V_B}^{V_C} f(V) = -\int_{V_D}^{V_A} f(V) dV$

Carnot’s efficiency is work – the difference of the absolute values of the two heat energies – over the heat energy invested at higher temperature $T_1$:

$\eta = \frac {Q_1 - \left | Q_2 \right |}{Q_1} = 1 - \frac {\left | Q_2 \right |}{Q_1}$
$\eta = 1 - \frac {T_2}{T_1} \frac {\left | \int_{V_C}^{V_D} f(V) dV \right |}{\int_{V_A}^{V_B} f(V) dV}$

The integral from A to B can replaced by an integral over the alternative path A-D-C-B (as the integral over the closed path is zero for a reversible process) and

$\int_{A}^{B} = \int_{A}^{D} + \int_{D}^{C}+ \int_{C}^{B}$

But the relation between the B-C and A-D integral derived from considering the adiabatic processes is equivalent to

$-\int_{C}^{B} = \int_{B}^{C} = - \int_{D}^{A} = \int_{A}^{D}$

Thus two terms in the alternative integral cancel and

$\int_{A}^{B} = \int_{D}^{C}$

… and finally the integrals in the efficiency cancel. What remains is Carnot’s efficiency:

$\eta = \frac {T_1 - T_2}{T_1}$

But what if the equation of state is more complex and specific heat would depends also on volume?

Yet another way to state the Second Law is to say that the efficiencies of all reversible processes has to be equal and equal to Carnot’s efficiency. Otherwise you get into a thicket of contradictions (as I highlighted here). The authors of the VdW paper say they are able to prove this for infinitesimal cycles which sounds of course plausible: As mentioned at the beginning, splitting up any reversible process into many processes that use only a tiny part of the co-ordinate space is the ‘standard textbook procedure’ (see e.g. Feynman’s lecture, especially figure 44-10).

But you could immediately see it without calculating anything by having a look at the process in a T-S diagram instead of the p-V representation. A process made up of two isothermal and two adiabatic processes is by definition (of entropy, see above) a rectangle no matter what the equation of state of the working substance is. Heat energy and work can easily been read off as the rectangles between or below the straight lines:

Carnot process displayed in the entropy-temperature plane. No matter if the working fluid is an ideal gas following the pv = RT equation of state or if it is a Van der Waals gas that may show a ‘wave’ with a maximum and a minimum in a p-V diagram – in the T-S diagram all of this will look like rectangles and thus exhibit the maximum (Carnot’s) efficiency.

In the p-V diagram one might see curves of weird shape, but when calculating the relation between entropy and temperature the weirdness of the dependencies of specific heat and pressure of V and T compensate for each other. They are related because of the differential relation implied by the 2nd Law.

It is not a paradox – it is a straight-forward relation between a heat pump system’s key data:

The lower a heat pump’s performance factor is, the smaller the source can be built.

I would not write this post, hadn’t I found a version of this statement with a positive twist  used in an advert!

In this post I consider a heat pump a blackbox that converts input energy into output heat energy – it ‘multiplies’ energy by a performance factor. A traditional mechanical heat pump uses electrical input energy to drive a mechanical compressor. The uncommon Rotation Heat Pump utilizes the pressure gradient created by centrifugal forces and thus again by electrical power.

But a pressure difference can also be maintained by adsorption/desorption processes or by changing the amount of one fluid dissolved in another; Einstein’s famous refrigerator uses a more complex combination of such dissolution/evaporation processes. Evaporation or desorption can be directly driven by heat: A gas heat pump thus ‘multiplies’ the energy from burning natural gas (and in addition, a heat pump and a gas boiler can be combined in one unit).

The overall performance factor of a gas heat pump – kWh heating energy out over kWh gas in – is about 1,5 – 2. This is lower than 4 – 5 available with mechanical compressors. But the assessment depends on the costs of kWh gas versus kWh electrical energy: If gas is four times cheaper (which nearly is the case in Germany) than burning natural gas in a traditional boiler without any ‘heat pump multiplication’, then the classical boiler can be more economical than using a heat pump with an electrical compressor. If gas is ‘only’ two times as cheap, then a gas heat pump with an overall performance number of ‘only’ 2 will still beat an electrical heat pump with a performance factor of 4.

While the gas heat pump may have its merits under certain market conditions, its performance number is low: For one kWh of gas you only get two kWh of heating energy. This  means you only need to provide one kWh of ‘ambient’ energy from your source – geothermal, water, or air. If the performance factor of an electrical heat pump is 4, you multiply each kWh of input energy by 4. But the heat source has to be able to supply the required 3 kWh. This is the whole ‘paradox’: The better the heat pump’s performance is in terms of heating energy over input energy, the more energy has to be released by a properly designed heat source, like ground loops sufficiently large, a ground-water well providing sufficient flow-rate, an air heat pump’s ventilator powerful enough, or our combination of a big enough solar/air collector plus water tank.

Illustration of the ‘heat source paradox’: The lower the performance number (ratio of output and input energy), the lower is the required ambient energy that has to be provided by ‘the environment’. The output heating energy in red is the target number that has to be met – it is tied to the building’s design heat load.

If you wish to state it that way, a heat pump with inferior performance characteristics has the ‘advantage’ that the source can be smaller – less pipes to be buried in the ground or a smaller water tank. And in an advert for a gas heat pump I found it spelled out exactly in this way, as a pro argument compared to other heat pumps:

The heat source can be built much smaller – investment costs are lower!

It is not wrong, but it is highly misleading. It is like saying that heating electrically with a resistive heating element – and thus a performance number of 1 – is superior because you do not need to invest in building any source of ambient energy at all.

# Things You Find in Your Hydraulic Schematic

Building an ice storage powered heat pump system is a DIY adventure – for a Leonardo da Vinci of plumbing, electrical engineering, carpentry, masonry, and computer technology.

But that holistic approach is already demonstrated clearly in our hydraulic schematics. Actually, here it is even more daring and bold:

There is Plutonium – Pu – everywhere in the heating circuit and the brine circuit …

I can’t tell if this is a hazard or if it boosts energy harvest. But I was not surprised – given that Doc Emmett Brown is our hero.

Maybe we see the impact of contamination already: How should I explain the mutated butterflies with three wings otherwise? After all, they are even tagged with M

Our default backup heating system is … Facebook Messenger!

So the big internet companies are already delivering heating-as-a-service-from-the-cloud!

But what the hell is the tennis ball needed for?