minetest-mods / technic

Technic mod for Minetest
Other
145 stars 155 forks source link

Electrical Engineering #92

Closed Xiong closed 9 years ago

Xiong commented 10 years ago

I've enjoyed playing on a server called King Arthur's. It's distinguished primarily by a theme -- buildings not conforming to the theme are forbidden, although I don't know who decides or on what basis. And although the server has some shortcomings, it has a great look to it. Everything works together, because of the unifying theme.

Now when I first looked at 'technic', I thought it had a theme: engineering, specifically electrical power engineering. Boy, was I ever wrong! I decided quickly that nobody involved in the development had ever touched a soldering iron -- certainly never held a multimeter in hand.

We have to work within the limitations of the Minetest engine, which probably cramps our ability to mimic the laws of electrodynamics. But we do not have to ignore them completely. A hallmark of a good model is that it reflects its prototype, at least superficially. An HO-gauge model steam locomotive does not actually have a tiny steam engine inside, let alone a tiny engineer and a tiny little stoker shoveling tiny lumps of coal into the tiny firebox. But we do shape the plastic or tin into the shape of a real prototype steam locomotive; and we paint it black; and we weather it so it looks real. We stick an electric motor inside the shell and we gear it to the wheels. It's a model, not a simulation. We can do as well with 'technic', I think.

At this point I expect a rash of objections, all based largely on imagined limitations of the core engine. I say that we can overcome at least half of them; and when we run out of room, we can fake it. At least we can give the appearance of a system that acts as its prototype would.

I expect another raft of objections that all tend toward "this is just a game, so who cares how it works". I invite such people to work on my proposed 'unicorn' mod instead, where candy-cane zepplins are driven by rainbow power and fairy dust.

Let me explain how to go about this:

Electricity does not come in "electrical units". It comes in the units of volts, amps, watts, and watt-hours. (Yes, there are other equivalent units.) These quantities are strictly related:

P = EI

... where P (power in watts) is equal to E (voltage in volts) times I (current in amps). So a 1000 watt hair dryer running on 117 VAC must be consuming a bit more than 8.5 amps.

And:

Wh = Pt

... that is, energy (in watt-hours) is equal to power (in watts) times elapsed time (in hours). If a power level of 10 watts is sustained for 8 hours then that is a total amount of energy equal to 80 watt-hours. Energy is not power! The conventional unit of energy in this context is the kilowatt-hour, kWh.

Another rule is pretty simple, the First Law of Thermodynamics: You can't get something for nothing. You can never take more energy out of a system than you put into it. The Second Law is even harsher: You can't break even. The Third Law is worse still: You can't quit the game.

To model this well in 'technic' does not require a major tearing-up; it only requires some desire to be faithful to the prototype. First thing, banish "EU" entirely; this has no meaning. I'll tolerate the terms 'MV', etc. only on condition that they are tied to specific, documented quantities. I'd suggest, reasonably, that LV be 120 VAC; MV, 240 VAC; and HV, 480 VAC. Actually none of these are really high voltage. But then, 230 kV will arc through almost any thickness of rubber, so as long as HV cable is merely double-insulated, we're still making sense.

So now, when we look at a voltage converter -- which is merely a big transformer -- we know how to model it. Since power before loss is constant, we might reasonably hope to get, say, 980 watts out for 1000 watts in. It doesn't matter whether we're going up or down in voltage; wattage will be about the same. The capacity of a transformer is measured in watts; when that capacity is reached, it won't pass any more power. However, it may always pass less.

If we have two machines doing roughly the same job -- say, an LV grinder and an MV grinder -- then they should consume roughly the same amount of power. The MV unit does more, so it consumes more; but not radically so. A big industrial grinder might well eat 40 kW -- that's 40,000 watts. If it's running at anything in the 120-480 volt range, it will require some real thick cabling -- which, fortunately, is just what we have -- cables that appear to be about 20 cm in thickness. But since our grinder fits in a one-meter cube, I have to figure it's a bit smaller. It would not be out of line to call an LV grinder a 10 kW load, an MV, 15 kW.

