Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Calcium carbide production overhaul #63392

Merged
merged 4 commits into from
Mar 5, 2023
Merged

Conversation

cake-pie
Copy link
Contributor

@cake-pie cake-pie commented Feb 1, 2023

Summary

Bugfixes "Calcium carbide production overhaul"

Purpose of change

The production of calcium carbide by arc furnace as implemented in #32454 is very much a rough first prototype. C++ was adapted from charcoal kiln, unfinished CaC2 was basically a clone of unfinished charcoal, grinding requirements missing, etc. Lacks scientific rigor.

Process yields 50±10% by volume compared to inputs, that's pretty much copied from charcoal firing and has no relation to the stochiometry of calcium carbide production CaO + 3 C -> CaC2 + CO.

Describe the solution

Calcium carbide's stats, like many chems, is standardized to 1 unit = 0.01 mole of the chemical. That's great, we'll start from that.

We have "calcium carbide premix", which is coke and lime that have been ground to fine powder and combined in the right proportion to be smelted into CaC2. For the sake of sanity in calculations and implementation, we'll set it equivalent to the end product, i.e. absent any loss/wastage, one unit of premix becomes one unit of CaC2. Do a bunch of math to determine what the weight / volume stats should be.

Adjusted the recipe for grinding coke and lime into calcium carbide premix to get inputs and outputs to match the required proportions as closely as possible. Make it require mortar and pestle for grinding and not just hammering.

Created a recipe that uses "electric arc furnace" f_arc_furnace; energy requirement for the reaction is 460 kJ per mole (plus overheads and wastage, 70% efficiency is generous, source reports 40~75%). The smelting creates molten CaC2 which is allowed to cool and solidify; this then has to be crushed and ground down to the powdered form that is chem_carbide.

Obsoleted "unfinished calcium carbide" which is what you would have found if you smashed apart an arc furnace after firing it up but before it is done. This was created when shoehorning the charcoal firing process for carbide production and no longer needs to be a thing. Delete cac2powder and unfinished_cac2 ammo types, and cac2powder material, which were "shoehorns".

For now this PR disables the iexamine function for f_arcfurnace_empty so the old process can no longer be started, but any savegames with the process underway can still get the produced carbide from the f_arcfurnace_full (after required time has elapsed), which turns the furniture back into a f_arcfurnace_empty. Will leave it like this for a transition period, after which the "arc furnace" (f_arcfurnace_empty, f_arcfurnace_full) and its iexamine functions will no longer be used at all and are removed as dead code.

Have not decided what to do with the furniture after its obsolescence. It is kind of redundant with f_arc_furnace, so one thought is to migrate/obsolete it. However, f_arc_furnace cannot be constructed, whereas the f_arcfurnace_empty can, with some special requirements like fire bricks. It is not clear to me if it is okay to merge these into one furniture def, or whether they should continue to exist separately, filling different gameplay roles.

For now, I've given f_arcfurnace_empty the same fake_arc_furnace as f_arc_furnace, so players who went to the trouble of constructing the former -- which existed specifically for making CaC2 -- aren't left without a means of doing so.

Describe alternatives you've considered

1
Industrial processes also involve "electrode paste composed of coal tar pitch binder and anthracite coal" [source] but we're going with a more artisanal approach per sources cited in #32441.
 

2
The carbide smelting process liberates carbon monoxide, IRL this may be piped directly to other industrial process (e.g. lime kiln) that are colocated with the carbide arc furnace to take advantage of this. We could certainly come up with uses for carbon monoxide in-game -- there are at least a couple of recipes for extraction of metal from ores that could have a variation that uses CO.

One way to do it is to have a carbon monoxide item that is produced as by-product, but that requires the player to have some additional means to capture and bottle it. If the by-product can be made on an opt-in basis (or otherwise discarded), that would be more palatable than forcing players to have extra equipment to collect CO that they don't want just in order to make carbide.

Another idea is to add machinery in C++ to support having some kind of co-recipe that defines a co-process that can be crafted at the same time to take advantage of synergies. E.g. while making carbide, we can take the liberated carbon monoxide to reduce chem_zinc_oxide to chem_zinc_powder, perhaps even leverage some waste heat to lower the amount of fuel required.

Testing

Test the recipes for mix/grind coal+lime into premix and smelt/grind premix into carbide.

Additional context

Assumes that coal_lump has mass 37.5g per unit and not 1.5g -- this is bugfixed by 79cd0dc in #63375, no need to duplicate it here.

Fix weight of coal_lump, from 1.5g to 37.5g. There was a mistake in 5549b62 where divided by count (250) instead of stack size (10) leading to value off by a factor of ×25.

@github-actions github-actions bot added [C++] Changes (can be) made in C++. Previously named `Code` [JSON] Changes (can be) made in JSON Crafting / Construction / Recipes Includes: Uncrafting / Disassembling Items: Ammo / Guns Ammunition for all kinds of weapons and these weapons themselves <Bugfix> This is a fix for a bug (or closes open issue) labels Feb 1, 2023
@github-actions github-actions bot added json-styled JSON lint passed, label assigned by github actions astyled astyled PR, label is assigned by github actions labels Feb 1, 2023
@github-actions github-actions bot added Code: Tests Measurement, self-control, statistics, balancing. Fields / Furniture / Terrain / Traps Objects that are part of the map or its features. labels Feb 3, 2023
@cake-pie cake-pie marked this pull request as ready for review February 3, 2023 03:08
@github-actions github-actions bot added the BasicBuildPassed This PR builds correctly, label assigned by github actions label Feb 5, 2023
@ZhilkinSerg ZhilkinSerg merged commit 5659d2a into CleverRaven:master Mar 5, 2023
@cake-pie cake-pie deleted the cac2-pt1 branch March 6, 2023 03:25
@kasanryukin
Copy link
Contributor

Just saw this when reviewing my old commits! Much more elegant that what I did. What I mocked up worked with the existing code (in a heavy handed way), but I always wanted to give it a second pass. I'm glad somebody did and did it well!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
astyled astyled PR, label is assigned by github actions BasicBuildPassed This PR builds correctly, label assigned by github actions <Bugfix> This is a fix for a bug (or closes open issue) [C++] Changes (can be) made in C++. Previously named `Code` Code: Tests Measurement, self-control, statistics, balancing. Crafting / Construction / Recipes Includes: Uncrafting / Disassembling Fields / Furniture / Terrain / Traps Objects that are part of the map or its features. Items: Ammo / Guns Ammunition for all kinds of weapons and these weapons themselves [JSON] Changes (can be) made in JSON json-styled JSON lint passed, label assigned by github actions
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants