The spatial organization of metabolism is common to all domains of life. Enteric and other bacteria use subcellular organelles known as bacterial microcompartments to spatially organize the metabolism of pathogenicity-relevant carbon sources, such as 1,2-propanediol. The organelles are thought to sequester a private cofactor pool, minimize the effects of toxic intermediates, and enhance flux through the encapsulated metabolic pathways. We develop a mathematical model of the function of the 1,2-propanediol utilization microcompartment of Salmonella enterica and use it to analyze the function of the microcompartment organelles in detail. Our model makes accurate estimates of doubling times based on an optimized compartment shell permeability determined by maximizing metabolic flux in the model. The compartments function primarily to decouple cytosolic intermediate concentrations from the concentrations in the microcompartment, allowing significant enhancement in pathway flux by the generation of large concentration gradients across the microcompartment shell. We find that selective permeability of the microcompartment shell is not absolutely necessary, but is often beneficial in establishing this intermediate-trapping function. Our findings also implicate active transport of the 1,2-propanediol substrate under conditions of low external substrate concentration, and we present a mathematical bound, in terms of external 1,2-propanediol substrate concentration and diffusive rates, on when active transport of the substrate is advantageous. By allowing us to predict experimentally inaccessible aspects of microcompartment function, such as intra-microcompartment metabolite concentrations, our model presents avenues for future research and underscores the importance of carefully considering changes in external metabolite concentrations and other conditions during batch cultures. Our results also suggest that the encapsulation of heterologous pathways in bacterial microcompartments might yield significant benefits for pathway flux, as well as for toxicity mitigation.