How much electricity should be used per citizen, how important for city growth May 13, 2010, 08:11:05 pm Currently the electrical provision to cities is, well, totally broken due to stupid bugs, mostly of the unit-conversion variety (the code for get_electricity_consumption is completely wrong, generating wildly different numbers when doing linear interpolation and when not doing so!)I can't really fix it correctly until I know how much electricity *should* be used per citizen. In kilowatts. By year. Also, the correct level of importance of electrical provision for city growth. As a percentage. By year. Quote Selected
Re: How much electricity should be used per citizen, how important for city growth Reply #1 – May 13, 2010, 10:32:54 pm Neroden,ohh dear - sorry for having made a mess of the coding. The testing that I did a while ago when I first introduced this feature seemed to be all right, but evidently it either wasn't tested thoroughly enough or has had a bout of bit-rot when integrated with Standard things since then. Thank you for looking into this.It's been so long since I did anything with this, I can't remember what I had originally intended. The idea is that both of those values should be scaled simultaneously based on the values in electricity.tab. The best way of calibrating it is to use industries, and work out how much electricity that a city of a certain size in real life (best use the size in square kilometres rather than population, since Simutrans population figures are not realistic as they are generally too low) would consume compared to an industry; or, alternatively, how many power stations of what size would in reality be required to supply a city of what size in what era. Might I ask - what are the errors? That might help to jog my memory as to what was intended.Edit: Ahh, hold on. Electricity proportion I think might be a factory thing: I modified the amount of electricity that factories consumed (a percentage of the amount consumed in Standard) because they consumed far too much in Standard compared to cities. Electricity proportion is just the modifier, I think, for the amount of electricity consumed by factories. The default is 17% of the amount consumed in Standard, but this can be varied, so that a farm, for example, consumes a tiny fraction of the amount that a steel mill of equivalent production consumes. Quote Selected Last Edit: May 13, 2010, 10:50:46 pm by jamespetts
Re: How much electricity should be used per citizen, how important for city growth Reply #2 – May 13, 2010, 10:52:29 pm Quote from: jamespetts – on May 13, 2010, 10:32:54 pmMight I ask - what are the errors? That might help to jog my memory as to what was intended.It was unclear whether get_electricity_consumption was supposed to return a *fraction* (1.0F = 100%) or a *percentage* (100.0F = 100%) (it did one half the time and one the other half). Then, it was unclear what that was supposed to be a percentage *of*.(There was yet another code bug -- the electricity_consumption tracking code cleared *car_ownership* on startup if there wasn't a working electricity.tab file!)In the current code, the number from get_electricity_consumption, originally from electricity.tab (a percentage half the time, a fraction half the time) was multiplied by 20 (?!?) to generate the fraction of city growth controlled by electricity supply. This doesn't make any sense at *all* to me. Note also that the "percentage" numbers in electricity.tab go well over 100.The consumption of power was equal to the number from get_electricity_consumption times the number of citizens times .02 (?!?) -- which is also in the wrong units, as it ends up being microscopic. I think there was a failure to convert from MW to interrnal power units.If we went with some rule, for instance "100 in electricity.tab means the city uses .02 MW per person, and electricity counts for 20% of city growth", I could straighten out all the conversions.I actually think you need to decouple the two factors slightly, by restoring electricity_multiplier to simuconf.tab. Perhaps 100 in electricity.tab should mean that electricity accounts for electricity_multiplier% of city growth. That would make some sort of comprehensible sense to pak builders.EDIT: As a useful point of reference, factories use (number of units produced per month) * (electricity_proportion) as the amount of power they need per month, in *internal units*. If not set in the pak, electricity_proportion defaults to 0.17 for reasons I don't fully understand. So that might be something to use for figuring out how much electricity should be used per unit of population. Quote Selected Last Edit: May 13, 2010, 10:58:48 pm by neroden
Re: How much electricity should be used per citizen, how important for city growth Reply #3 – May 13, 2010, 11:14:28 pm This is all rather difficult for me to remember now - sorry! However, I do know that when I read in a percentage value in simuconf.tab, it goes into a fraction as a float, so 1.0F = 100%: that's my standard way of doing percentages/proportions in simuconf.tab.I'm fairly sure that there was a good reason for multiplying by 20, but I can't remember what it is now. However, the percentages were designed to tie in with government statistics, if I recall correctly, so the absolute values are essentially arbitrary: it is (I think - the government statistics website to which I linked in electricity.tab has been re-organised, so the page is no longer valid) x% of the electricity consumption in a particular year. Indeed, it might well be that the multiplying by 20 was designed to make the internal values work with the raw data from government statistics, although my memory of the exact purpose is faded now. However, the values in electricity.tab were definitely designed to be able to use government statistics without modification of the absolute numbers in the statistics. Quote Selected
Re: How much electricity should be used per citizen, how important for city growth Reply #4 – May 14, 2010, 01:10:11 am Quote from: jamespetts – on May 13, 2010, 11:14:28 pmHowever, the percentages were designed to tie in with government statistics, if I recall correctly, so the absolute values are essentially arbitrary: it is (I think - the government statistics website to which I linked in electricity.tab has been re-organised, so the page is no longer valid) x% of the electricity consumption in a particular year. No it's not, or it wouldn't go over 100%. Oh, and I didn't even mention the "magic" divisions by 5120, which I think are for MW conversion, but aren't everywhere they should be.ANYway, I have made what I think are the minimal changes necessary for something approximating correct behavior. Most importantly, everything is now p****ed through in correct units. The 'magic constant' determining megawattage per citizen is now in only one place instead of in three; the '20' is broken out as the electricity_multiplier (it appears to have originated as this and you should probably restore it to simuconf.tab); and the comments are right.See how it works; it's all on my 8.x branch.EDIT: Since I notice you pulled my jp-devel branch to your devel branch, which had the powerline-stabilization code and a half-****ed version of the fixes for the city electric code -- I suggest you pull my jp-devel branch to your devel branch again. It now properly integrates the fixes on the 8.x branch with the merger of the powerline-stabilization code. Quote Selected Last Edit: May 14, 2010, 02:06:15 am by neroden
Re: How much electricity should be used per citizen, how important for city growth Reply #5 – May 15, 2010, 12:46:29 am Neroden,various changes pulled - see my comments on the other thread for details. Thank you very much for your effort on this one - much appreciated :-) Quote Selected