def add_compartment(model, compartment, **keywords):
    """ Helper function to add a compartment to the SBML model.
    :param model: a valid SBML model
    :param compartment: a Compartment object
    :return: SBML compartment object 
    """
    sbml_compartment = model.createCompartment()
    compartment_id = compartment.name
    sbml_compartment.setId(compartment_id)
    sbml_compartment.setName(compartment.name)
    sbml_compartment.setConstant(True)  # keep compartment size constant
    sbml_compartment.setSpatialDimensions(compartment.spatial_dimensions)  # For example, 3 dimensional compartment
    sbml_compartment.setSize(compartment.size)  # For example, 1e-6 liter
    if compartment.unit is not None:
        sbml_compartment.setUnits(compartment.unit)
    return sbml_compartment