Hi, I've made some castings in brass and they had porosity problems, I've learned since that the solution is to add some phosphorus in the form of a stick of copper/phosphorous brazing rod which is commonly used in brazing joints in refrigeration applications. This stuff is cheap and I've got some but haven't tried it yet. It happens with bronze castings as well, I read in an old Model engineer magazine from the 1940's that porosity used to be considered inevitable in non - ferrous castings.
I have read a lot about how to make quality castings that don't have any significant defects, and so far I am having good luck with iron castings that do not have porosity or other defects.
I did get some defects in the first cast iron flywheel that I cast due to using the wrong sand type (Petrobond), and some of the sand erroded at iron temperatures. I was able to salvage the flywheel luckily, but I changed to resin-bound sand after that, and have not had any more casting defects.
I believe most casting defects are cause by excessive velocity in the molten metal stream that is flowing into the mold cavity.
The excessive velocity often damages the sand mold, and it also creates turbulence in the metal, with entrains air and slag into the casting.
If you control metal velocity, and avoid metal turbulence by using the correct sprue/runner/gate arrangement, you can consistently make iron or other castings without defects.
With a slight amount of ferrosilicon, the iron is very machinable too.
Phosphorus is said to be the bane of iron castings, and while it can give extreme fluidity to an iron melt, it also supposedly gives the iron some very poor qualities that you generally want to avoid in engine castings.
For aluminum castings, one of the secrets to avoid porisity is to melt the metal as quickly as possible, and don't heat it above pour temperature, and pour immediately.
Once you get aluminum above pour temperature, it becomes like a giant sponge, and your castings will be filled with porosity due to hydrogen absorption.
For super critical aluminum castings, you can use a degasser like nitrogen or some other inert gas, but you can get good aluminum castings without porosity just by not overheating the melt.
.