-
Notifications
You must be signed in to change notification settings - Fork 150
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
Fixing the Chemistry #1414
Fixing the Chemistry #1414
Conversation
Chemistryfixes
…ls.CalciumAcetate to better fit the fluid
…into molconvention
The water and hydrogen sulfide recipe really doesn't make any sense, unless we assume that all of the provided water is electrolyzed into hydrogen and oxygen, and the resulting hydrogen is just returned for free. I think that recipe should be removed in favor of the new oxygen recipe, as this represents a condensed form of the four-step Wet Sulfuric Acid (WSA) process used widely in industry. The second recipe is, as you say, not very realistic. The Contact process and WSA both burn solid elemental sulfur into sulfur dioxide as their starting step, then further oxidize it into sulfur trioxide. At this point the processes diverge:
In both cases it makes far more sense for the ingredients to include oxygen and to not produce hydrogen as an output. It might even be cool to have a recipe for the Contact process (where with sulfuric acid, sulfur, and water, you can produce twice the sulfuric acid). |
I can spend some time this afternoon/evening going through all ores to make sure there aren’t other issues like with Rutile. |
Good work everyone who participated on this PR. This is really big piece of work. And even though I can't understand most of it I see how much though you give to it. And I would gladly accept this and include it in next Minor release. @Exaxxion please create new issue with your idea regarding implementation of processing Uraninite as there is need to get whole radiation/decay/other related stuff get working first. @DStrand1 I authorize removal of all petitioned recipes, except Uraninite as new processing chain will not be part of this PR. |
Old recipes we requested removal of have been removed, and the opening comment has been updated. I adjusted the "recipes petitioned for removal" section to simply list all removed recipes in one organized place now. |
I'll create a separate issue for the proposed Uraninite changes. Given that we are not going to change it here, I should point out that while magnesium makes at least the faintest bit of sense for processing Uraninite (as you can get metallic Uranium via |
Before this issue report I looked at the different chemistry recipes added in by GTCE and those by Nuclearcraft and found Nuclearcraft's recipes to be following a proper chemical balance with moles for items and fluids such as electrolyzing 1B of water gives 950 mB hydrogen and 50 mB deuterium (or a combined 1B of hydrogen) and 500 mB oxygen, which follows the suggested guidelines perfectly. |
The way you describe it, they actually treat it just as we do, with one key difference. They treat molecules like Hydrogen and Oxygen as diatomic, like they are in the real world. In that situation, it makes total sense that water would break apart into those ratios. However, as an already established precedent in GTCE (that I did not touch at all, since it would be very distuptive), diatomic elements are treated as monoatomic for simplicity. This means that 1B of Hydrogen is actually “H” and not “H2” like Nuclearcraft has it. Figured I’d point this out, as our water recipe breaks down into 2B Hydrogen and 1B Oxygen. |
Electrolyzing water and centrifuging hydrogen aren't ways deuterium is obtained in practice. Much like uranium enrichment where you're improving the ratio of U235 relative to U238, deuterium must be captured through enrichment using an abundant chemical containing naturally occurring isotope ratios of hydrogen: water. Water is enriched from natural H2O into deuterated or "semiheavy" water (HDO) and eventually into heavy water (D2O). This is done through isotopic exchange via the GS process, which uses an apparatus with two sieve towers for water and a closed loop for hydrogen sulfide (H2S) gas. This is a cascading chemical process requiring several such apparatus. Water is first treated to remove contaminants like minerals and dissolved air. It is then added to a low-temperature tower (30C) where equilibrium favors exchange of deuterium from enriched hydrogen sulfide to water. The resulting enriched water is extracted for further enrichment, and the remaining water and depleted hydrogen sulfide flows into the high-temperature tower (130C). In this second tower, the equilibrium favors exchange of deuterium from water to hydrogen sulfide, depleting the water and enriching the hydrogen sulfide. The depleted water is filtered out and the enriched hydrogen sulfide is cycled back to the low-temperature tower, closing its loop. Heavy water has important uses as a neutron moderator in nuclear reactors, but for our purposes you could electrolyze it into deuterium and oxygen from there. Tritium can be generated through neutron capture by heavy water in a nuclear reactor, but heavy water is selected mainly because deuterium does not tend to capture neutrons. Thus the rate is incredibly slow and it is unreliable as a source of tritium; heavy water used in reactors is cleaned of the created tritiated or "super-heavy" water on an interval of several years. In practice, Tritium is mainly made in a fission reactor using Lithium-6, where it splits the Lithium fuel into Helium-4 and Tritium. |
@DStrand1 That is indeed what I was thinking about when I compared the two mods' chemistry values. Mono-atomic is better for simplicity whereas diatomic is more realistic. @Exaxxion That is true. As for why the NC electrolysis recipe for water gave you 50 mB of deuterium and 950 mB of hydrogen I cannot figure out, as you can also obtain your deuterium by fusing hydrogen together for instance. It may have been convenient for now to use that instead of adding the GS process to enrich hydrogen. As for the tritium, you can irradiate lithium-6 and boron-10 with neutrons to obtain it together with He4. An other method is by using certain fusion fuel combinations. However it seems that Mekanism takes this to some realistic level with its solar neutron activator which is a bottleneck in producing tritium. These things aside, I'm looking forward to the suggested changes. |
Yeah, its difficult to balance our chemistry around other mods that do it much more unrealistically; we have to just do the best we can, and depend on modpack authors to adjust other mod's nonsensical chemistry if they wish to include them with us. |
@LAGIdiot We have found a few more recipes that we would like to remove. There currently exists recipes in the Chemical Reactor that create Quartz, Quartzite, and Certus Quartz gems with Water/Distilled Water and Sodium. The Sodium is consumed in the process which makes this a bad recipe, and there already exists Autoclave recipes for these materials (the primary recipe). We would like to remove these recipes. |
@DStrand1 Permission for additional removal of recipes in petition section of opening comment granted. |
Alright. And with that, I would call this PR complete, assuming no further requested changes. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you everyone, who participated on this PR for your hard work.
The only recipe for calcium acetate solution that makes sense out of these is the third one. The only real alternative to calcium carbonate in this reaction with acetic acid would be Calcium Hydroxide ( It's trivial to make calcium carbonate (called Calcite in game) in a chemical reactor (also you can get it from marble and malachite) so I think it would be sensible to just remove the first two recipes. |
Due to @DStrand1 's pull request here(GregTechCE#1414), the recipes for processing Uraninite into Uranium 238 were changed. One of the recipes, which outputs 144mb of liquid Aluminium, allows you to delay making a blast furnace until further materials are needed. By changing the EU/t cost of the recipe to require MV power, it ensures that you need to make your first aluminium from smelting in the blast furnace. In the future, uraninite processing needs to be looked at in more depth.
* add toggle button to all voiding covers added lang * remove TODOs remove soft mallet function from voiding covers * re-implement soft hammer functionality * Fixed Soft Hammer not working with Voiding Covers on pipes Fixed/Added swinging when using a Wrench on pipes * Fix failing tests * add lang * remove override for onSoftMalletClick() * notify player via message * small oopsie * get cover on actual side instead of using the grid not sure how to do the same for pipes * fix NPE * remove logic for getting cover on actual side hit instead of GT grid * improved lang * remove commented out code * use `determineGridSideHit()` instead of `traceCoverSide()` * added soft mallet to `isCoverBehaviorItem()` in GTUtility removed check for soft mallet in BlockPipe `hasPipeCollisionChangingItem()` * re-organize `createUI()` adjust widget positioning for Manual IO Button * re-organize `createUI()` for advanced voiding covers adjust widget positioning for Manual IO Button move some logic in `createUI()` in CoverFluidVoidingAdvanced to it's own method, to match CoverItemVoidingAdvanced also fixed the fluid filter's stupid positioning in CoverFluidVoidingAdvanced * change funny magic number * improve lang * improve lang (forgor the lang file) * fix GUI issue in `CoverFluidVoidingAdvanced` * Revert "use `determineGridSideHit()` instead of `traceCoverSide()`" This reverts commit 168a8f3aef7f97a625735c18500ba60c3f24ac26. * change null check to `coverSide` instead of `coverBehavior` move `coverBehavior` field initialization * small adjustments match #1464 * make warning hover tooltip stand out
What:
Currently, GregTech does not respect the established convention that 1B of a fluid is 1 mol of that material. It is respected about 85% of the time, but that 15% has been shown to result in positive loops and exploits. This also causes the electrolysis/centrifugation of all fluids to be wildly inefficient, resulting in significant loss of materials. This PR fixes that, by “simply” changing the
processDecomposition()
method inDecompositionRecipeHandler
to allow for all electrolysis recipes with fluids to use 1B instead of 1B times the total elements present in the fluid. Of course, this revealed many inconsistencies, which I will get into in the following sections.At first glance, it may seem like simply fixing the linked issues regarding Methane and Phosphorus positive loops, and maybe disabling decomposition on some chemicals would be a better fix. However, this will never be the "good" solution, as just from spending a few minutes really looking into some of these recipes, I discovered several more problems just like the original two. Also, fixing positive loops like this completely disregards the inefficient electrolysis of materials, and in order to fix that issue, all of these changes were required, otherwise material could easily be lost during electrolysis. There are also several recipes present that void resources, such as the Titanium process, Uraninite, and Phosphoric Acid (using Calcium-based products), to name a few.
How solved:
Once
processDecomposition()
was changed, we had to manually comb through all of GregTech’s chemical recipes. Not only did we have to fix potential exploits that arose, such as Sulfuric Acid, Methane, Phosphoric Acid, and many others, but many recipes did not follow common stoichiometric balances, so they were adjusted to accurately reflect chemistry. Changing these was also very important, as an imbalance in elements could very easily lead to a positive loop with the Electrolyzer. This is a very large issue, and a significant number of recipes are being changed as a result.Rules we are following to accurately update recipes:
This is going to get very chemistry-heavy (and very long), but here is a list of recipe changes:
processDecomposition()
.C + 4H -> 5CH₄
. I simply reduced the Methane output to 1B instead of 5.MgCl₂ + Na -> 1.5Mg + 1.5Cl
. Added electrolysis recipe:3MgCl₂ -> Mg + 2Cl
. Additionally, I changed the EBF recipe of2Mg + TiCl₄
to output 6 Magnesium Chloride dust instead of 2, so that material is not lost. This conforms with the molecular mass of MgCl₂, as it is 3 dust per mol.NaCl + H₂SO₄ -> HCl + (1/7)NaHSO₄
. I denote it as 1/7 since it only gave one dust, and not 7 as the molecular mass states it should be. Adjusted it to output 7 dust. I also added a new decomposition recipe for Sodium Bisulfate (NaHSO₄) which I will explain later.(1/2)NaCl + H₂O -> 2B Salt Water
in mixer. Similarly as above, it is only 1 Salt dust when it should be 2. This would lead to a positive loop for Sodium Hydroxide and Chlorine, typically more difficult materials to acquire. New recipe:NaCl + H₂O -> 1B Salt Water
. Additionally, electrolysis of Salt Water now gives 3 NaOH dust, or 1 full mol.C₆H₅CH(CH₃)₂ + O -> (CH₃)₂CO + C₆H₅OH
. Changed Oxygen input to 2B, as without it, Oxygen is being created from nothing, introducing a potential positive loop.O + H + NO₂ -> H₂O + Rocket Fuel
. This recipe implied that rocket fuel was simplyNO₂
, which is Nitrogen Dioxide, and on top of that, this formula is imbalanced as it is short Hydrogen on the left. This recipe was removed, and the typical 1,1-Dimethylhydrazine recipes for Rocket Fuel are the only ones now.1B Nitric Acid + 1B Sulfuric Acid = 2B Nitration Mixture
. This was changed to only output 1 bucket.2H₂O + 2H₂S -> 3H₂SO₄
. This recipe has many problems, as it produces way too much Sulfuric Acid given that there is not enough Sulfur or Oxygen present, and it is not accurate to real-world chemistry. This recipe was removed. Additionally I added a recipe to use just Oxygen to not have the excess Hydrogen, using the same EUt and duration as the other H₂S recipe:4O + H₂S -> H₂SO₄
. Second old formula:S + 2H₂O -> 3H₂SO₄
. This formula would create a very easy positive loop for Sulfur if left as is. Second new formula:S + 4H₂O -> H₂SO₄ + 6H
. These recipes aren’t the most realistic, but avoided having to change input types for existing recipes.2O + N -> 3NO₂
. New recipe simply reduces the output amount to 1B of Nitrogen Dioxide. This recipe is a clear example of past confusion regarding molecular mass of fluids. There are not too many like this, but this is a very clear example of one.HClO + NH₃ + 2CH₃OH -> NH₂-N(CH₃)₂ + Dilute HCl
. This recipe is trying to compact the other recipe for dimethyl into one step, but missed an input. Increased NH₃ (Ammonia) to 2B, and increased Dilute Hydrochloric to 2B as well, to incorporate the new excess Hydrogen. Additionally changed the other recipe to give HCl instead of dilute HCl, since the formula was perfect and had no contaminants that would dilute the HCl.C + N + 2H₂O -> C₃H₅(NO₃)₃
. This recipe is very lacking in input material, and could have been an easy source of exploitation. This recipe also was unrealistic, so it was removed.S + Na + 4O -> 6Na₂S₂O₈
. Another good example of mol confusion, and an example of a newly discovered exploit as of working on this PR. This recipe was removed. I instead added an Electrolyzer recipe for Persulfate, being2NaHSO₄ -> Na₂S₂O₈ + 2H
where NaHSO₄ is Sodium Bisulfate. Additionally, since the recipe was made significantly harder, I reduced its amount used for purifying certain crushed ores in the Chemical Bath, from 1B to 100mb.UO₂ + Al/Mg -> U(238)
. I added 2B of Oxygen and 144mb of Al/Mg as additional fluid outputs, so nothing is lost. This is a good example of an “ingot mol,” as we output 144mb of Al/Mg and not 1B. New formula:UO₂ + Al/Mg -> U(238) + 2O + Al/Mg
. This recipe is very problematic, and has no chemical basis. We should remove it and replace it with a more accurate recipe as mentioned in the comments below.Silicon + Epichlorohydrin
recipe as 1H, 1C, 1Cl, and 1O are voided currently. I removed this recipe entirely, since it is not the primary recipe for Silicone, and since Silicone is not able to be produced from ECH in real-world.H₂C=C=O + 8HNO₃ -> 2C(NO₂)₄ + 9H₂O
. Recipe created 8 Hydrogen from nothing, and was quite inaccurate to the real-world process. Adjusted the recipe to:4CH₃COOH + 4H₂C=C=O + 4HNO₃ -> C(NO₂)₄ + 7CH₃COOH
. Acetic Acid + Ethenone + Nitric Acid -> TNM + Acetic Acid. One CO₂ is getting voided in this recipe, due mostly to limited output slots but also because in a real reaction, this CO₂ would be exceptionally difficult to capture and keep.Ca₅(PO₄)₃Cl + 5H₂SO₄ + 10H₂O -> 3H₃PO₄ + HCl
to now include the byproducts in the form of Gypsum (like the real-world formula is) with the formula:Ca₅(PO₄)₃Cl + 5H₂SO₄ + 10H₂O -> 3H₃PO₄ + HCl + 5CaS(H₂O)₂O₄
. This is reflected in game as 40 Gypsum dust, since to get the full material back from electrolysis, it is 8 dust per mol. This differs from how it might “seem” to be, since the element count of Gypsum (CaS(H₂O)₂O₄) is 12, but the electrolysis recipe keeps the water intact, making it 8 instead. Unfortunately this is a little annoying, as the machine can now only run once before having to have items emptied out, but this is not the primary way of making Phosphoric Acid, so I think it is okay.Additionally, another recipe creating Phosphoric Acid with Phosphorous Pentoxide caused a positive loop before making this electrolysis change, as shown in [BUG] Phosphorus positive Crafting loop exists via Posphorus Pentoxide #1318. The old formula was
(1/14)P₄O₁₀ + 6H₂O => 4H₃PO₄
. I denote it as (1/14) since it used one dust, instead of the full mol, being 14 dust. I changed this recipe to use 14 dust instead. The recipe for Phosphorous Pentoxide was already correct, being4P + 10O -> P₄O₁₀
.Cumene + Oxygen
recipe was short 1B of Oxygen, so I added that. For the other three, we had to change their recipes to make Calcium Acetate Solution instead of directly making Acetone, as the old recipes did not even come close to creating Acetone. We also slightly reworked Calcium Acetate Solution, and changed it’s composition to include 1 H2O. This allowed for the Calcite recipe to be balanced, since before, it required 3 distinct fluid outputs of materials that had no solid form. This means that when distilling it, water is now given in addition to Acetone, CO₂, and CaO. Formulas:Old Recipe 1:
Ca + 4CH₃COOH -> (CH₃)₂CO + 4CO₂
New Recipe 1:Ca + O + 2CH₃COOH -> Ca(C₂H₃O₂)₂(aq)
Old Recipe 2:
(1/2)CaO + 4CH₃COOH -> (CH₃)₂CO + 4CO₂
New Recipe 2:CaO + 2CH₃COOH -> Ca(C₂H₃O₂)₂(aq)
Old Recipe 3:
(1/5)CaCO₃ + 4CH₃COOH -> (CH₃)₂CO + 4CO₂
New Recipe 3:CaCO₃ + 2CH₃COOH -> Ca(C₂H₃O₂)₂(aq) + CO₂
The descriptor (aq) means that it is in solution with water. Note that these new recipes do not actually form Acetone, so only the Cumene process recipe directly creates Acetone. However, Calcium Acetate can still be put in a Fluid Heater or Distilled into Acetone, as it was before. The recipe here using metallic Calcium is not particularly realistic, but I feel it is an unnecessary line to draw in terms of convenience, especially since the formula is still balanced.
Ca(C₂H₃O₂)₂(aq) => CaO + (CH₃)₂CO + CO₂ + H₂O
. The EUt and duration of this were not changed. I understand if the name change seems unnecessary, and would be totally fine with reverting it. Additionally, the Mixer recipes for Calcium Acetate were removed, since they were not able to be properly balanced due to limited I/O slots in the Mixer. These changes to Calcium Acetate address the issue of [BUG] Quicklime Positive Loop #1417.Outcome:
Additional info:
As a result of these changes, many recipes had to be rebalanced to a degree. I don’t expect this to be too much of an issue, as most of the time, only the amounts of input and output items/fluids were changed, but there were some cases where additional inputs or outputs were added. Overall, I would not call this a nerf or a buff. Many recipes were made easier, many were made harder, and many stayed the same.
Additionally, there were 2 key cases where I broke convention. One of them is the final step of the production of plastics, rubbers, and alloys, as they are more like an ingot than a liquid/dust, so they remain unchanged. However, there probably are some recipes late in the plastic production formulas that have some issues, but since plastics have the
DISABLE_DECOMPOSITION
flag, I decided there was no need to change them currently, because it would significantly affect progression. Second place is with ore-based processes. The primary ones were: Saltpeter for Polycaprolactam was left at one dust, despite the “correct” recipe using 5 Saltpeter and not 1. Also, the Indium line recipe using 2 different purified ores were left at 1 each, despite the ores being more complex compounds.Oil processing lines, distillery recipes (aside from Calcium Acetate), and many, many more things were left completely untouched as they are consistent with themselves just fine. The only things changed here were mostly Chemical Reactor recipes, Electrolyzer/Centrifuge recipes(liquids only), a couple Mixer recipes, and 2 EBF recipes (Titanium production).
I also want to link the closed PR #1406, which addressed a couple problems, but failed to address the major issue. The fixes (and commits even) were included in this PR.
Additionally, I wanted to mention that this fix opens the door to removing the
DISABLE_DECOMPOSITION
flag from many materials, as it seems to have been used in some cases to ignore the problems addressed here. However, I did not change this flag for any materials (aside from Magnesium Chloride), as it is not part of the scope of this PR, and removing this flag from some materials doesn't make much sense in real-world chemistry.Possible compatibility issue:
Addons could suffer with this change. However, I have spoken with the devs of Gregicality, and worked with Exa, the current maintainer of SoG, while working on this, and everyone seems very excited to implement these changes. I have already spoken with the Gregicality dev team in-depth about these changes, and they have started working on fixes to their mod based on these changes, and I will be helping them with it as well. Modpacks like FTB:I or Omnifactory may have some script problems, but I suspect some of their scriptwork is for adding some of these changes included in this PR.
Additionally, since some recipe amounts have been rebalanced somewhat significantly, some automation may be clogged up with excess output items or fluids, but it is a minor problem at worst.
This is, however, a very large change. I completely understand if you are hesitant to implement this into GTCE. However, I and many others feel that this is an extremely necessary change, because as-is, the chemistry system has many flaws, and this addresses all of them.
TL;DR For Recipe Removals:
Recipes that have been entirely removed:
Water + Hydrogen Sulfide
to be replaced entirely by new recipe already added:Oxygen + Hydrogen Sulfide
Carbon + Nitrogen + Water
to be replaced entirely by other pre-existing recipeGlycerol + Nitration Mixture
Sulfur + Sodium + Oxygen
to be replaced entirely by new recipe already added to electrolyzer:Sodium Bisulfate -> Sodium Persulfate + Hydrogen
O + C + NO₂
, to instead require 1,1-Dimethylhydrazine for Rocket Fuel.Thanks:
Thank you to TheCodingChicken, Exa, OneLemonyBoi, the Gregicality chemistry masters, Arch, and many others who helped me to figure out what to fix, how to go about fixing it, and for helping with sifting through the recipes and comparing against real-world chemical formulas. I definitely could not have done this without their help.