Millimeter and submillimeter observations of the Orion Bar. II. Chemical models