Now again, I don't insist on anything like strict adherence to real life in batteries. But let's try to look at them honestly. I think we'd like a fully-charged battery box to run at least one machine of its voltage tier overnight. If we take the LV grinder above, that's 12 * 10 = 120 kWh. That's a honking big battery; a Tesla Roadster has a battery rated at 54 kWh. Still, it's within hand-waving range. Considering we're building an LV battery box out of 4 portable batteries, it's a bit of an... overstatement.

The MV battery box, though, is built from 5 LV battery boxes; and can be expected to hold 5 times as much energy, more or less. So should the MV box hold 600 kWh? Note that the fact it operates at the Medium Voltage of 240 V is not the consideration; only that it contains more batteries. We might then expect the HV box to have a capacity of 3000 kWh, and this is kinda lunacy in the Real World. Since construction of such a thing demands quite a bit of resources, though, should the payoff not be great? Oh, yes, fiddle with the numbers, balance the game play. But why not start with numbers that make sense?

I'd actually prefer to consider the batteries arranged in a series-parallel circuit, so that each tier only doubles the capacity of the previous one. So LV box, 120 kWh; MV, 240 kWh; HV, 480 kWh. That's a bit more credible and provides a bit more balanced game play. After downconversion, the HV box might run as many as three MV grinders... for about ten and a half hours.

It should be patently obvious that a hand-held power tool has, internally, a single battery and holds charge at a fixed voltage. So regardless of which box it is charged in, it should consume the same amount of energy, in watt-hours, leaving the box depleted by that much. We can wave away the charging circuitry that allows the same tool to be charged at various source voltages.

Again, I'll gladly wave off any consideration of the fact that batteries hold DC and virtually all industrial machinery consumes AC power. As model railroaders like to say, there's no need to count the rivets on the boiler.

Now let's look at our generators, since batteries only store power. Like machines that consume power, generators generate power and are rated in kWh regardless of the voltage they produce. I can't see the least reason why there should be an MV windmill and an LV water turbine; it makes no sense. Rather, let there be LV and MV versions of both, with the MV version significantly more expensive to craft and capable of producing more power.

For that matter, since only MV units work with pipeworks... is there any reason there should not, automatically, be MV versions of every LV machine? Tell me why not. Should it even be a major task to code them all? It might even be within my limited ability.

Solar power is a sore point with me; it's vicious to produce, as I did, four HV arrays and parts for another. Do the math; that's 1000 doped wafers per array, therefore over 10 full chargings of the alloy furnace, with another 20 full chargings to make the blank wafers. With 5 HV arrays produced, that's.. yes, 150 full chargings, assuming no slip-ups. I suppose I might have used pipeworks to accelerate the process... but my alloy furnaces were busy with wafers, not stainless steel. To start, I had to use LV alloy furnaces. And so it goes. (Please don't say we fixed that already. My point is that I already invested that effort.)

Now the point of solar power, I'd think, is that it works, at least if the sun is out. I put mine on a tower reaching above 130 m, as dictated by the comments cleverly hidden in the code. This worked; although there is much grumbling about how. Certainly I don't consider it an improvement to go up the ladder, disconnect the arrays, and stick them on my roof. I worked hard on that tower and it's a shame to see it go to waste. I don't care what sort of nasty kluge must be worked; solar should work when the sun is out. I should think it a simple thing to check the time of day.

Now we have windmills; and I don't see the point, if they're required to be at a certain distance from the ground to work at all. Should I build my workshop in the air? Or pay a kid to stand up there all day and night? No. Electricity does not stop working when you turn your back. Please do not blame the core devs or weaknesses in the core engine. It's a simple thing to store a complete electrical network, distinct from its nodes, merely as an electrical network; and recalculate the network when something alters the nodes that comprise it. A player has to load the chunk to alter it. I refuse to worry about a guy who builds a castle in the sky, two chunks up from my solar, and manages never to load the chunk the solar is in while he shadows it. There is no need to worry that a bird is going to shit on the solar array when you're not looking... or get caught in a windmill's blades.

As long as we're discussing generation... nuclear reactors should indeed be quite expensive to build; and the time you get out of fueling one should be long. So far, so good. It's my understanding -- not tested yet, thank you -- that damaging one in operation does not actually cause anything significant to happen. A big concern, and a realistic one, is that a reactor melting down will ruin the next-door neighbor's house. But let's show some unrealistic sense and simply kill the player standing next to it -- and, of course, shut down the reactor. Can we at least agree to do that?

