The answer depends on what type of mechanical system you have. There are generally two categories, zone hvac such as ZoneHVACPackagedTerminalAirConditioner and built up central systems implemented in OpenStudio as AirLoopHVAC. In OpenStudio dynamic manipulation of the OA rates is generally not possible with zone hvac.
If you have a built up AirLoopHVAC system delivering outside air, there will be an AirLoopHVACOutdoorAirSystem as a component on the AirLoopHVAC and the oa system will have have a ControllerOutdoorAir. The oa controller can be used to turn ventilation on and off with the Maximum Fraction of Outdoor Air Schedule Name
which is available through the OpenStudio API and Measure using this method. This is the typical thing to do when you want the oa damper closed at night or during unoccupied hours.
In OpenStudio, if you want the ventilation rates to vary fractionally through time you will want your DesignSpecificationOutdoorAir objects to define ventilation in terms of per person, and then enable demand controlled ventilation in the ControllerMechanicalVentilation object which is associated with the ControllerOutdoorAir.
Yes I know this is a little complicated. I'll make a follow up post to give you some ruby code to demonstrate this in Measure format. Also this post is relevant.
update Here is an example of what a Measure might do
# vent_schedule = on off schedule that you want the ventilation to follow
model.getAirLoopHVACs.each do |air_system|
oa_system = air_system.airLoopHVACOutdoorAirSystem
if ! oa_system.empty?
oa_system.get.getControllerOutdoorAir.setMaximumFractionofOutdoorAirSchedule(vent_schedule)
# If you want the system to use DCV then do this
oa_system.get.getControllerOutdoorAir.controllerMechanicalVentilation.setDemandControlledVentilation(true)
end
end