Abstract. The flow of fluids through porous media such as groundwater flow or magma migration are key processes in geological sciences. Flow is controlled by the permeability of the rock, thus an accurate determination and prediction of its value is of crucial importance. For this reason, permeability has been measured across different scales. As laboratory measurements exhibit a range of limitations, the numerical prediction of permeability at conditions where laboratory experiments struggle has become an important method to complement laboratory approaches. At high resolutions, this prediction becomes computationally very expensive, which makes it crucial to develop methods that maximize accuracy. In recent years, the flow of non-Newtonian fluids through porous media has gained additional importance due to e.g., the use of nanofluids for enhanced oil recovery. Numerical methods to predict fluid flow in these cases are therefore required. Here, we employ the open-source finite difference solver LaMEM to numerically predict the permeability of porous media at low Reynolds numbers for both Newtonian as well as non-Newtonian fluids. We employ a stencil rescaling method to better describe the solid-fluid interface. The accuracy of the code is verified by comparing numerical solutions to analytical ones for a set of simplified model setups. Results show that stencil rescaling significantly increases the accuracy at no additional computational cost. Finally, we use our modeling framework to predict the permeability of a Fontainebleau sandstone, and demonstrate numerical convergence. Results show very good agreement with experimental estimates as well as with previous studies. We also demonstrate the ability of the code to simulate the flow of power law fluids through porous media. As in the Newtonian case, results show good agreement with analytical solutions.