Now back to cabling -- by which I mean to include all the forms of connection among parts that generate, consume, and store power. I don't know what's going on now but it doesn't work. Why not? I smell a lack of respect for basic electrical engineering.

First, let's agree to disregard all cable losses, just to simplify the model. Then all connected cables can be treated as a single point. What seems to be confusing everyone is what happens at that point, to which a large number of sources and sinks are connected. Let me explain how this works in the prototype.

We said that the nominal LV was 120 V. If we have sufficient generators online and our batteries are fully charged, then we can assume voltage regulators simply discard power. But if we connect too many loads to the circuit, then the actual voltage will drop below the nominal value. This is the time that battery boxes should start discharging; and at a rate proportional to the discrepancy in generated and consumed power.

So, for example, if we have one 10 kW generator going and one 10 kW grinder, all is well. If we connect a second grinder, our load is 20 kW; and if we have exactly one battery box in the circuit, that box has to discharge at a rate of 10 kW to make up the difference. That box has a capacity of 120 kWh; so it will last about 12 hours before fully discharging -- assuming it was fully charged at the start. During the whole discharge cycle, actual line voltage will remain somewhat below nominal; when the battery is exhausted, voltage drops to zero, of course.

It's perfectly reasonably to assume constant losses and calculate them on some simple basis. Standby power for machines, battery leakage, cabling losses per node.

Power converters seem to be a special mystery; but all they are is big transformers. The rule on a transformer is -- disregarding losses -- a load on the output is a load on the input. So a converter connected to an output line with no machinery on it should hardly load its input; a converter on a heavily loaded output line should draw maximum input power. Watts in, watts out. Voltage does not enter into this.

The simplest way to model batteries is to assume that each has a constant maximum rate of charge and discharge. If the actual line voltage is equal to nominal, the battery charges... which puts additional load on the line and might actually pull it below nominal. So the charging rate -- in kW -- decreases; and if the line voltage goes low enough, stops charging altogether; if lower still, the box starts to discharge. It's easy to work this all out with simple ratios of power available and power consumed. For reasons I hope should be obvious, batteries should be greedy to charge and reluctant to discharge, compared to converter response. That is, a shortfall should be made up out of converter capacity first.

I realize that to those untrained in EE, the above discussion may not be as plain as I'd like. I'm more than willing to clear it up as best I can, if anyone will be kind enough to point out any obscure features.

I'm not at all certain of my ability to dinker with the code itself to bring it into line. I have some ability but I don't imagine myself a software jock; I'm just an old hardware dog. However I'm willing to dip in and fiddle. What's wanted most of all is a willingness among the 'technic' team to think seriously about sticking to a particular model of electrical power distribution and not try to invent physics all over again de novo, like Athena from Zeus' brow.

hdastwb commented 10 years ago

I don't believe the point of Technic was ever to provide a fully realistic electrical system, but rather an interesting game mechanic inspired by similar motives as those of Minecraft's Tekkit (just as Mesecons is more similar to Redstone than to actual digital electronics). I also think a more complete/accurate electrical engineering mod would be really neat, but I don't think that mod is Technic (though here's a similar concept regarding chemistry: https://forum.minetest.net/viewtopic.php?id=6616).

However, I do agree that it is quite difficult to figure out as a newcomer (or even as a veteran) what exactly the design principles of Technic really are, and at this stage in development it still seems like the gameplay model of Technic is still fairly fluid. Our lack of documentation doesn't help at all, yet it's difficult to write documentation because it's difficult to tell what, exactly, everything is really supposed to do or how everything is supposed to work, regardless of how the surprisingly buggy implementation does it. I think what this mod really needs is something akin to RBA's suggestion here: https://github.com/minetest-technic/technic/issues/84#issuecomment-23475120

Anyway, I'm sorry if I overlooked or oversimplified any part of your post in constructing my response…

hdastwb commented 10 years ago

Also, perhaps we should consider adding this statement somewhere: All science appearing in this work is fictitious. Any resemblance to real science, living or dead, is purely coincidental.

Partmedia commented 10 years ago

As of a recent commit, nuclear reactors are finally dangerous!