Production from factories is added to the warehouse one factory at a time.
All steel is produced before engines are produced.
In you example say you are producing your steel in factories in batches of 20.
You will be producing QL50 steel from QL0 iron ore.
You start with 941 QL0 steel for 0QL*units in the warehouse.
You then add 20 units of QL50 steel to the warehouse. 20*50=1000QL*units were added.
You now have 941+20=961 units of steel and 1000QL*units of quality.
The mixed quality is now int(1000/961)=1QL.
You have 961 units of QL1 steel.
Warehouse has 961*QL1 = 961 QL*units of steel quality.
The next factory will dump 20 more units of QL50 steel adding 1000 QL*units of steel quality.
Total steel quality units are 1961 for 981 units.
The mixed quality is now int(1961/981)=1 (NOT 2!)
The process is repeated and the rounded down quality level stays at 1.
You now produce engines.
Its quality level is int((QL1 steel + QL50 engines)/2) = 24.
All engines produced are QL 24.
Note: that if you do not buy any more steel, you will start the next update with 493 steel of QL1.
You should end up with much higher QL steel. Maybe over QL20.
Walter