Max Rate Calculator


Calculates maximum consumption/prodution rates of assemblers, plants, etc.

Utilities
3 years ago
0.15 - 1.1
109K

g Mining Calculations

3 years ago

Thanks for adding support for miners. Here are a few issues I found:

(1) The pumpjack rate should not be clamped at 100%. For example, if the amount is 600000 and the normal amount is 300000, a pumpjack will produce 20 oil/sec.

(2) For pumpjacks, you should take the fluid name and fluid rate from mineable_properties.products. I believe the formula for the fluid rate should be:

resource.amount / resource_prototype.normal_resource_amount * (product.amount_min+product.amount_max)/2

"product" refers to each record inside mineable_properties.products. I'm not sure what happens if there are multiple products. I'm also not sure if "probability" applies, or if it's possible for amount_min to differ from amount_max.

I encourage you to play around with natural gas (aka gas well) in Angel's mod because it uses nonstandard values for amount_min and amount_max. Also, the name of the fluid doesn't match the name of the resource, so your mod doesn't work at all right now. Here's some tips for getting it set up:

a. You'll need to install angelspetrochem and angelsrefining
b. Make a map that has some Gas Wells visible in the map preview
c. Spawn a pumpjack and place it over the Gas Well

(3) Think about calculating the required fluid rate for mining uranium. mineable_properties contains two fields of interest: required_fluid and fluid_amount. required_fluid is the fluid's name ("sulfuric-acid" in this case). Be careful with fluid_amount because it's scaled by a factor of 10. If you run this command in game, you'll get 10:
/c game.print(game.entity_prototypes["uranium-ore"].mineable_properties.fluid_amount)
But if you hover the cursor over a uranium ore patch, the tooltip says "1 Sulfuric acid per mining operation"

3 years ago

Version 3.4.39 should handle this better. I'm not seeing the amount_min/max thing for the gas wells - in the script, those are commented out.

Also, the game's production graph shows two outputs, one being multiphase gas., which I don't see in the mineable_properties.products array for some reason.

3 years ago

I looked over your changes, and I think everything is fixed including natural gas in Angel's Petrochem. I don't understand what you mean about the production graph showing two outputs. If you open angelspetrochem_0.9.11\prototypes\generation\angels-natural-gas.lua you'll see the parameters he uses for configuring natural gas. The important ones are output_min and output_max which are both set to 20. In game, a pumpjack placed over crude oil gives you Multi Phase Oil at a base rate of 10/s. A pumpjack placed over a gas well gives you natural gas at a base rate of 20/s. Maybe you're using an older version of Angel's mods? Anyway, the calculations are correct so it doesn't matter.

3 years ago

By the production graph, I mean type P, select the fluids tab. I see two products, Natural Gas and Multi Phase Oil. The tooltip (and the array in mineable_properties.products) just shows the Natural Gas,

The test at line 1134 of my control.lua is not seeing a value in amount_min, so the code is just using what's in amount, so your suggestion in (2) doesn't always apply

3 years ago

Indeed. It looks like the game sets only amount inside mineable_properties.products[] if amount_min equals amount_max inside the LUA definition. In testing what would happen if amount_min wasn't equal to amount_max, I discovered a small mistake in your code:

debug_log(FUNC(), " producst min is " .. fluid_prod.amount_min) <-- fluid_prod is undefined

3 years ago

Ooops, thanks. Fixed in 3.4.40. What mod were you using to test it?

3 years ago

I don't think any mods assign different values to amount_min and amount_max, so I went into base/prototypes/entity/resources.lua and temporarily changed amount_max to 20.

New response