Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion openstudiocore/src/contam/Contam.i
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
// fatal error C1061: compiler limit : blocks nested too deeply
%ignore RunControl(std::string name=std::string(),std::string version=std::string(),int echo=0,std::string prjdesc=std::string(),int skheight=0,int skwidth=0,int def_units=0,int def_flows=0,RX def_T=RX_INIT(0),int udefT=0,RX rel_N=RX_INIT(0),RX wind_H=RX_INIT(0),int uwH=0,RX wind_Ao=RX_INIT(0),RX wind_a=RX_INIT(0),RX scale=RX_INIT(0),int uScale=0,int orgRow=0,int orgCol=0,int invYaxis=0,int showGeom=0,WeatherData ssWeather=WeatherData(),WeatherData wptWeather=WeatherData(),std::string WTHpath=std::string(),std::string CTMpath=std::string(),std::string CVFpath=std::string(),std::string DVFpath=std::string(),std::string WPCfile=std::string(),std::string EWCfile=std::string(),std::string WPCdesc=std::string(),RX X0=RX_INIT(0),RX Y0=RX_INIT(0),RX Z0=RX_INIT(0),RX angle=RX_INIT(0),int u_XYZ=0,RX epsPath=RX_INIT(0),RX epsSpcs=RX_INIT(0),std::string tShift=std::string(),std::string dStart=std::string(),std::string dEnd=std::string(),int useWPCwp=0,int useWPCmf=0,int wpctrig=0,RX latd=RX_INIT(0),RX lgtd=RX_INIT(0),RX Tznr=RX_INIT(0),RX altd=RX_INIT(0),RX Tgrnd=RX_INIT(0),int utg=0,int u_a=0,int sim_af=0,int afcalc=0,int afmaxi=0,RX afrcnvg=RX_INIT(0),RX afacnvg=RX_INIT(0),RX afrelax=RX_INIT(0),int uac2=0,RX Pres=RX_INIT(0),int uPres=0,int afslae=0,int afrseq=0,int aflmaxi=0,RX aflcnvg=RX_INIT(0),int aflinit=0,int Tadj=0,int sim_mf=0,int ccmaxi=0,RX ccrcnvg=RX_INIT(0),RX ccacnvg=RX_INIT(0),RX ccrelax=RX_INIT(0),int uccc=0,int mfnmthd=0,int mfnrseq=0,int mfnmaxi=0,RX mfnrcnvg=RX_INIT(0),RX mfnacnvg=RX_INIT(0),RX mfnrelax=RX_INIT(0),RX mfngamma=RX_INIT(0),int uccn=0,int mftmthd=0,int mftrseq=0,int mftmaxi=0,RX mftrcnvg=RX_INIT(0),RX mftacnvg=RX_INIT(0),RX mftrelax=RX_INIT(0),RX mftgamma=RX_INIT(0),int ucct=0,int mfvmthd=0,int mfvrseq=0,int mfvmaxi=0,RX mfvrcnvg=RX_INIT(0),RX mfvacnvg=RX_INIT(0),RX mfvrelax=RX_INIT(0),int uccv=0,int mf_solver=0,int sim_1dz=0,int sim_1dd=0,RX celldx=RX_INIT(0),int sim_vjt=0,int udx=0,int cvode_mth=0,RX cvode_rcnvg=RX_INIT(0),RX cvode_acnvg=RX_INIT(0),RX cvode_dtmax=RX_INIT(0),int tsdens=0,RX tsrelax=RX_INIT(0),int tsmaxi=0,int cnvgSS=0,int densZP=0,int stackD=0,int dodMdt=0,std::string date_st=std::string(),std::string time_st=std::string(),std::string date_0=std::string(),std::string time_0=std::string(),std::string date_1=std::string(),std::string time_1=std::string(),std::string time_step=std::string(),std::string time_list=std::string(),std::string time_scrn=std::string(),int restart=0,std::string rstdate=std::string(),std::string rsttime=std::string(),int list=0,int doDlg=0,int pfsave=0,int zfsave=0,int zcsave=0,int achvol=0,int achsave=0,int abwsave=0,int cbwsave=0,int expsave=0,int ebwsave=0,int zaasave=0,int zbwsave=0,int rzfsave=0,int rzmsave=0,int rz1save=0,int csmsave=0,int srfsave=0,int logsave=0,std::vector<int> save=std::vector<int>(),std::vector<RX> rvals=std::vector<RX>(),int BldgFlowZ=0,int BldgFlowD=0,int BldgFlowC=0,int cfd_ctype=0,RX cfd_convcpl=RX_INIT(0),int cfd_var=0,int cfd_zref=0,int cfd_imax=0,int cfd_dtcmo=0);
%include <contam/PrjPublic.hpp>
%ignore Model(Reader &input);
%ignore PrjModel(Reader &input);
%include <contam/PrjModel.hpp>
//%include <contam/ReverseTranslator.hpp>
%include <contam/ForwardTranslator.hpp>
Expand Down
29 changes: 2 additions & 27 deletions openstudiocore/src/contam/ForwardTranslator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -400,7 +400,7 @@ bool ForwardTranslator::modelToPrj(const openstudio::model::Model& model, const
translator.setTranslateHVAC(translateHVAC);
translator.setAirtightnessLevel(leakageDescriptor);

boost::optional<contam::PrjModel> prjModel = translator.translate(model);
boost::optional<contam::PrjModel> prjModel = translator.translateModel(model);
if(prjModel)
{
boost::optional<std::string> output = prjModel->toString();
Expand Down Expand Up @@ -429,7 +429,7 @@ bool compareElevation(openstudio::model::BuildingStory a, openstudio::model::Bui

// This function is altogether too long and needs to be broken up into smaller functions.
// This is particularly true for the HVAC translation.
boost::optional<contam::PrjModel> ForwardTranslator::translate(model::Model model)
boost::optional<contam::PrjModel> ForwardTranslator::translateModel(model::Model model)
{
m_logSink.setThreadId(QThread::currentThread());
m_logSink.resetStringStream();
Expand Down Expand Up @@ -1112,31 +1112,6 @@ boost::optional<contam::PrjModel> ForwardTranslator::translate(model::Model mode

}

boost::optional<EpwFile> ForwardTranslator::translateEpw(openstudio::path epwpath, openstudio::path outpath)
{
boost::optional<EpwFile> epw;
try
{
EpwFile epwFile(epwpath,true);
try
{
epwFile.translateToWth(outpath);
}
catch(...) // Is this going to work?
{
LOG(Error,"Translation of EPW file failed, weather will be steady state");
return false;
}
epw = boost::optional<EpwFile>(epwFile);
}
catch(...)
{
LOG(Error,"Failed to correctly load EPW file, weather will be steady state");
return false;
}
return epw;
}

static double laminarCoefficient(double Ct, double x)
{
// Ct turbulent flow coefficient
Expand Down
30 changes: 14 additions & 16 deletions openstudiocore/src/contam/ForwardTranslator.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,8 @@ namespace contam{
* www.bfrl.nist.gov/IAQanalysis/CONTAM/manual/Content/html/IDH_UsingControls_CVF.htm
*
* Data is input as TimeSeries that should cover the entire time period to
* be simulated.
* be simulated. TimeSeries with Celcius units will be converted to Kelvin
* on output. All other TimeSeries should be in the units CONTAM expects.
*
*/
class CONTAM_API CvFile
Expand Down Expand Up @@ -75,7 +76,7 @@ class CONTAM_API CvFile
*
* ForwardTranslator translates an OpenStudio energy model into a CONTAM
* airflow model using a streamlined approach. Each wall is assigned an
* overall leakage rate, and individual components are not presently
* overall leakage rate and individual components are not presently
* represented.
*
*/
Expand All @@ -84,25 +85,18 @@ class CONTAM_API ForwardTranslator
public:
ForwardTranslator();

// Clear out the translator and reset to the defaults
void clear();

// Translator
boost::optional<contam::PrjModel> translate(model::Model model);
// Translation function
boost::optional<contam::PrjModel> translateModel(model::Model model);

// Static translation function
static bool modelToPrj(const openstudio::model::Model& model, const openstudio::path& path,
bool translateHVAC=true, std::string leakageDescriptor="Average", ProgressBar* progressBar=NULL);

// Secondary translation functions - this doesn't really fit here any more, so maybe it needs
// to be moved elsewhere, could be made static
boost::optional<EpwFile> translateEpw(openstudio::path epwpath, openstudio::path outpath);

// Accessors to the element maps
std::map <Handle, int> surfaceMap() const {return m_surfaceMap;}
std::map <Handle, int> zoneMap() const {return m_zoneMap;}

// Getters and setters - the setters modify how translation
// Getters and setters - the setters modify how translation is done
// Setters that could fail return a boolean
boost::optional<std::string> airtightnessLevel() const;
void setAirtightnessLevel(std::string level);
Expand All @@ -119,9 +113,6 @@ class CONTAM_API ForwardTranslator
boost::optional<DateTime> startDateTime() const;
boost::optional<DateTime> endDateTime() const;

// We may need more functions like this that modify the CONTAM model
int addNewAirflowElement(contam::PrjModel prjModel,std::string name,double flow,double n=0.65,double deltaP=75.0);

// Write control files
bool writeCvFile(openstudio::path filepath);

Expand All @@ -132,17 +123,24 @@ class CONTAM_API ForwardTranslator
std::vector<LogMessage> errors() const;

private:
// Do the work to set up the leakage paths
bool applyExteriorFlowRate(contam::PrjModel prjModel);
bool applyAirtightnessLevel(contam::PrjModel prjModel);

// Convenience function to add a new one-point test airflow element to the model
int addNewAirflowElement(contam::PrjModel prjModel,std::string name,double flow,double n=0.65,double deltaP=75.0);

// Clear out the translator and reset to the defaults
void clear();

// Really need to look at these and determine if they are really needed
int tableLookup(QMap<std::string,int> map, std::string str, const char *name);
int tableLookup(QMap<Handle,int> map, Handle handle, const char *name);
int tableLookup(std::map<Handle,int> map, Handle handle, const char *name);
std::string reverseLookup(QMap<std::string,int> map, int nr, const char *name);
Handle reverseLookup(QMap<Handle,int> map, int nr, const char *name);

// Maps - will be populated after a call of translateToPrj
// Maps - will be populated after a call of translateModel
// All map to the CONTAM index (1,2,...,nElement)
std::map<std::string,int> m_afeMap; // Map from descriptor ("exterior", "floor", etc.) to CONTAM airflow element index
QMap <Handle, int> m_levelMap; // Building story to level map by handle
Expand Down