├── .python-version ├── doc ├── src │ ├── parsers │ │ ├── __init__.py │ │ ├── util │ │ │ └── process-raw-cnrecs.py │ │ ├── cnfields.py │ │ ├── base.py │ │ └── cndefns.py │ ├── docs │ │ ├── probe-definitions │ │ │ ├── index.md │ │ │ └── .nav.yml │ │ ├── assets │ │ │ ├── images │ │ │ │ ├── fd_refs.png │ │ │ │ ├── image1.png │ │ │ │ ├── pv_fixed.png │ │ │ │ ├── fd_block_slab.png │ │ │ │ ├── fd_block_basement.png │ │ │ │ ├── fd_context_slab.png │ │ │ │ ├── diagram-source-CSE.pptx │ │ │ │ ├── fd_context_basement.png │ │ │ │ ├── pv_horiz_tracker_east.png │ │ │ │ ├── pv_horiz_tracker_south.png │ │ │ │ └── pv_tilted_tracker_south.png │ │ │ ├── tables │ │ │ │ └── input-data--member-table-definition.csv │ │ │ ├── javascript │ │ │ │ └── extra_js.js │ │ │ └── stylesheets │ │ │ │ └── extra_styles.css │ │ ├── .nav.yml │ │ ├── input-data │ │ │ ├── dhwheater.md │ │ │ ├── dhwloopheater.md │ │ │ ├── dhwmeter.md │ │ │ ├── perimeter.md │ │ │ ├── afmeter.md │ │ │ ├── dhwpump.md │ │ │ ├── .nav.yml │ │ │ ├── construction.md │ │ │ ├── index.md │ │ │ ├── dhwlooppump.md │ │ │ ├── exportfile.md │ │ │ ├── shadex.md │ │ │ ├── layer.md │ │ │ ├── loadmeter.md │ │ │ ├── exportcol.md │ │ │ ├── dhwloopseg.md │ │ │ ├── accumulator.md │ │ │ ├── sgdist.md │ │ │ ├── dhwtank.md │ │ │ └── dhwsolarsys.md │ │ ├── index.md │ │ ├── shared │ │ │ └── enduses.md │ │ └── introduction.md │ ├── extra │ │ ├── hploop.md │ │ ├── dhwsolartank.md │ │ └── inverse.md │ ├── main.py │ └── mkdocs.yml ├── .gitignore └── CMakeLists.txt ├── test ├── error_handling │ ├── missing_weather_file.cse │ ├── failed_importfile.cse │ └── CMakeLists.txt ├── MF8X.cse ├── ZT5D.cse ├── dc2.et1 ├── minimum_running_file.cse ├── wshp.cse ├── Fresno.ET1 ├── chdhw.cse ├── ASHP_DFNG.cse ├── DHW_BRWL.cse ├── FanCoil.cse ├── ashpvc2.cse ├── autosize.cse ├── perfmap2z.cse ├── submeter.cse ├── DHWLoop32U.cse ├── Ductest1c2.cse ├── FRESNO_CTZ2.et1 ├── GA_Atlanta.et1 ├── DHW_MFSizing.cse ├── RefUp.bat ├── ref-win32-msvc │ ├── MF8X.REP │ ├── WSHP.REP │ ├── ZT5D.REP │ ├── CHDHW.REP │ ├── ASHPVC2.REP │ ├── ASHP_DFNG.REP │ ├── AUTOSIZE.REP │ ├── FANCOIL.REP │ ├── perfmap2z.rep │ ├── submeter.rep │ ├── dhwloop32U.rep │ ├── DHW_MFSIZING.REP │ ├── MINIMUM_RUNNING_FILE.REP │ └── ExportFileOutput.rep ├── SACRAMENTO-EXECUTIVE_CTZ2.et1 ├── wcmp │ └── CMakeLists.txt ├── diff.bat.in ├── update.bat.in ├── unit │ ├── cse_tests.unit.cpp │ ├── CMakeLists.txt │ ├── nummeth.unit.cpp │ └── cvpak.unit.cpp ├── bc4.bat ├── ExportFileOutput.cse ├── 600.cse ├── DHW_INV.cse ├── 930.cse ├── 960.cse ├── bt_test.cse ├── PVTest.cse ├── CMakeLists.txt └── shadeTest.cse ├── cmake ├── configure-and-build.cmake ├── string-finder.cmake ├── preprocess.cmake ├── update-failed.cmake ├── diff-failed.cmake ├── build.cmake ├── utility.cmake ├── configure.cmake ├── initialize-submodules.cmake └── CSEVersion.cmake ├── AUTHORS.txt ├── CONTRIBUTORS.txt ├── src ├── stdafx.cpp ├── RCDEF │ ├── readme.txt │ └── CMakeLists.txt ├── timer.h ├── culstr.natvis ├── datfcns.h ├── cgwthr.h ├── csevrsn.in.h ├── cprint.h ├── impf.h ├── DTLIMS.DEF ├── curvemap.h ├── envpak.h ├── pp.h ├── cse.rc ├── cuparse.h ├── messages.h ├── dmpak.h ├── lookup.h ├── cpgprput.cpp ├── foundation.h ├── libstubs.cpp ├── sytb.h ├── cse.h ├── exman.h ├── cncult.h ├── tdpak.h ├── gmpak.h ├── cuparsei.h ├── lookup.cpp ├── nummeth.h └── cuevf.h ├── .gitmodules ├── .pre-commit-config.yaml ├── forge.toml ├── .github ├── workflows │ ├── release.yml │ └── build-and-test.yml └── pull_request_template.md ├── LICENSE.txt ├── README.md ├── pyproject.toml └── vendor └── CMakeLists.txt /.python-version: -------------------------------------------------------------------------------- 1 | 3.13 2 | -------------------------------------------------------------------------------- /doc/src/parsers/__init__.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /test/error_handling/missing_weather_file.cse: -------------------------------------------------------------------------------- 1 | RUN 2 | -------------------------------------------------------------------------------- /doc/src/docs/probe-definitions/index.md: -------------------------------------------------------------------------------- 1 | # Probe definitions 2 | -------------------------------------------------------------------------------- /doc/src/extra/hploop.md: -------------------------------------------------------------------------------- 1 | # HPLOOP 2 | 3 | To be written. 4 | -------------------------------------------------------------------------------- /test/MF8X.cse: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cse-sim/cse/HEAD/test/MF8X.cse -------------------------------------------------------------------------------- /test/ZT5D.cse: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cse-sim/cse/HEAD/test/ZT5D.cse -------------------------------------------------------------------------------- /test/dc2.et1: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cse-sim/cse/HEAD/test/dc2.et1 -------------------------------------------------------------------------------- /test/minimum_running_file.cse: -------------------------------------------------------------------------------- 1 | WfName="CTZ12S13B.CSW" 2 | 3 | RUN 4 | -------------------------------------------------------------------------------- /test/wshp.cse: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cse-sim/cse/HEAD/test/wshp.cse -------------------------------------------------------------------------------- /test/Fresno.ET1: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cse-sim/cse/HEAD/test/Fresno.ET1 -------------------------------------------------------------------------------- /test/chdhw.cse: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cse-sim/cse/HEAD/test/chdhw.cse -------------------------------------------------------------------------------- /test/ASHP_DFNG.cse: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cse-sim/cse/HEAD/test/ASHP_DFNG.cse -------------------------------------------------------------------------------- /test/DHW_BRWL.cse: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cse-sim/cse/HEAD/test/DHW_BRWL.cse -------------------------------------------------------------------------------- /test/FanCoil.cse: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cse-sim/cse/HEAD/test/FanCoil.cse -------------------------------------------------------------------------------- /test/ashpvc2.cse: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cse-sim/cse/HEAD/test/ashpvc2.cse -------------------------------------------------------------------------------- /test/autosize.cse: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cse-sim/cse/HEAD/test/autosize.cse -------------------------------------------------------------------------------- /test/perfmap2z.cse: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cse-sim/cse/HEAD/test/perfmap2z.cse -------------------------------------------------------------------------------- /test/submeter.cse: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cse-sim/cse/HEAD/test/submeter.cse -------------------------------------------------------------------------------- /test/DHWLoop32U.cse: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cse-sim/cse/HEAD/test/DHWLoop32U.cse -------------------------------------------------------------------------------- /test/Ductest1c2.cse: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cse-sim/cse/HEAD/test/Ductest1c2.cse -------------------------------------------------------------------------------- /test/FRESNO_CTZ2.et1: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cse-sim/cse/HEAD/test/FRESNO_CTZ2.et1 -------------------------------------------------------------------------------- /test/GA_Atlanta.et1: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cse-sim/cse/HEAD/test/GA_Atlanta.et1 -------------------------------------------------------------------------------- /cmake/configure-and-build.cmake: -------------------------------------------------------------------------------- 1 | include(cmake/configure.cmake) 2 | include(cmake/build.cmake) -------------------------------------------------------------------------------- /test/DHW_MFSizing.cse: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cse-sim/cse/HEAD/test/DHW_MFSizing.cse -------------------------------------------------------------------------------- /test/RefUp.bat: -------------------------------------------------------------------------------- 1 | :: Update reference files 2 | 3 | xcopy /U /D /C /Y *.* ref 4 | 5 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /test/ref-win32-msvc/MF8X.REP: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cse-sim/cse/HEAD/test/ref-win32-msvc/MF8X.REP -------------------------------------------------------------------------------- /test/ref-win32-msvc/WSHP.REP: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cse-sim/cse/HEAD/test/ref-win32-msvc/WSHP.REP -------------------------------------------------------------------------------- /test/ref-win32-msvc/ZT5D.REP: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cse-sim/cse/HEAD/test/ref-win32-msvc/ZT5D.REP -------------------------------------------------------------------------------- /doc/src/docs/probe-definitions/.nav.yml: -------------------------------------------------------------------------------- 1 | title: Probe Definitions 2 | nav: 3 | - index.md 4 | - '*.md' -------------------------------------------------------------------------------- /test/ref-win32-msvc/CHDHW.REP: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cse-sim/cse/HEAD/test/ref-win32-msvc/CHDHW.REP -------------------------------------------------------------------------------- /test/ref-win32-msvc/ASHPVC2.REP: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cse-sim/cse/HEAD/test/ref-win32-msvc/ASHPVC2.REP -------------------------------------------------------------------------------- /test/ref-win32-msvc/ASHP_DFNG.REP: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cse-sim/cse/HEAD/test/ref-win32-msvc/ASHP_DFNG.REP -------------------------------------------------------------------------------- /test/ref-win32-msvc/AUTOSIZE.REP: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cse-sim/cse/HEAD/test/ref-win32-msvc/AUTOSIZE.REP -------------------------------------------------------------------------------- /test/ref-win32-msvc/FANCOIL.REP: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cse-sim/cse/HEAD/test/ref-win32-msvc/FANCOIL.REP -------------------------------------------------------------------------------- /test/ref-win32-msvc/perfmap2z.rep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cse-sim/cse/HEAD/test/ref-win32-msvc/perfmap2z.rep -------------------------------------------------------------------------------- /test/ref-win32-msvc/submeter.rep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cse-sim/cse/HEAD/test/ref-win32-msvc/submeter.rep -------------------------------------------------------------------------------- /test/SACRAMENTO-EXECUTIVE_CTZ2.et1: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cse-sim/cse/HEAD/test/SACRAMENTO-EXECUTIVE_CTZ2.et1 -------------------------------------------------------------------------------- /test/ref-win32-msvc/dhwloop32U.rep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cse-sim/cse/HEAD/test/ref-win32-msvc/dhwloop32U.rep -------------------------------------------------------------------------------- /doc/src/docs/assets/images/fd_refs.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cse-sim/cse/HEAD/doc/src/docs/assets/images/fd_refs.png -------------------------------------------------------------------------------- /doc/src/docs/assets/images/image1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cse-sim/cse/HEAD/doc/src/docs/assets/images/image1.png -------------------------------------------------------------------------------- /test/ref-win32-msvc/DHW_MFSIZING.REP: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cse-sim/cse/HEAD/test/ref-win32-msvc/DHW_MFSIZING.REP -------------------------------------------------------------------------------- /doc/src/docs/assets/images/pv_fixed.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cse-sim/cse/HEAD/doc/src/docs/assets/images/pv_fixed.png -------------------------------------------------------------------------------- /test/wcmp/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | add_executable(wcmp wcmp.cpp) 2 | 3 | set_target_properties(wcmp PROPERTIES FOLDER Dependencies/Test) -------------------------------------------------------------------------------- /doc/src/docs/assets/images/fd_block_slab.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cse-sim/cse/HEAD/doc/src/docs/assets/images/fd_block_slab.png -------------------------------------------------------------------------------- /doc/src/docs/assets/images/fd_block_basement.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cse-sim/cse/HEAD/doc/src/docs/assets/images/fd_block_basement.png -------------------------------------------------------------------------------- /doc/src/docs/assets/images/fd_context_slab.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cse-sim/cse/HEAD/doc/src/docs/assets/images/fd_context_slab.png -------------------------------------------------------------------------------- /doc/src/docs/assets/images/diagram-source-CSE.pptx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cse-sim/cse/HEAD/doc/src/docs/assets/images/diagram-source-CSE.pptx -------------------------------------------------------------------------------- /doc/src/docs/assets/images/fd_context_basement.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cse-sim/cse/HEAD/doc/src/docs/assets/images/fd_context_basement.png -------------------------------------------------------------------------------- /doc/src/docs/assets/images/pv_horiz_tracker_east.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cse-sim/cse/HEAD/doc/src/docs/assets/images/pv_horiz_tracker_east.png -------------------------------------------------------------------------------- /doc/src/docs/assets/images/pv_horiz_tracker_south.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cse-sim/cse/HEAD/doc/src/docs/assets/images/pv_horiz_tracker_south.png -------------------------------------------------------------------------------- /test/diff.bat.in: -------------------------------------------------------------------------------- 1 | @shell_path@ 2 | cmake -Dtest_dir="@CMAKE_SOURCE_DIR@/test" -Dref_dir="@ref_dir@" -P "@CMAKE_SOURCE_DIR@/cmake/diff-failed.cmake" 3 | -------------------------------------------------------------------------------- /doc/src/docs/assets/images/pv_tilted_tracker_south.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cse-sim/cse/HEAD/doc/src/docs/assets/images/pv_tilted_tracker_south.png -------------------------------------------------------------------------------- /test/update.bat.in: -------------------------------------------------------------------------------- 1 | @shell_path@ 2 | cmake -Dtest_dir="@CMAKE_SOURCE_DIR@/test" -Dref_dir="@ref_dir@" -P "@CMAKE_SOURCE_DIR@/cmake/update-failed.cmake" 3 | -------------------------------------------------------------------------------- /doc/src/docs/.nav.yml: -------------------------------------------------------------------------------- 1 | nav: 2 | - introduction.md 3 | - operation.md 4 | - input-structure.md 5 | - input-data 6 | - output-reports.md 7 | - probe-definitions 8 | not_in_nav: index.md 9 | -------------------------------------------------------------------------------- /AUTHORS.txt: -------------------------------------------------------------------------------- 1 | # This is the official list of CSE Authors for copyright purposes. 2 | 3 | John R. "Rob" Barnaby 4 | Charles S. Barnaby 5 | Big Ladder Software LLC 6 | Wrightsoft Corporation 7 | -------------------------------------------------------------------------------- /test/unit/cse_tests.unit.cpp: -------------------------------------------------------------------------------- 1 | #include "gtest/gtest.h" 2 | 3 | // Google Test main 4 | int main(int argc, char **argv) { 5 | ::testing::InitGoogleTest(&argc, argv); 6 | return RUN_ALL_TESTS(); 7 | } 8 | -------------------------------------------------------------------------------- /doc/src/docs/input-data/dhwheater.md: -------------------------------------------------------------------------------- 1 | # DHWHEATER 2 | 3 | DHWHEATER constructs an object representing a domestic hot water heater (or several if identical). 4 | 5 | {% include 'shared/dhwheater-doc.md' %} 6 | -------------------------------------------------------------------------------- /test/error_handling/failed_importfile.cse: -------------------------------------------------------------------------------- 1 | IMPORTFILE Data 2 | imFileName="file_does_not_exists.dat" 3 | imFreq="Year" 4 | 5 | WfName="./../Bishop.epw" 6 | 7 | GAIN 8 | gnPower = import(Data,"Column-Name") 9 | 10 | RUN -------------------------------------------------------------------------------- /doc/src/docs/input-data/dhwloopheater.md: -------------------------------------------------------------------------------- 1 | # DHWLOOPHEATER 2 | 3 | DHWHEATERLOOP constructs an object representing a hot water heater dedicated to heating DHWLOOP return water (or several if identical). 4 | 5 | {% include 'shared/dhwheater-doc.md' %} 6 | -------------------------------------------------------------------------------- /test/bc4.bat: -------------------------------------------------------------------------------- 1 | :: run beyond compare 4 2 | @echo off 3 | if exist "c:\program files\beyond compare 4\BCompare.exe" ( 4 | @c:\"program files\beyond compare 4\BCompare.exe" %* 5 | ) else ( 6 | @c:\"program files (x86)\beyond compare 4\BCompare.exe" %* 7 | ) 8 | -------------------------------------------------------------------------------- /test/ExportFileOutput.cse: -------------------------------------------------------------------------------- 1 | EXPORTFILE 2 | xfFileName=EXPORT_FILE_ABSOLUTE_PATH 3 | 4 | EXPORTFILE 5 | xfFileName=".\\..\\test\\relativePathExportFile.csv" 6 | 7 | EXPORTFILE 8 | xfFileName="noPathExportFile.csv" 9 | 10 | WfName="Bishop.epw" 11 | 12 | RUN -------------------------------------------------------------------------------- /doc/.gitignore: -------------------------------------------------------------------------------- 1 | build/ 2 | config.yaml 3 | 4 | *.egg*/ 5 | .doit.* 6 | .pytest_cache/ 7 | .vscode/ 8 | .venv/ 9 | __pycache__/ 10 | dist/ 11 | 12 | **/probe-definitions/*.md 13 | !**/probe-definitions/index.md 14 | 15 | probes.txt 16 | cullist.txt 17 | 18 | .DS_Store -------------------------------------------------------------------------------- /doc/src/extra/dhwsolartank.md: -------------------------------------------------------------------------------- 1 | # DHWSOLARTANK 2 | 3 | Solar preheating tank. Same as other tanks. 4 | 5 | Outlet of this tank is the inlet to all system tanks. 6 | 7 | Drain water heat recovery preheats water coming into this tank. 8 | 9 | ### stName 10 | 11 | **endDHWSOLARTANK** -------------------------------------------------------------------------------- /cmake/string-finder.cmake: -------------------------------------------------------------------------------- 1 | # string-finder: Returns an error if string is not found in the given file. Otherwise exits gracefully. 2 | file(READ ${file} file_content) 3 | 4 | string(FIND ${file_content} ${string} content_location) 5 | 6 | if (${content_location} LESS 0) 7 | message(FATAL_ERROR "STRING-FINDER ERROR: String, \"${string}\", not found in the file, \"${file}\".") 8 | endif() 9 | -------------------------------------------------------------------------------- /CONTRIBUTORS.txt: -------------------------------------------------------------------------------- 1 | # This file lists the people who can legally contribute code 2 | # to the CSE repository (either by signing the Contributor 3 | # License Agreement (CLA), as a copyright holder or as an 4 | # employee of a copyright holding organization). 5 | 6 | Bruce A. Wilcox (bruceawilcox) 7 | Charles S. Barnaby (chipbarnaby) 8 | John R. "Rob" Barnaby 9 | Michael O'Keefe (michael-okeefe) 10 | Neal J. F. Kruis (nealkruis) 11 | -------------------------------------------------------------------------------- /src/stdafx.cpp: -------------------------------------------------------------------------------- 1 | // Copyright (c) 1997-2019 The CSE Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style license 3 | // that can be found in the LICENSE file. 4 | 5 | // stdafx.cpp : source file that includes just the standard includes 6 | // CSE.pch will be the pre-compiled header 7 | // stdafx.obj will contain the pre-compiled type information 8 | 9 | #include "cnglob.h" 10 | 11 | // stdafx.cpp end -------------------------------------------------------------------------------- /.gitmodules: -------------------------------------------------------------------------------- 1 | [submodule "vendor/penumbra"] 2 | path = vendor/penumbra 3 | url = https://github.com/bigladder/penumbra.git 4 | [submodule "vendor/HPWHsim"] 5 | path = vendor/HPWHsim 6 | url = https://github.com/bigladder/HPWHsim.git 7 | [submodule "vendor/kiva"] 8 | path = vendor/kiva 9 | url = https://github.com/bigladder/kiva.git 10 | [submodule "vendor/googletest"] 11 | path = vendor/googletest 12 | url = https://github.com/google/googletest.git 13 | -------------------------------------------------------------------------------- /.pre-commit-config.yaml: -------------------------------------------------------------------------------- 1 | repos: 2 | - repo: https://github.com/astral-sh/ruff-pre-commit 3 | # Ruff version. 4 | rev: v0.9.9 5 | hooks: 6 | # Run the formatter (automatically fixes in-place) 7 | - id: ruff-format 8 | # Run the linter 9 | - id: ruff 10 | args: [ --fix ] 11 | - repo: local 12 | hooks: 13 | - id: mypy 14 | name: mypy 15 | entry: uv run mypy 16 | require_serial: true 17 | language: system 18 | types: [python] -------------------------------------------------------------------------------- /doc/src/docs/assets/tables/input-data--member-table-definition.csv: -------------------------------------------------------------------------------- 1 | "Header", Meaning 2 | "Units","units of measure (lb., ft, Btu, etc.) where applicable" 3 | "Legal Range","limits of valid range for numeric inputs; valid choices for *choice* members, etc." 4 | "Default","value assumed if member not given; applicable only if not required" 5 | "Required","YES if you must give this member" 6 | "Variability","how often the given expression can change: hourly, daily, etc. See sections on [expressions][expressions-overview], [statements][member-statements], and [variation frequencies][variation-frequencies-revisited]" 7 | -------------------------------------------------------------------------------- /src/RCDEF/readme.txt: -------------------------------------------------------------------------------- 1 | RCDEF 2 | 3 | RCDEF is a batch executable that generates several header and implementation 4 | files for CSE. 5 | 6 | Typical CSE input files -- 7 | 8 | cndtypes.def 9 | cnunits.def 10 | dtlims.def 11 | cnfields.def 12 | cnrecs.def 13 | 14 | During the build process, the input files are pre-processed to 15 | yield files xxx.i 16 | 17 | Command line argument details are documented in rcdef.cpp. 18 | 19 | For debugging, the following can be pasted into e.g. Visual Studio 20 | to correctly invoke the program. 21 | 22 | cndtypes.i cnunits.i dtlims.i cnfields.i cnrecs.i . NUL NUL NUL . 23 | -------------------------------------------------------------------------------- /src/timer.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) 1997-2019 The CSE Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style license 3 | // that can be found in the LICENSE file. 4 | 5 | // timer.h: Definitions for program timing routines (timer.cpp). 6 | 7 | // Function declarations 8 | void tmrInit( const char* tmrName, int tmr); 9 | void tmrStart( int tmr); 10 | void tmrStop( int tmr); 11 | double tmrCurTot( int tmr); 12 | void tmrDisp( FILE *f, int tmr, double delta); // may be if 0'd 13 | RC tmrVrDisp( int vrh, int tmr, const char* pfx="", double delta=0.); 14 | 15 | // End of timer.h 16 | 17 | -------------------------------------------------------------------------------- /forge.toml: -------------------------------------------------------------------------------- 1 | project_name = "cse" 2 | # project_short_description = "" 3 | project_type = "python" 4 | # start_year = 2025 5 | # use_app = false 6 | # version_major = 0 7 | # version_minor = 1 8 | # version_patch = 0 9 | # year = 2025 10 | # [[deps]] 11 | # name = "" # <- name of the dependency; vendor/ 12 | # git_url = "" # <- add the url used to checkout this repository 13 | # git_checkout = "" # <- add the branch, sha, or tag to check out 14 | # add_to_cmake = true # <- if true, add to CMakeLists.txt files 15 | # link_library_spec = "" # <- how library should appear in target_link_library(.); if blank, use project name -------------------------------------------------------------------------------- /src/culstr.natvis: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | {us_hCulStr} {us_csc.us_vectCULSTREL[us_hCulStr].usl_str,s} 5 | nandle 6 | 7 | us_hCulStr 8 | us_csc.us_vectCULSTREL[us_hCulStr].usl_str,s 9 | 10 | 11 | -------------------------------------------------------------------------------- /doc/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | find_program(UV_EXECUTABLE NAMES uv REQUIRED) 2 | 3 | if(CSE_BUILD_DOCUMENTATION STREQUAL "BuildWithAll") 4 | set(build_with_all_string "ALL") 5 | endif() 6 | 7 | add_custom_target( 8 | cse_documentation 9 | ${build_with_all_string} 10 | COMMAND ${UV_EXECUTABLE} run mkdocs build 11 | WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/src" 12 | ) 13 | 14 | add_test(NAME documentation.coverage 15 | COMMAND ${UV_EXECUTABLE} run coverage.py --path_to_cse $ --path_to_input_data "docs/input-data" 16 | WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/src" 17 | ) -------------------------------------------------------------------------------- /cmake/preprocess.cmake: -------------------------------------------------------------------------------- 1 | if (${compiler_name} STREQUAL "MSVC") 2 | execute_process( 3 | COMMAND "${compiler_path}" -DCSE_ARCH=${compiler_arch} -c -EP -nologo -I "${include_dir}" -Tc ${input_path} 4 | OUTPUT_FILE ${output_path} 5 | RESULT_VARIABLE exit_status 6 | ) 7 | else() 8 | execute_process( 9 | COMMAND "${compiler_path}" -E -P -I "${include_dir}" - 10 | INPUT_FILE "${input_path}" 11 | OUTPUT_FILE "${output_path}" 12 | RESULT_VARIABLE exit_status 13 | ) 14 | endif() 15 | 16 | if(NOT "${exit_status}" STREQUAL "0") 17 | message(FATAL_ERROR "C Preprocessor failed (${exit_status}): '${output_string}'") 18 | endif() 19 | -------------------------------------------------------------------------------- /doc/src/docs/index.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: "California Simulation Engine" 3 | toc: false 4 | --- 5 | 6 | # Overview {-} 7 | 8 | CSE is a general purpose building simulation model developed primarily to perform the required calculations for the California Building Energy Code Compliance for Residential buildings ([CBECC-Res](http://www.bwilcox.com/BEES/BEES.html)) software. 9 | 10 | ## CSE User Manual {-} 11 | 12 | This manual is presented as a multi-page HTML site. You can also view the entire manual as a [single page](./single_page). 13 | 14 | ## CSE Source Code {-} 15 | 16 | The CSE source code is hosted on [GitHub](https://github.com/cse-sim/cse). 17 | -------------------------------------------------------------------------------- /src/RCDEF/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # RCDEF CMakeLists.txt 2 | 3 | set(source 4 | rcdef.cpp 5 | ../lookup.cpp 6 | ../dmpak.cpp 7 | ../messages.cpp 8 | ../msgtbl.cpp 9 | ../rmkerr.cpp 10 | ../strpak.cpp 11 | ../xiopak.cpp 12 | ../libstubs.cpp 13 | ) 14 | 15 | set(headers 16 | ../cnglob.h 17 | ../lookup.h 18 | ../dmpak.h 19 | ../messages.h 20 | ../rmkerr.h 21 | ../xiopak.h 22 | ) 23 | 24 | add_executable(RCDEF ${source} ${headers}) 25 | target_compile_features(RCDEF PRIVATE cxx_std_17) 26 | target_include_directories(RCDEF PRIVATE "${CMAKE_CURRENT_SOURCE_DIR}" "${CSE_SOURCE_DIR}/src") 27 | target_compile_definitions(RCDEF PRIVATE NODTYPES) 28 | target_link_libraries(RCDEF PRIVATE cse_common_interface) 29 | -------------------------------------------------------------------------------- /cmake/update-failed.cmake: -------------------------------------------------------------------------------- 1 | set(testLog "Testing/Temporary/LastTestsFailed.log") 2 | if(EXISTS ${testLog}) 3 | file(STRINGS ${testLog} failedTests) 4 | foreach(test ${failedTests}) 5 | string(REGEX REPLACE "[0-9]+:[^;].*.(Regression|Run)" "\\1" test_type "${test}") 6 | if(${test_type} MATCHES "Regression") 7 | string(REGEX REPLACE "[0-9]+:([^;].*).Regression" "\\1" test_name "${test}") 8 | string(TOUPPER ${test_name} test_name) 9 | message("Updating: ${test_name}.REP") 10 | execute_process(COMMAND ${CMAKE_COMMAND} -E copy "${test_name}.REP" "${ref_dir}/${test_name}.REP" 11 | WORKING_DIRECTORY ${test_dir} 12 | RESULT_VARIABLE success 13 | ) 14 | endif() 15 | endforeach() 16 | else() 17 | message("Could not find test log at ${testLog}") 18 | endif() 19 | -------------------------------------------------------------------------------- /src/datfcns.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) 1997-2019 The CSE Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style license 3 | // that can be found in the LICENSE file. 4 | 5 | // datfcns.h header for datfcns.cpp -- date functions 6 | 7 | short FC dMonDay2Jday( short mon, short day, short isLeap=0); // formerly "dJDay" 10-94 8 | RC FC dStr2MonDay( const char *str, short *pMon, short *pDay); // formerly "dMonDay" 10-94 9 | short FC dStr2Mi( const char *str); // formerly "dMoni" 10-94 10 | 11 | void FC dJday2MonDay( SI jDate, SI *pMon, SI *pMDay, SI isLeap=FALSE); // was "jDate2MonDay" 10-94 12 | char * FC dMonDay2Str( SI mon, SI mDay, char *buf = NULL); // was "monDay2Str" 10-94 13 | char * FC dJday2Str( SI jDate, SI isLeap=FALSE, char *buf=NULL); // was "jDate2Str" 10-94 14 | 15 | // end of datfcns.h 16 | -------------------------------------------------------------------------------- /doc/src/parsers/util/process-raw-cnrecs.py: -------------------------------------------------------------------------------- 1 | from pathlib import Path 2 | import re 3 | 4 | 5 | def clean(text: str): 6 | return "\n".join( 7 | re.sub(r"[ \t]+", " ", line).strip().lower() 8 | for line in text.splitlines() 9 | if (line.strip() and not line.startswith("//====")) 10 | ) 11 | 12 | 13 | if __name__ == "__main__": 14 | root_dir = Path(__file__).parent.parent 15 | src_dir = root_dir / "example_src" 16 | out_dir = root_dir / "example_out" 17 | 18 | with open(src_dir / "CNRECS.DEF", "r") as file: 19 | cnrecs_raw = file.read() 20 | 21 | without_whitespace = clean(cnrecs_raw) 22 | 23 | target_path_no_white_space = out_dir / "original_cnrecs_no-whitespace.def" 24 | 25 | with open(target_path_no_white_space, "w") as file: 26 | file.write(without_whitespace) 27 | -------------------------------------------------------------------------------- /src/cgwthr.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) 1997-2019 The CSE Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style license 3 | // that can be found in the LICENSE file. 4 | 5 | // cgwthr.h -- Include file for CSE hourly weather functions in cgwthr.c 6 | 7 | /*-------------------------- PUBLIC VARIABLES ----------------------------- */ 8 | 9 | // Weather data set by cgwthr:cgWfRead() (much duplicated in Top members) 10 | //old 1-94, new decl in cnguts.h: 11 | // extern struct WFDATA NEAR Wthr; // Current hour's weather data, with xxxFactor modifications. 12 | //1-94 see cnguts.cpp:Wthr for hour's weather data; also cnguts.cpp:Wfile for weather file info; class decls in rccn.h. 13 | 14 | 15 | /*-------------------------- PUBLIC FUNCTIONS ------------------------------*/ 16 | // cgwthr.cpp 17 | extern void FC cgWthrClean( CLEANCASE cs); 18 | 19 | // end cgwthr.h 20 | -------------------------------------------------------------------------------- /doc/src/docs/shared/enduses.md: -------------------------------------------------------------------------------- 1 | {{csv_table( 2 | "Clg, Cooling 3 | Htg, Heating (includes heat pump compressor) 4 | HPBU, Heat pump resistance heating (backup and defrost) 5 | DHW, Domestic (service) hot water 6 | DHWBU, Domestic (service) hot water heating backup (HPWH resistance) 7 | DHWMFL, Domestic (service) hot water heating multi-family loop pumping and loss makeup 8 | FANC, Fans, AC and cooling ventilation 9 | FANH, Fans, heating 10 | FANV, Fans, IAQ venting 11 | FAN, Fans, other purposes 12 | AUX, HVAC auxiliaries such as pumps 13 | PROC, Process 14 | LIT, Lighting 15 | RCP, Receptacles 16 | EXT, Exterior lighting 17 | REFR, Refrigeration 18 | DISH, Dishwashing 19 | DRY, Clothes drying 20 | WASH, Clothes washing 21 | COOK, Cooking 22 | USER1, User-defined category 1 23 | USER2, User-defined category 2 24 | BT, Battery charge power 25 | PV, Photovoltaic power generation", header=False) 26 | }} -------------------------------------------------------------------------------- /test/error_handling/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | 2 | macro(error_test case error_string) 3 | get_filename_component(test_name ${case} NAME_WE) 4 | set(test_comment "! ") 5 | add_test(NAME ${test_name}.Error 6 | COMMAND $ -x${test_comment} -b -t1 "${test_name}" 7 | WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}" 8 | ) 9 | set_tests_properties(${test_name}.Error PROPERTIES WILL_FAIL TRUE) 10 | 11 | add_test(NAME ${test_name}.ErrorMatch 12 | COMMAND ${CMAKE_COMMAND} -Dfile=${test_name}.err -Dstring=${error_string} -P "${PROJECT_SOURCE_DIR}/cmake/string-finder.cmake" 13 | WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}" 14 | ) 15 | set_tests_properties(${test_name}.ErrorMatch PROPERTIES DEPENDS ${test_name}.Error ) 16 | endmacro() 17 | 18 | error_test(missing_weather_file "S0263: No wfName given in input file") 19 | error_test(no_file "P0003: Cannot open file") 20 | error_test(failed_importfile "R1901: Cannot open import file") -------------------------------------------------------------------------------- /cmake/diff-failed.cmake: -------------------------------------------------------------------------------- 1 | set(testLog "Testing/Temporary/LastTestsFailed.log") 2 | if(EXISTS ${testLog}) 3 | file(STRINGS ${testLog} failedTests) 4 | if ("${CMAKE_HOST_SYSTEM_NAME}" STREQUAL "Windows") 5 | set(bc_command bc4.bat) 6 | else () 7 | set(bc_command bcomp) 8 | endif () 9 | foreach(test ${failedTests}) 10 | string(REGEX REPLACE "[0-9]+:[^;].*.(Regression|Run)" "\\1" test_type "${test}") 11 | if(${test_type} MATCHES "Regression") 12 | string(REGEX REPLACE "[0-9]+:([^;].*).Regression" "\\1" test_name "${test}") 13 | string(TOUPPER ${test_name} test_name) 14 | message("Diffing: ${test_name}.REP") 15 | execute_process(COMMAND ${bc_command} "${test_name}.REP" "${ref_dir}/${test_name}.REP" 16 | WORKING_DIRECTORY ${test_dir} 17 | RESULT_VARIABLE success 18 | ) 19 | endif() 20 | endforeach() 21 | else() 22 | message("Could not find test log at ${testLog}") 23 | endif() 24 | -------------------------------------------------------------------------------- /src/csevrsn.in.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) 1997-2017 The CSE Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style license 3 | // that can be found in the LICENSE file. 4 | 5 | // csevrsn.h: specify current build CSE version number 6 | // Used by cse.cpp and cse.rc 7 | 8 | #ifndef MAKE_LITERAL 9 | // convert #defined value to string literal 10 | // #define NAME BOB 11 | // MAKE_LITERAL( NAME) -> "BOB" 12 | #define MAKE_LITERAL2(s) #s 13 | #define MAKE_LITERAL(s) MAKE_LITERAL2(s) 14 | #endif 15 | 16 | // version # for current build (derived from git repo tags) 17 | #define CSEVRSN_MAJOR @CSEVRSN_MAJOR@ 18 | #define CSEVRSN_MINOR @CSEVRSN_MINOR@ 19 | #define CSEVRSN_PATCH @CSEVRSN_PATCH@ 20 | 21 | #define CSEVRSN_META "@CSEVRSN_META@" 22 | 23 | // version # as quoted text 24 | #define CSEVRSN_TEXT MAKE_LITERAL(CSEVRSN_MAJOR.CSEVRSN_MINOR.CSEVRSN_PATCH@CSEVRSN_PRERELEASE@) CSEVRSN_META 25 | 26 | // csevrsn.h end 27 | -------------------------------------------------------------------------------- /cmake/build.cmake: -------------------------------------------------------------------------------- 1 | if (NOT DEFINED TARGET_NAME) 2 | if ("${CMAKE_HOST_SYSTEM_NAME}" STREQUAL "Windows") 3 | set(TARGET_NAME "ALL_BUILD") # Needed for MSVC (not necessarily all Windows builds) 4 | else () 5 | set(TARGET_NAME "all") 6 | endif () 7 | endif () 8 | message(STATUS "Building ${TARGET_NAME}...") 9 | 10 | include(cmake/utility.cmake) 11 | set_build_configuration() 12 | if (NOT DEFINED BUILD_DIRECTORY) 13 | set(BUILD_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/builds/${BUILD_CONFIGURATION}") 14 | endif () 15 | 16 | include(ProcessorCount) 17 | ProcessorCount(N) 18 | if(NOT N EQUAL 0) 19 | set(parallel_jobs ${N}) 20 | else() 21 | set(parallel_jobs 1) 22 | endif() 23 | 24 | execute_process(COMMAND ${CMAKE_COMMAND} 25 | --build . 26 | --config ${CONFIGURATION} 27 | --target ${TARGET_NAME} 28 | -j ${parallel_jobs} 29 | WORKING_DIRECTORY ${BUILD_DIRECTORY} 30 | RESULT_VARIABLE success 31 | ) 32 | if (${success} MATCHES "0") 33 | message("Build Successful!") 34 | else() 35 | message(FATAL_ERROR "Build failed.") 36 | endif() 37 | -------------------------------------------------------------------------------- /src/cprint.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) 1997-2019 The CSE Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style license 3 | // that can be found in the LICENSE file. 4 | 5 | /* cprint.h: printer defines used externally, for cprint.c 6 | CSE version derived from prpak.h 8-28-91 */ 7 | 8 | 9 | /*------------------------- FUNCTION DECLARATIONS -------------------------*/ 10 | /* cprint.c */ 11 | RC FC prOpen( int erOp, char *pathname); 12 | RC FC prClose( void); 13 | RC FC prSetPage( SI); 14 | SI FC prGetPage( void); 15 | SI FC prGetLine( void); 16 | RC FC prNewl( void); 17 | RC FC prC( char); 18 | RC FC prStrN( char *, SI); 19 | #if 0 // changing last call (cpgprput.c) to prStrN 11-7-91 20 | x RC FC prStr( char *); 21 | #endif 22 | #if 0 // eliminate -- expand any uses with prC( 0x0c or 0x0d); rob 11-91 23 | x RC FC prFf( void); 24 | x RC FC prCr( void); 25 | #endif 26 | #if 0 // no ext uses rob 11-91 27 | x RC FC sendN( char *, SI); 28 | #endif 29 | 30 | // end of cprint.h 31 |  -------------------------------------------------------------------------------- /test/unit/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | set(source 2 | cse_tests.unit.cpp 3 | strpak.unit.cpp 4 | xiopak.unit.cpp 5 | cvpak.unit.cpp 6 | nummeth.unit.cpp 7 | ${CSE_SOURCE_DIR}/src/libstubs.cpp 8 | ${CSE_BINARY_DIR}/src/untab.cpp 9 | ${CSE_BINARY_DIR}/src/dttab.cpp 10 | ) 11 | 12 | set_source_files_properties( 13 | "${CSE_BINARY_DIR}/src/untab.cpp" 14 | "${CSE_BINARY_DIR}/src/dttab.cpp" 15 | PROPERTIES GENERATED TRUE 16 | ) 17 | 18 | list(APPEND source ${cse_common_source}) 19 | add_executable(cse_tests ${source}) 20 | add_dependencies(cse_tests generate_rcdef_outputs) 21 | target_compile_definitions(cse_tests PRIVATE SOURCE_DIR="${CMAKE_SOURCE_DIR}") 22 | 23 | target_include_directories(cse_tests PRIVATE 24 | "${CSE_SOURCE_DIR}/src" 25 | "${CSE_BINARY_DIR}/src" 26 | "${gtest_SOURCE_DIR}/include" 27 | ) 28 | 29 | target_link_libraries(cse_tests PRIVATE gtest cse_common_interface) 30 | target_compile_features(cse_tests PUBLIC cxx_std_17) 31 | 32 | include(GoogleTest) 33 | 34 | gtest_discover_tests(cse_tests TEST_SUFFIX .Unit) 35 | -------------------------------------------------------------------------------- /doc/src/docs/input-data/dhwmeter.md: -------------------------------------------------------------------------------- 1 | # DHWMETER 2 | 3 | A DHWMETER object is a user-defined "device" that records water consumption as simulated by CSE. The data accumulated by DHWMETERs can be reported at hourly, daily, monthly, and annual (run) intervals by using REPORTs and EXPORTs of type DHWMTR. Water use is reported in gallons. 4 | 5 | 6 | DHWMETERs account for water use in the following pre-defined end uses. The abbreviations in parentheses are used in DHWMTR report headings. 7 | 8 | - Total water use (Total) 9 | - Unknown end use (Unknown) 10 | - Miscellaneous draws (Faucet) 11 | - Shower (Shower) 12 | - Bathtub (Bath) 13 | - Clothes washer (CWashr) 14 | - Dishwasher (DWashr) 15 | 16 | [DHWSYS][dhwsys] items wsWHhwMtr and wsFXhwMtr specify the DHWMETER(s) to which water consumption is accumulated. 17 | 18 | ### dhwMtrName 19 | 20 | Name of meter: required for assigning water uses to the DHWMETER. 21 | 22 | {{ 23 | member_table({ 24 | "units": "", 25 | "legal_range": "*63 characters*", 26 | "default": "*none*", 27 | "required": "Yes", 28 | "variability": "constant" 29 | }) 30 | }} 31 | 32 | ### endDhwMeter 33 | 34 | **Related Probes:** 35 | 36 | - @[DHWmeter][p_dhwmeter] 37 | -------------------------------------------------------------------------------- /.github/workflows/release.yml: -------------------------------------------------------------------------------- 1 | name: Release 2 | 3 | on: 4 | release: 5 | types: 6 | - created 7 | 8 | jobs: 9 | release-cse: 10 | name: Deploy CSE release 11 | runs-on: windows-2022 12 | defaults: 13 | run: 14 | shell: bash 15 | steps: 16 | - name: Checkout 17 | uses: actions/checkout@v4 18 | with: 19 | fetch-depth: 0 20 | submodules: recursive 21 | - name: Install uv and set the python version 22 | uses: astral-sh/setup-uv@v5 23 | with: 24 | python-version: "3.13" 25 | - name: Build CSE 26 | run: cmake -DBUILD_ARCHITECTURE=32 -DCOMPILER_ID=msvc -DCONFIGURATION=Release -DBUILD_DIRECTORY=build -DBUILD_DOCS_WITH_ALL=ON -P cmake/configure-and-build.cmake 27 | - name: Upload executable to release assets 28 | uses: softprops/action-gh-release@v2 29 | with: 30 | files: build/CSE.exe 31 | - name: Update gh-pages 32 | uses: peaceiris/actions-gh-pages@v3 33 | with: 34 | github_token: ${{ secrets.GITHUB_TOKEN }} 35 | publish_dir: doc/build 36 | user_name: 'cse-ci' 37 | user_email: 'ci@cse.org' 38 | full_commit_message: "Update docs for ${{ github.event.release.tag_name }}." 39 | -------------------------------------------------------------------------------- /cmake/utility.cmake: -------------------------------------------------------------------------------- 1 | macro(set_build_configuration) 2 | if ("${CMAKE_HOST_SYSTEM_NAME}" STREQUAL "Windows") 3 | set(OS_ID "win") 4 | if (NOT DEFINED COMPILER_ID) 5 | set(COMPILER_ID "msvc") 6 | endif () 7 | if (NOT DEFINED BUILD_ARCHITECTURE) 8 | set(BUILD_ARCHITECTURE "32") 9 | endif () 10 | if ("${BUILD_ARCHITECTURE}" STREQUAL "64") 11 | set(TARGET_VS_ARCHITECTURE "x64") 12 | else () 13 | set(TARGET_VS_ARCHITECTURE "Win32") 14 | endif () 15 | else () 16 | if (NOT DEFINED CONFIGURATION) 17 | set(CONFIGURATION Release) 18 | endif () 19 | string(TOLOWER "-${CONFIGURATION}" CONFIGURATION_STRING) 20 | if (NOT DEFINED BUILD_ARCHITECTURE) 21 | set(BUILD_ARCHITECTURE "64") 22 | endif () 23 | if ("${CMAKE_HOST_SYSTEM_NAME}" STREQUAL "Darwin") 24 | set(OS_ID "macos") 25 | set(COMPILER_ID "appleclang") 26 | elseif ("${CMAKE_HOST_SYSTEM_NAME}" STREQUAL "Linux") 27 | set(OS_ID "linux") 28 | set(COMPILER_ID "gcc") 29 | endif () 30 | endif () 31 | set(BUILD_CONFIGURATION "${OS_ID}${BUILD_ARCHITECTURE}-${COMPILER_ID}${CONFIGURATION_STRING}") 32 | endmacro() 33 | -------------------------------------------------------------------------------- /src/impf.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) 1997-2019 The CSE Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style license 3 | // that can be found in the LICENSE file. 4 | 5 | // impf.h header for Import Files for CSE 2-94 6 | 7 | 8 | // largest field number to accept (expect far fewer fields in a file) 9 | const int FNRMAX = 1024; 10 | 11 | // compile support functions used from cuparse.cpp 12 | RC impFcn( const char* impfName, TI* iffnmi, int fileIx, int inputLineNo, IVLCH* imFreq, const char* fieldName, SI* fnmi); 13 | RC impFcn( const char* impfName, TI* iffnmi, int fileIx, int inputLineNo, IVLCH* imFreq, SI fnr); 14 | 15 | RC FC clearImpf(); // Import stuff special clear function 16 | RC FC topImpf(); // check/process ImportFiles at end of input 17 | RC FC impfStart(); 18 | RC FC impfAfterWarmup(); 19 | void FC impfEnd(); 20 | void FC impfIvl(IVLCH ivl); 21 | 22 | // runtime import-field functions in impf.cpp, used from cueval.cpp. 23 | RC impFldNmN( int iffnmi, int fnmi, float *pv, int fileIx, int line, MSGORHANDLE* pms); 24 | RC impFldNmS( int iffnmi, int fnmi, char **pv, int fileIx, int line, MSGORHANDLE* pms); 25 | RC impFldNrN( int iffnmi, int fnr, float *pv, int fileIx, int line, MSGORHANDLE* pms); 26 | RC impFldNrS( int iffnmi, int fnr, char **pv, int fileIx, int line, MSGORHANDLE* pms); 27 | 28 | // end of impf.h 29 | -------------------------------------------------------------------------------- /src/DTLIMS.DEF: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 1997-2019 The CSE Authors. All rights reserved. 2 | Use of this source code is governed by a BSD-style license 3 | that can be found in the LICENSE file. */ 4 | 5 | /* DTLIMS.DEF: limit definitions for TAKEOFF/CALRES/CSE 6 | 7 | This file is an input file for the record definer RCDEF.EXE, 8 | named on the command line, argument 3. */ 9 | 10 | /* Limit types 11 | 12 | Produces: defines in limits.h; also used in field descriptors. 13 | 14 | If reordered, recompile code using limits defines (LMxxxx) from limits.h. 15 | 16 | Limit types are believed NOT to be stored in pdbs. 17 | 18 | Limits are checked in cvpak.c:cvlmchck (12-89). */ 19 | 20 | 21 | /* 22 | Type Name Description (comments) 23 | --------- ----------------------------- */ 24 | LMNONE /* No limits (must be first as expected value is 0) */ 25 | LMFR /* 0 <= val <= 1.0 */ 26 | LMFGZ /* 0 < val <= 1.0 */ 27 | LMGEZ /* >= 0 */ 28 | LMGZ /* > 0 */ 29 | LMDAYHR /* 0 <= val <= 24.0. Only one use 1-25-91 */ 30 | LMDOY /* 1 <= val <= 365 */ 31 | LMLEZ /* <= 0 rob 2-91 for HSZN.QCOOLMAX */ 32 | LMLZ /* < 0 rob 5-91 for COOLCOIL.K1 */ 33 | LMNZ /* != 0 rob 2-91 (uses undone, could remove) */ 34 | LMGE1 /* >= 1 */ 35 | LMG1 /* > 1 */ 36 | *END 37 | 38 | /* end of dtlims.def */ 39 |  -------------------------------------------------------------------------------- /doc/src/docs/input-data/perimeter.md: -------------------------------------------------------------------------------- 1 | # PERIMETER 2 | 3 | PERIMETER defines a subobject belonging to the current zone that represents a length of exposed edge of a (slab on grade) floor. 4 | 5 | ### prName 6 | 7 | Optional name of perimeter. 8 | 9 | {{ 10 | member_table({ 11 | "units": "", 12 | "legal_range": "*63 characters*", 13 | "default": "*none*", 14 | "required": "No", 15 | "variability": "constant" 16 | }) 17 | }} 18 | 19 | ### prLen 20 | 21 | Type: float 22 | 23 | Length of exposed perimeter. 24 | 25 | {{ 26 | member_table({ 27 | "units": "ft", 28 | "legal_range": "*x* > 0", 29 | "default": "*none*", 30 | "required": "Yes", 31 | "variability": "constant" 32 | }) 33 | }} 34 | 35 | ### prF2 36 | 37 | Type: float 38 | 39 | Perimeter conduction per unit length. 40 | 41 | {{ 42 | member_table({ 43 | "units": "Btuh/ft-°F", 44 | "legal_range": "*x* > 0", 45 | "default": "*none*", 46 | "required": "Yes", 47 | "variability": "constant" 48 | }) 49 | }} 50 | 51 | ### endPerimeter 52 | 53 | Optionally indicates the end of the perimeter definition. 54 | 55 | {{ 56 | member_table({ 57 | "units": "", 58 | "legal_range": "", 59 | "default": "*none*", 60 | "required": "No", 61 | "variability": "constant" 62 | }) 63 | }} 64 | 65 | **Related Probes:** 66 | 67 | - @[perimeter][p_perimeter] 68 | - @[xsurf][p_xsurf] 69 | -------------------------------------------------------------------------------- /doc/src/docs/input-data/afmeter.md: -------------------------------------------------------------------------------- 1 | # AFMETER 2 | 3 | An AFMETER object is a user-defined "device" that records zone air flows as simulated by CSE. The user defines AFMETERs and assigns them to zones (see ZONE znAFMtr). 4 | 5 | Air flow is recorded in standard air cfm (density 0.075 lb/ft3) at subhour, hour, day, month, and year intervals. At intervals of an hour and longer, values are averaged. Flows are categorized according to IZXFER izAFCat. 6 | 7 | If any AFMETERs are defined, an additional AFMETER "sum_of_AFMETERs" is automatically created where the sums of all user-define AFMETERs are accumulated. 8 | 9 | Note that *only* AirNet flows are recorded. 10 | 11 | AFMETER results can be REPORTed using rpType=AFMTR (or EXPORTed using exType=AFMTR). See [Air Flow Meter Report][air-flow-meter-report]. 12 | 13 | 14 | ### afMtrName 15 | 16 | Name of meter: required for assigning air flows to the AFMETER. 17 | 18 | {{ 19 | member_table({ 20 | "units": "", 21 | "legal_range": "*63 characters*", 22 | "default": "*none*", 23 | "required": "Yes", 24 | "variability": "constant" 25 | }) 26 | }} 27 | 28 | ### endAFMeter 29 | 30 | Indicates the end of the meter definition. Alternatively, the end of the meter definition can be indicated by the declaration of another object or by END. 31 | 32 | {{ 33 | member_table({ 34 | "units": "", 35 | "legal_range": "", 36 | "default": "*none*", 37 | "required": "No", 38 | "variability": "constant" 39 | }) 40 | }} 41 | 42 | **Related Probes:** 43 | 44 | - @[afmeter][p_afmeter] 45 | -------------------------------------------------------------------------------- /LICENSE.txt: -------------------------------------------------------------------------------- 1 | Copyright (c) 1997-2016 The CSE Authors. All rights reserved. 2 | 3 | Redistribution and use in source and binary forms, with or without 4 | modification, are permitted provided that the following conditions are met: 5 | 6 | * Redistributions of source code must retain the above copyright notice, this 7 | list of conditions and the following disclaimer. 8 | 9 | * Redistributions in binary form must reproduce the above copyright notice, 10 | this list of conditions and the following disclaimer in the documentation 11 | and/or other materials provided with the distribution. 12 | 13 | * Neither the name of the copyright holders nor the names of its contributors 14 | may be used to endorse or promote products derived from this software 15 | without specific prior written permission from the copyright holders. 16 | 17 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 18 | AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 19 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 20 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE 21 | FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 22 | DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 23 | SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 24 | CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 25 | OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 26 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 27 | -------------------------------------------------------------------------------- /src/curvemap.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) 1997-2024 The CSE Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style license 3 | // that can be found in the LICENSE file. 4 | 5 | // curvemap.h -- include file for curve and performance map 6 | 7 | #ifndef _CURVEMAP_H 8 | #define _CURVEMAP_H 9 | 10 | // enum class PMSPEED { MIN, RATED, MAX }; in cnglob.h 11 | 12 | class PMACCESS 13 | { 14 | public: 15 | PMACCESS(); 16 | ~PMACCESS(); 17 | RC pa_Init(const PERFORMANCEMAP* pPM, record* pParent, const char* tag, double capRef); 18 | 19 | double pa_GetSpeedF(PMSPEED s) const { return s==PMSPEED::MIN ? pa_speedFMin : s==PMSPEED::MAX ? 1. : pa_speedFRated; } 20 | double pa_GetSpeedFMin() const { return pa_GetSpeedF(PMSPEED::MIN); }; 21 | 22 | RC pa_GetCapInp(float tdb, float speedF, float& cap, float& inp); 23 | RC pa_GetCapInpRatios(float tdb, float speedF, double& capRat, double& inpRat); 24 | RC pa_GetRatedCapCOP(float tdb, float& cap, float& COP, PMSPEED whichSpeed = PMSPEED::RATED); 25 | double pa_GetRatedFanFlowFactor(float speedF); 26 | 27 | record* pa_pParent; // owner 28 | const class PERFORMANCEMAP* pa_pPERFORMANCEMAP; // source PERFORMANCEMAP 29 | 30 | class Btwxt::RegularGridInterpolator* pa_pRGI; // associated Btwxt interpolator 31 | 32 | std::vector pa_vTarget; 33 | std::vector pa_vResult; 34 | 35 | double pa_capRef; // reference capacity, Btuh 36 | 37 | double pa_tdbRated; 38 | 39 | double pa_speedFMin; // minimum speed fraction 40 | double pa_speedFRated; // speed fraction for rated values 41 | 42 | }; // class PMACCESS 43 | 44 | 45 | #endif // _CURVEMAP_H 46 | 47 | -------------------------------------------------------------------------------- /src/envpak.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) 1997-2019 The CSE Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style license 3 | // that can be found in the LICENSE file. 4 | 5 | // envpak.h: defs and decls for envpak.cpp 6 | 7 | /*-------------------------------- DEFINES --------------------------------*/ 8 | 9 | #if !defined( BUILDING_RCDEF) 10 | // Constants for enkimode() argument 11 | #define KISILENT 0 // Do not beep when interrupt is detected 12 | #define KIBEEP 1 // Issue a beep when interrupt is detected 13 | #define KICLEAR 0 // Unconditionally clear interrupt flag 14 | #define KILEAVEHIT 2 // Clear interrupt flag unless an unprocessed ^C is indicated. 15 | 16 | /*------------------------- FUNCTION DECLARATIONS -------------------------*/ 17 | WStr enExePath(); // path to current .exe 18 | WStr enExeInfo( WStr exePath, int& codeSize); // timestamp (from header) of .exe 19 | void FC ensystd( IDATETIME*); // Return system date and time 20 | LDATETIME FC ensysldt(); // Return system date/time as LDATETIME 21 | void FC enkiinit(SI); // Initialize keyboard interrupt handler 22 | void FC enkimode(SI); // Set keyboard interrupt mode 23 | int enkichk(); // Check if keyboard interrupt recvd 24 | 25 | UINT doControlFP(); // (maybe) unmask FP exceptions 26 | 27 | #endif 28 | 29 | void FC hello(); // entry fcn 30 | void FC byebye( int exitCode); // exit fcn 31 | 32 | void FC cknull(); // check for memory clobbers 33 | /* also public but called ONLY from msc lib or interrupt 34 | * INT matherr( struct exception *); * private math runtime error fcn * 35 | * void fpeErr( INT, INT); * intercepts floating point errors * 36 | */ 37 | 38 | // end of envpak.h 39 | -------------------------------------------------------------------------------- /test/600.cse: -------------------------------------------------------------------------------- 1 | // ----- TOP LEVEL ----- 2 | 3 | #define CASE "600" 4 | 5 | #define ACH 0.5 6 | #define INTGAIN 682.36 //internal gain Btuh = 200 W 7 | 8 | #define ABSORP 0.6 //absorptivity of exterior surface 9 | #define INABSORP 0.6 //absorptivity of interior surface 10 | #define WALEXF 5.160 //wall exterior film, emissivity = 0.9 11 | #define WINEXF 3.698 //window exterior film, emissivity = 0.9 12 | #define INFILM 1.461 //interior film, emissivity = 0.9 13 | #define FLOORCON lw_floor //floor construction, light weight 14 | #define WALLCON lw_wall //wall construction 15 | #define HEATCAP 0.0001 //total construction heat capacity 16 | #define SURFTYPE DELAYED //delayed, quick or auto 17 | 18 | #define SOUTHWIN 19 | #define WINH 6.562 //window height 20 | #define WINW 9.842 //window width 21 | #define OHDPTH 0 //depth of overhang 22 | #define GLASSTYPE Best_Double 23 | 24 | #define HEATTEMP 68 //setpoint for heating 25 | #define COOLTEMP 80.6 //setpoint for cooling 26 | #define VENTFRAC 0 //setpoint for natural ventilation 27 | 28 | // #define SOLTARGET //targets solar gain to walls and floor 29 | 30 | #define JAN4REP 1 //1 for hourly reports, 0 otherwise 31 | #define JAN4NAME "600jan4.csv" 32 | #define MAR5REP 1 //1 for hourly reports, 0 otherwise 33 | #define MAR5NAME "mar5s.csv" 34 | #define JUL27REP 1 //1 for hourly reports, 0 otherwise 35 | #define JUL27NAME "600jul27s.csv" 36 | 37 | dbgPrintMask = $dayOfYear < 32 ? 4096 : 0; 38 | 39 | #include "BESTEST.cin" 40 | -------------------------------------------------------------------------------- /test/DHW_INV.cse: -------------------------------------------------------------------------------- 1 | // DHW_INV.cse -- HPWH tank temperature inversion test case 2 | 3 | // CTZ12 Weather 4 | WfName="CTZ12S13b.CSW" 5 | dbgPrintMask = $dayofyear == 15 ? 256 : 0 6 | repHdrL = "Inversion test case" 7 | 8 | wuDays=30 9 | nSubSteps=6 10 | 11 | // Hourly use schedules 12 | #define WHUSE01 hourval( \ 13 | 0, 0, 0, 0, 0, 0, 0, 0, \ 14 | 1, 1, 1, 1, 1, 0, 1, 0, \ 15 | 0, 0, 0, 0, 0, 0, 0, 0 ) 16 | 17 | #define TSUP01 hourval( \ 18 | 50, 50, 50, 50, 50, 50, 50, 50, \ 19 | 50, 50, 50, 50, 113, 50, 50, 50, \ 20 | 50, 50, 50, 50, 50, 50, 50, 50 ) 21 | 22 | 23 | //==================================================================== 24 | // single system 25 | 26 | METER mtrElec 27 | METER Fuel0 28 | DHWMETER FX0 29 | DHWMETER WH0 30 | 31 | DHWSYS "DS0" 32 | wsMult = 1 33 | wsElecMtr = mtrElec 34 | wsFXHWMTR = FX0 35 | wsWHHWMTR = WH0 36 | wsTInlet = TSUP01 37 | wsTSetpoint = 131 // 55 C 38 | wsTUse = 122 // 50 C 39 | wsUse = 15.8503 * WHUSE01 // 1 l/min 40 | wsDSM = 1 41 | wsSDLM = 1 42 | 43 | DHWHEATER "ResTank" 44 | whType = SmallStorage 45 | whHeatSrc = ResistanceX 46 | whTEx = 68 // 20 C 47 | whVol = 52.83 // 200 l 48 | whEF = .92 49 | whResHtPwr = 1000 50 | 51 | 52 | DELETE REPORT EB 53 | 54 | REPORT rpType=MTR rpMeter = mtrElec rpFreq=MONTH rpBtuSf = 3413 55 | REPORT rpType=MTR rpMeter = mtrElec rpFreq=HOUR rpDayBeg=jan 15 rpDayEnd = jan 15 rpBtuSf = 3413 56 | 57 | REPORT rpType=DHWMTR rpDHWMeter = WH0 rpFreq=MONTH 58 | REPORT rpType=DHWMTR rpDHWMeter = WH0 rpFreq=HOUR rpDayBeg=jan 15 rpDayEnd = jan 15 59 | 60 | //============================================================== 61 | 62 | 63 | RUN 64 | 65 | 66 | 67 | 68 | 69 | -------------------------------------------------------------------------------- /test/930.cse: -------------------------------------------------------------------------------- 1 | // ----- TOP LEVEL ----- 2 | 3 | #define CASE "930" 4 | 5 | #define ACH 0.5 6 | #define INTGAIN 682.36 //internal gain Btuh = 200 W 7 | 8 | #define ABSORP 0.6 //absorptivity of exterior surface 9 | #define INABSORP 0.6 //absorptivity of interior surface 10 | #define WALEXF 5.160 //wall exterior film, emissivity = 0.9 11 | #define WINEXF 3.698 //window exterior film, emissivity = 0.9 12 | #define INFILM 1.461 //interior film, emissivity = 0.9 13 | #define FLOORCON hw_floor //floor construction, light weight 14 | #define WALLCON hw_wall //wall construction 15 | #define HEATCAP 0.0001 //total construction heat capacity 16 | #define SURFTYPE DELAYED //delayed, quick or auto 17 | 18 | #define EASTWESTWIN 19 | #define WINH 6.562 //window height 20 | #define WINW 9.842 //window width 21 | #define OHDPTH 3.281 //depth of overhang 22 | #define GLASSTYPE Best_Double 23 | 24 | #define HEATTEMP 68 //setpoint for heating 25 | #define COOLTEMP 80.6 //setpoint for cooling 26 | #define VENTFRAC 0 //setpoint for natural ventilation 27 | 28 | // #define SOLTARGET //targets solar gain to walls and floor 29 | 30 | #define REPTYPE MTR // ZEB for free-float cases, else MTR 31 | #define JAN4REP 0 //1 for hourly reports, 0 otherwise 32 | #define JAN4NAME "930jan4.csv" 33 | #define MAR5REP 0 //1 for hourly reports, 0 otherwise 34 | #define MAR5NAME "930mar5.csv" 35 | #define JUL27REP 0 //1 for hourly reports, 0 otherwise 36 | #define JUL27NAME "930jul27.csv" 37 | 38 | #include "BESTEST.cin" 39 | -------------------------------------------------------------------------------- /src/pp.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) 1997-2019 The CSE Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style license 3 | // that can be found in the LICENSE file. 4 | 5 | /* pp.h: public declarations CSE user language input file preprocessor */ 6 | 7 | /*-------------------------------- OPTIONS --------------------------------*/ 8 | 9 | /*-------------- VARIABLES accessed outside of pp.cpp -------------*/ 10 | extern int VrInp; // 0 or virtual report handle (vrpak.cpp) for open INPut listing virtual report. 11 | 12 | /*--------------- FUNCTIONS called outside of pp.cpp files --------------*/ 13 | 14 | // command line interface for pp switches 15 | inline bool IsCmdLineSwitch( int c) { return c == '-'; } 16 | bool ppClargIf( const char* s, RC& rc); 17 | 18 | // re getting preprocessed text (see pp.cpp for local fcns) 19 | void FC ppClean( CLEANCASE cs); // init/cleanup 20 | void ppAddPath( const char* paths); // add path(s) to search for input/include files 21 | bool ppFindFile( const char *fname, char *fullPath); // search pp paths, return full file path 22 | #if 0 23 | bool ppFindFile( char* &fname); // ditto, update fname to path found 24 | #endif 25 | bool ppFindFile(CULSTR& fname); // ditto, update fname to path found 26 | RC FC ppOpen( const char* fname, const char* defex); // open file 27 | void FC ppClose(); // close file(s) 28 | USI FC ppGet( char *p, USI n); // get preprocessed text 29 | 30 | // input listing 31 | SI FC openInpVr(); 32 | void FC closeInpVr(); 33 | void FC lisFlushThruLine( int line); 34 | void FC lisThruLine( int line); 35 | void FC lisMsg( char *p, int dashB4, int dashAf); 36 | int FC lisFind( int fileIx, int line, const char* p, int *pPlace); 37 | void FC lisInsertMsg( int place, char *p, int dashB4, int dashAf); 38 | 39 | // end of pp.h 40 | -------------------------------------------------------------------------------- /doc/src/docs/input-data/dhwpump.md: -------------------------------------------------------------------------------- 1 | # DHWPUMP 2 | 3 | DHWPUMP constructs an object representing a domestic hot water circulation pump (or more than one if identical). 4 | 5 | ### wpName 6 | 7 | Optional name of pump; give after the word “DHWPUMP” if desired. 8 | 9 | {{ 10 | member_table({ 11 | "units": "", 12 | "legal_range": "*63 characters*", 13 | "default": "*none*", 14 | "required": "No", 15 | "variability": "constant" 16 | }) 17 | }} 18 | 19 | ### wpMult 20 | 21 | Type: integer 22 | 23 | Number of identical pumps of this type. Any value $>1$ is equivalent to repeated entry of the same DHWPUMP. 24 | 25 | {{ 26 | member_table({ 27 | "units": "", 28 | "legal_range": "x > 0", 29 | "default": "1", 30 | "required": "No", 31 | "variability": "constant" 32 | }) 33 | }} 34 | 35 | ### wpPwr 36 | 37 | Type: float 38 | 39 | Pump power. 40 | 41 | {{ 42 | member_table({ 43 | "units": "W", 44 | "legal_range": "x > 0", 45 | "default": "0", 46 | "required": "No", 47 | "variability": "hourly" 48 | }) 49 | }} 50 | 51 | ### wpElecMtr 52 | 53 | Type: mtrName 54 | 55 | Name of METER object, if any, to which DHWPUMP electrical energy use is recorded (under end use DHW). 56 | 57 | {{ 58 | member_table({ 59 | "units": "", 60 | "legal_range": "*name of a METER*", 61 | "default": "*Parent DHWSYS wsElecMtr*", 62 | "required": "No", 63 | "variability": "constant" 64 | }) 65 | }} 66 | 67 | ### endDHWPump 68 | 69 | Optionally indicates the end of the DHWPUMP definition. 70 | 71 | {{ 72 | member_table({ 73 | "units": "", 74 | "legal_range": "", 75 | "default": "*none*", 76 | "required": "No", 77 | "variability": "" 78 | }) 79 | }} 80 | 81 | **Related Probes:** 82 | 83 | - @[DHWPump][p_dhwpump] 84 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | [![Build and Test](https://github.com/cse-sim/cse/workflows/Build%20and%20Test/badge.svg)](https://github.com/cse-sim/cse/actions?query=branch%3Amain) 2 | 3 | ## California Simulation Engine (CSE) 4 | 5 | CSE is a general purpose building simulation model developed primarily to perform the required calculations for the California Building Energy Code Compliance for Residential buildings ([CBECC-Res](http://www.bwilcox.com/BEES/BEES.html)) software. 6 | 7 | ### CSE User Manual 8 | 9 | The CSE User Manual can be found on the [CSE Documentation Web Site](https://cse-sim.github.io/cse): 10 | 11 | - [HTML Format](https://cse-sim.github.io/cse/single_page/) (single page) 12 | - [HTML Format](https://cse-sim.github.io/cse/introduction/) (multi page) 13 | 14 | ### Issues and Issue Reporting 15 | 16 | All known issues are listed on our [Issue Tracker]. New issues can be reported there, as well. 17 | 18 | [Issue Tracker]: https://github.com/cse-sim/cse/issues 19 | 20 | ### Development 21 | 22 | CSE is configured as a CMake project. Currently, CMake is only configured to generate Microsoft Visual Studio solutions compiled with Microsoft Visual C++ (other generators and compilers will not work). A batch script is set up for automatic project setup. Simply double click or run the **build.bat** script in the root directory. All products (e.g., CSE.exe) will be placed in a directory called **msvc**. 23 | 24 | #### Testing 25 | 26 | Automated testing of your build can be executed by running after building the entire solution 27 | 28 | `ctest -C Release` 29 | 30 | from the **msvc\\build** directory. 31 | 32 | #### Dependencies 33 | 34 | - Microsoft Visual Visual C++ (v142 toolset) 35 | - CMake 3.10 or later 36 | 37 | Note: Generating the documentation requires additional tools. See [doc\\README.md](doc/README.md). 38 | -------------------------------------------------------------------------------- /test/960.cse: -------------------------------------------------------------------------------- 1 | // ----- TOP LEVEL ----- 2 | 3 | #define CASE "960" 4 | 5 | #define ACH 0.5 6 | #define INTGAIN 682.36 //internal gain Btuh = 200 W 7 | 8 | #define ABSORP 0.6 //absorptivity of exterior surface 9 | #define INABSORP 0.6 //absorptivity of interior surface 10 | #define WALEXF 5.160 //wall exterior film, emissivity = 0.9 11 | #define WINEXF 3.698 //window exterior film, emissivity = 0.9 12 | #define INFILM 1.461 //interior film, emissivity = 0.9 13 | #define FLOORCON lw_floor //floor construction 14 | #define WALLCON lw_wall //wall construction 15 | #define HEATCAP 0.1 //total construction heat capacity 16 | #define SURFTYPE AUTO //delayed, quick or auto 17 | 18 | #define SOUTHWIN 19 | #define WINH 6.562 //window height 20 | #define WINW 9.842 //window width 21 | #define OHDPTH 0 //depth of overhang 22 | #define GLASSTYPE Best_Double 23 | 24 | #define HEATTEMP 68 //setpoint for heating 25 | #define COOLTEMP 80.6 //setpoint for cooling 26 | #define VENTFRAC 0 //setpoint for natural ventilation 27 | #define SUNZONE //makes sunspace zone 28 | 29 | #define HOURLYTEMPS // gets ZEB reports 30 | #define JAN4REP 1 //1 for hourly reports, 0 otherwise 31 | #define JAN4NAME "960jan4.csv" 32 | #define MAR5REP 0 //1 for hourly reports, 0 otherwise 33 | #define MAR5NAME "960mar5.csv" 34 | #define JUL27REP 1 //1 for hourly reports, 0 otherwise 35 | #define JUL27NAME "960jul27.csv" 36 | #define YEARREP 1 //1 for hourly reports, 0 otherwise 37 | #define YEARNAME "960year.csv" 38 | 39 | #include "BESTEST.cin" 40 | -------------------------------------------------------------------------------- /doc/src/docs/input-data/.nav.yml: -------------------------------------------------------------------------------- 1 | title: Input Data 2 | nav: 3 | - index.md 4 | - TOP Members: top-members.md 5 | - HOLIDAY: holiday.md 6 | - DESCOND: descond.md 7 | - MATERIAL: material.md 8 | - CONSTRUCTION: construction.md 9 | - FOUNDATION: foundation.md 10 | - FNDBLOCK: fndblock.md 11 | - LAYER: layer.md 12 | - GLAZETYPE: glazetype.md 13 | - METER: meter.md 14 | - DHWMETER: dhwmeter.md 15 | - AFMETER: afmeter.md 16 | - LOADMETER: loadmeter.md 17 | - ACCUMULATOR: accumulator.md 18 | - ZONE: zone.md 19 | - GAIN: gain.md 20 | - SURFACE: surface.md 21 | - WINDOW: window.md 22 | - SHADE: shade.md 23 | - SGDIST: sgdist.md 24 | - DOOR: door.md 25 | - PERIMETER: perimeter.md 26 | - TERMINAL: terminal.md 27 | - IZXFER: izxfer.md 28 | - DOAS: doas.md 29 | - RSYS: rsys.md 30 | - DUCTSEG: ductseg.md 31 | - PERFORMANCEMAP: performancemap.md 32 | - DHWDAYUSE: dhwdayuse.md 33 | - DHWUSE: dhwuse.md 34 | - DHWSYS: dhwsys.md 35 | - DHWHEATER: dhwheater.md 36 | - DHWLOOPHEATER: dhwloopheater.md 37 | - DHWHEATREC: dhwheatrec.md 38 | - DHWTANK: dhwtank.md 39 | - DHWPUMP: dhwpump.md 40 | - DHWLOOP: dhwloop.md 41 | - DHWLOOPPUMP: dhwlooppump.md 42 | - DHWLOOPSEG: dhwloopseg.md 43 | - DHWLOOPBRANCH: dhwloopbranch.md 44 | - DHWSOLARSYS: dhwsolarsys.md 45 | - DHWSOLARCOLLECTOR: dhwsolarcollector.md 46 | - PVARRAY: pvarray.md 47 | - SHADEX: shadex.md 48 | - BATTERY: battery.md 49 | - AIRHANDLER: airhandler.md 50 | - HEATPLANT: heatplant.md 51 | - BOILER: boiler.md 52 | - COOLPLANT: coolplant.md 53 | - CHILLER: chiller.md 54 | - TOWERPLANT: towerplant.md 55 | - REPORTFILE: reportfile.md 56 | - REPORT: report.md 57 | - REPORTCOL: reportcol.md 58 | - EXPORTFILE: exportfile.md 59 | - EXPORT: export.md 60 | - EXPORTCOL: exportcol.md 61 | - IMPORTFILE: importfile.md -------------------------------------------------------------------------------- /pyproject.toml: -------------------------------------------------------------------------------- 1 | [project] 2 | name = "cse" 3 | version = "0.1.0" 4 | description = "Source code for the California Simulation Engine and documentation" 5 | requires-python = ">=3.12" 6 | readme = "README.md" 7 | keywords = ["cse", "energy-modeling", "simulation"] 8 | dependencies = [ 9 | "beautifulsoup4>=4.13.4", 10 | "mkdocs-autorefs>=1.4.2", 11 | "mkdocs-awesome-nav>=3.1.2", 12 | "mkdocs-macros-plugin>=1.3.7", 13 | "mkdocs-material", 14 | "python-slugify>=8.0.4", 15 | "pyyaml>=6.0.2", 16 | "types-pyyaml>=6.0.12.20250516", 17 | "mkdocs-print-site-plugin" 18 | ] 19 | 20 | [dependency-groups] 21 | dev = ["ruff", "pytest", "doit", "pre-commit", "mypy"] 22 | 23 | [tool.ruff] 24 | line-length = 120 25 | 26 | [tool.ruff.lint] 27 | select = [ 28 | "E", # pycodestyle errors (see https://docs.astral.sh/ruff/rules/#pycodestyle-e-w) 29 | "F", # pyflakes (see https://docs.astral.sh/ruff/rules/#pyflakes-f) 30 | "PL", # Pylint (see https://docs.astral.sh/ruff/rules/#pylint-pl) 31 | "I001", # isort unsorted-imports (see https://docs.astral.sh/ruff/rules/#isort-i) 32 | ] 33 | ignore = [ 34 | "F405", # undefined-local-with-import-star-usage 35 | ] 36 | 37 | [tool.ruff.lint.pylint] 38 | max-args = 6 39 | 40 | [tool.mypy] 41 | disallow_incomplete_defs = true 42 | no_implicit_optional = true 43 | check_untyped_defs = true 44 | exclude = ["vendor/"] 45 | 46 | [[tool.mypy.overrides]] 47 | module = "cse.*" 48 | disable_error_code = ["annotation-unchecked", "import"] 49 | 50 | [build-system] 51 | requires = ["hatchling"] 52 | build-backend = "hatchling.build" 53 | 54 | [tool.hatch.build.targets.wheel] 55 | packages = ["cse"] 56 | 57 | [tool.uv] 58 | [tool.uv.sources] 59 | mkdocs-material = { git = "https://github.com/squidfunk/mkdocs-material.git", rev = "6af73667b36c2c1043252d3bc9f772a665295ae6" } 60 | -------------------------------------------------------------------------------- /doc/src/extra/inverse.md: -------------------------------------------------------------------------------- 1 | # Inverse 2 | 3 | Function inverter 4 | 5 | ### ivFREQ 6 | 7 | Type: Choice 8 | 9 | {{ 10 | member_table({ 11 | "units": "", 12 | "legal_range": "", 13 | "default": "**none**", 14 | "required": "No", 15 | "variability": "runly" 16 | }) 17 | }} 18 | 19 | ### ivX 20 | 21 | Type: float 22 | 23 | {{ 24 | member_table({ 25 | "units": "", 26 | "legal_range": "", 27 | "default": "**none**", 28 | "required": "No", 29 | "variability": "constant" 30 | }) 31 | }} 32 | 33 | ### ivX0 34 | 35 | Type: float 36 | 37 | {{ 38 | member_table({ 39 | "units": "", 40 | "legal_range": "", 41 | "default": "**none**", 42 | "required": "No", 43 | "variability": "runly" 44 | }) 45 | }} 46 | 47 | ### ivY 48 | 49 | Type: float 50 | 51 | {{ 52 | member_table({ 53 | "units": "", 54 | "legal_range": "", 55 | "default": "**none**", 56 | "required": "No", 57 | "variability": "constant" 58 | }) 59 | }} 60 | 61 | ### ivY0 62 | 63 | Type: float 64 | 65 | {{ 66 | member_table({ 67 | "units": "", 68 | "legal_range": "", 69 | "default": "**none**", 70 | "required": "No", 71 | "variability": "runly" 72 | }) 73 | }} 74 | 75 | ### ivYTarg 76 | 77 | Type: float 78 | 79 | {{ 80 | member_table({ 81 | "units": "", 82 | "legal_range": "", 83 | "default": "**none**", 84 | "required": "No", 85 | "variability": "runly" 86 | }) 87 | }} 88 | 89 | ### endInverse 90 | 91 | Optionally indicates the end of the inverse definition. 92 | 93 | {{ 94 | member_table({ 95 | "units": "", 96 | "legal_range": "", 97 | "default": "**none**", 98 | "required": "No", 99 | "variability": "" 100 | }) 101 | }} -------------------------------------------------------------------------------- /src/cse.rc: -------------------------------------------------------------------------------- 1 | //========================================================================== 2 | // cse.rc -- Hand editted resources for Windows build of CSE 3 | //========================================================================== 4 | 5 | #ifdef APSTUDIO_INVOKED // hand-maintained: APPSTUDIO can't do #defines 6 | #error This file is not editable by Visual C++ !! 7 | #endif 8 | 9 | #include "csevrsn.h" 10 | #include // for VERSIONINFO defns: VS_FF etc 11 | 12 | VS_VERSION_INFO VERSIONINFO 13 | 14 | FILEVERSION CSEVRSN_MAJOR, CSEVRSN_MINOR, CSEVRSN_PATCH, 0 15 | PRODUCTVERSION CSEVRSN_MAJOR, CSEVRSN_MINOR, CSEVRSN_PATCH, 0 16 | 17 | FILEFLAGSMASK VS_FFI_FILEFLAGSMASK 18 | 19 | FILEFLAGS 20 | #if defined( _DEBUG) 21 | VS_FF_DEBUG 22 | #else 23 | 0 24 | #endif 25 | 26 | FILEOS VOS_NT_WINDOWS32 // target OS: 32-bit windows 27 | 28 | FILETYPE 29 | #if defined( DLL) || defined( CSE_DLL) 30 | VFT_DLL // this is a DLL 31 | #else 32 | VFT_APP 33 | #endif 34 | FILESUBTYPE 0 // unused 35 | BEGIN 36 | BLOCK "VarFileInfo" 37 | BEGIN 38 | VALUE "Translation", 0x409, 1252 // identify StringFileInfo 39 | // lang/charset pairs 40 | // US English + Windows Multilingual 41 | END 42 | BLOCK "StringFileInfo" 43 | BEGIN 44 | BLOCK "040904E4" // Lang = US English 45 | // Charset = Windows Multilingual (1252) 46 | BEGIN 47 | VALUE "InternalName", "CSE" 48 | VALUE "OriginalFilename", 49 | #if defined( _DEBUG) 50 | "CSEd" 51 | #else 52 | "CSE" 53 | #endif 54 | #if defined( DLL) || defined( CSE_DLL) 55 | ".dll" 56 | #else 57 | ".exe" 58 | #endif 59 | 60 | VALUE "ProductName", "CSE" 61 | VALUE "ProductVersion", CSEVRSN_TEXT 62 | END 63 | END 64 | END 65 | 66 | // cse.rc end 67 | -------------------------------------------------------------------------------- /doc/src/parsers/cnfields.py: -------------------------------------------------------------------------------- 1 | import re 2 | from typing import List, TypedDict 3 | 4 | from .base import BaseParser 5 | 6 | 7 | class BaseField(TypedDict): 8 | typename: str 9 | datatype: str 10 | limits: str 11 | units: str 12 | 13 | 14 | class Field(BaseField, total=False): 15 | comments: List[str] 16 | 17 | 18 | type FieldsResult = List[Field] 19 | 20 | EXPECTED_COLUMN_COUNT = 4 21 | 22 | 23 | class FieldsParser(BaseParser[FieldsResult]): 24 | def _prepare_clean_text(self): 25 | # We want to keep inline comments, since those can be saved in field["comments"]. 26 | return self.strip_block_comments(self.raw_text) 27 | 28 | def _parse(self): 29 | result: FieldsResult = [] 30 | for line in self.clean_text.splitlines(): 31 | stripped = line.strip() 32 | if not stripped or stripped.startswith("//"): 33 | continue 34 | 35 | tokens: List[str] = re.split(r"\s+", stripped, maxsplit=4) 36 | # A line must have a value for each of the four named columns. 37 | if len(tokens) < EXPECTED_COLUMN_COUNT: 38 | continue 39 | 40 | typename, datatype, limits, units = tokens[:4] 41 | comment: str | None = None 42 | 43 | # TODO: Support for comments longer than one end-of-line? 44 | comment_match = re.search(r"//(.*)$", line) 45 | if comment_match: 46 | comment = comment_match.group(1).strip() 47 | 48 | field: Field = { 49 | "typename": typename.upper(), 50 | "datatype": datatype, 51 | "limits": limits, 52 | "units": units, 53 | } 54 | 55 | if comment: 56 | field["comments"] = [comment] 57 | 58 | result.append(field) 59 | 60 | return result 61 | -------------------------------------------------------------------------------- /src/cuparse.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) 1997-2019 The CSE Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style license 3 | // that can be found in the LICENSE file. 4 | 5 | // cuparse.h: decls for callers of cuparse.cpp and cuprobe.cpp 6 | 7 | 8 | /*-------------------------------- DEFINES --------------------------------*/ 9 | 10 | // see cuevf.h for EVFs & variabilities 11 | // see srd.h for expr() data types 12 | 13 | /*------------------------- FUNCTION DECLARATIONS -------------------------*/ 14 | 15 | // cuparse.cpp. Also see cuparsex.h -- fcn distribution is capricous, 10-8-90 16 | void FC cuParseClean(CLEANCASE cs); 17 | RC FC fov(); 18 | RC FC funcsVarsClear(); 19 | RC FC exOrk( SI toprec, USI wanTy, USI choiDt, USI evfOkPar, const char* ermTx, 20 | USI *pGotTy, USI *pEvf, SI *pisKon, NANDAT* pv, PSOP **pip ); 21 | RC FC itPile( PSOP *dest, USI sizeofDest); 22 | RC FC finPile( USI *pCodeSize); 23 | RC FC expTy( SI toprec, USI wanTy, const char* tx, SI aN); 24 | int toke(); 25 | void FC unToke(); 26 | 27 | RC FC cuAddItSyms( SI tokTyPar, SI casi, STBK *tbl, USI entLen, int op); 28 | 29 | const char * FC evfTx( USI evf, SI adverb); 30 | 31 | RC CDEC per( MSGORHANDLE msg, ...); 32 | RC CDEC perl( MSGORHANDLE msg, ...); 33 | RC CDEC perlc( MSGORHANDLE msg, ...); 34 | RC CDEC pWarn( MSGORHANDLE msg, ...); 35 | RC CDEC pWarnlc( MSGORHANDLE msg, ...); 36 | RC CDEC pInfo( MSGORHANDLE msg, ...); 37 | RC CDEC pInfol( MSGORHANDLE msg, ...); 38 | RC CDEC pInfolc( MSGORHANDLE msg, ...); 39 | RC CDEC perNx( MSGORHANDLE msg, ...); 40 | RC CDEC pWarnNx( MSGORHANDLE msg, ...); 41 | RC FC perNxV( int isWarn, MSGORHANDLE msg, va_list ap); 42 | 43 | void FC curLine( int retokPar, int* pFileIx, int* pline, int* pcol, char *s, size_t sSize); 44 | 45 | // cuprobe.cpp 46 | void FC showProbeNames(int showAll); 47 | RC SetupProbeModernizeTables(); 48 | 49 | // end of cuparse.h -------------------------------------------------------------------------------- /cmake/configure.cmake: -------------------------------------------------------------------------------- 1 | include(cmake/utility.cmake) 2 | set_build_configuration() 3 | if (NOT DEFINED BUILD_DIRECTORY) 4 | set(BUILDS_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/builds") 5 | set(BUILD_DIRECTORY "${BUILDS_DIRECTORY}/${BUILD_CONFIGURATION}") 6 | set(EXECUTABLE_DIRECTORY ${BUILDS_DIRECTORY}) 7 | endif () 8 | 9 | file(MAKE_DIRECTORY ${BUILD_DIRECTORY}) 10 | 11 | set(configure_command ${CMAKE_COMMAND} ${CMAKE_CURRENT_SOURCE_DIR} -DCSE_BUILD_ARCHITECTURE=${BUILD_ARCHITECTURE}) 12 | 13 | if (DEFINED EXECUTABLE_DIRECTORY) 14 | set(configure_command ${configure_command} -DCSE_EXECUTABLE_DIRECTORY=${EXECUTABLE_DIRECTORY}) 15 | endif () 16 | 17 | if (DEFINED BUILD_DOCS_WITH_ALL) 18 | set(configure_command ${configure_command} -DCSE_BUILD_DOCUMENTATION=BuildWithAll) 19 | endif () 20 | 21 | if ("${CMAKE_HOST_SYSTEM_NAME}" STREQUAL "Windows") 22 | if (${COMPILER_ID} STREQUAL "msvc") 23 | # Explicitly set versions to guarantee computational stability 24 | # toolset version (-T, version) 25 | # SDK version (CMAKE_SYSTEM_VERSION) 26 | # Supported list of SDK versions: https://developer.microsoft.com/en-us/windows/downloads/sdk-archive/ 27 | set(configure_command ${configure_command} -T v142,version=14.29.16.11 -A ${TARGET_VS_ARCHITECTURE} -DCMAKE_SYSTEM_VERSION=10.0.26100.0) 28 | elseif(${COMPILER_ID} STREQUAL "clang") 29 | set(configure_command ${configure_command} -T ClangCL -A ${TARGET_VS_ARCHITECTURE}) 30 | endif () 31 | else() 32 | set(configure_command ${configure_command} -DCMAKE_BUILD_TYPE=${CONFIGURATION}) 33 | endif() 34 | 35 | message("Generating project files...") 36 | execute_process(COMMAND ${configure_command} 37 | WORKING_DIRECTORY ${BUILD_DIRECTORY} 38 | RESULT_VARIABLE success 39 | ) 40 | 41 | if (NOT ${success} MATCHES "0") 42 | message(FATAL_ERROR "Generation step failed.") 43 | endif() -------------------------------------------------------------------------------- /doc/src/docs/input-data/construction.md: -------------------------------------------------------------------------------- 1 | # CONSTRUCTION 2 | 3 | CONSTRUCTION constructs an object of class CONSTRUCTION that represents a light weight or massive ceiling, wall, floor, or mass assembly (mass assemblies cannot, obviously, be lightweight). Once defined, CONSTRUCTIONs can be referenced from SURFACEs (below). A defined CONSTRUCTION need not be referenced. Each CONSTRUCTION is optionally followed by LAYERs, which define the constituent LAYERs of the construction. 4 | 5 | ### conName 6 | 7 | Name of construction. Required for reference from SURFACE and DOOR objects, below. 8 | 9 | {{ 10 | member_table({ 11 | "units": "", 12 | "legal_range": "*63 characters*", 13 | "default": "*none*", 14 | "required": "Yes", 15 | "variability": "constant" 16 | }) 17 | }} 18 | 19 | ### conU 20 | 21 | Type: float 22 | 23 | U-value for the construction (NOT including surface (air film) conductances; see SURFACE statements). If omitted, one or more LAYERs must immediately follow to specify the LAYERs that make up the construction. If specified, no LAYERs can follow. 24 | 25 | {{ 26 | member_table({ 27 | "units": "Btuh/ft^2^-°F", 28 | "legal_range": "x > 0", 29 | "default": "calculated from LAYERs", 30 | "required": "if omitted, LAYERs must follow", 31 | "variability": "constant" 32 | }) 33 | }} 34 | 35 | ### endConstruction 36 | 37 | Optional to indicates the end of the CONSTRUCTION. Alternatively, the end of the CONSTRUCTION definition can be indicated by "END" or by beginning another object If END or endConstruction is used, it should follow the construction's LAYER subobjects, if any. 38 | 39 | {{ 40 | member_table({ 41 | "units": "", 42 | "legal_range": "", 43 | "default": "*N/A*", 44 | "required": "No", 45 | "variability": "constant" 46 | }) 47 | }} 48 | 49 | **Related Probes:** 50 | 51 | - @[construction][p_construction] 52 | -------------------------------------------------------------------------------- /src/messages.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) 1997-2019 The CSE Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style license 3 | // that can be found in the LICENSE file. 4 | 5 | // messages.h -- definitions and declarations for messages.cpp (CSE message string retriever), 6 | // msgtab.cpp (CSE message text), and msgw.cpp (CSE message file creator). 7 | 8 | 9 | /*-------------------------------- DEFINES --------------------------------*/ 10 | 11 | const int MSG_MAXLEN = 2000; // PROBABLE safe dimension for msg buffers, for use as as dim in messages.cpp, rmkerr.cpp, etc. 12 | // CALLERS BEWARE: Formatted msg len is not known until vsprintf() is done so hard 13 | // enforcement not possible. 14 | // messages:msgCheck verifies that tabulated msgs are shorter than MSG_MAXLEN/2. 15 | 16 | /*--------------------------------- TYPES ---------------------------------*/ 17 | 18 | //---- message handle ---- 19 | //MH is typedef'd in cnglob.h. 20 | 21 | //---- entry in msgTbl[] ---- 22 | struct MSGTBL 23 | { MH msgHan; // message handle: int 0 - 16384 as defined in msghans.h 24 | const char* msg; // pointer to message text associated with msgHan 25 | }; 26 | 27 | /*--------------------------- PUBLIC VARIABLES ----------------------------*/ 28 | // msgtab.cpp public variables declared and refd ONLY in messages.cpp and msgw.cpp 29 | // MSGTBL msgTbl[] or MSGTBL msgTbl*; message table, or offset table for texts on disk 30 | // SI msgTblCount; number of entries in msgTbl 31 | 32 | 33 | /*------------------------- FUNCTION DECLARATIONS -------------------------*/ 34 | // messages.cpp 35 | void FC msgClean(); 36 | RC msgInit( int erOp); 37 | const char* msg( char *mBuf, MSGORHANDLE mOrH, ...); // ALSO DECL IN cnglob.h 38 | RC msgI( int erOp, char* mBuf, size_t mBufSz, int* pMLen, MSGORHANDLE mOrH, va_list ap=NULL); 39 | const char* msgSec( SEC sec); 40 | 41 | // messages.h end 42 | -------------------------------------------------------------------------------- /doc/src/docs/assets/javascript/extra_js.js: -------------------------------------------------------------------------------- 1 | document$.subscribe(function () { 2 | var tables = document.querySelectorAll("article table:not([class])"); 3 | tables.forEach(function (table) { 4 | // The only way to have only two rows is to have either: 5 | // - a header with one row (no need for sorting) 6 | // - no header with two rows (again, no need for soring, since header is hidden) 7 | if (table.querySelectorAll('tr').length === 2) return; 8 | 9 | new Tablesort(table); 10 | }); 11 | }); 12 | 13 | document$.subscribe(({ body }) => { 14 | renderMathInElement(body, { 15 | delimiters: [ 16 | { left: "$$", right: "$$", display: true }, 17 | { left: "$", right: "$", display: false }, 18 | { left: "\\(", right: "\\)", display: false }, 19 | { left: "\\[", right: "\\]", display: true }, 20 | ], 21 | }); 22 | }); 23 | 24 | // The script probably would not affect the multi-page site, since the paragraphs containing 25 | // @nested-dl should have already been removed by beautiful soup in the on_page_content 26 | // hook, but adding "section.print-page" to the selector just adds a layer of confidence 27 | // that the JS will only operate on elements that are part of the single-page site. 28 | document.querySelectorAll("section.print-page p:has(+ :is(h1, h2, h3, h4, h5, h6))").forEach(element => { 29 | if (element.innerHTML !== '@nested-dl') return 30 | 31 | let currentElement = element.nextElementSibling 32 | const heading_level = currentElement?.tagName.startsWith("H") ? currentElement.tagName : null 33 | 34 | if (!heading_level) return 35 | 36 | while (currentElement) { 37 | if (currentElement.tagName === 'DL') { 38 | currentElement.classList.add("nested-dl") 39 | } 40 | 41 | currentElement = currentElement.nextElementSibling 42 | if (currentElement?.tagName === heading_level) { 43 | break 44 | } 45 | } 46 | 47 | element.remove() 48 | }) 49 | 50 | 51 | -------------------------------------------------------------------------------- /src/dmpak.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) 1997-2019 The CSE Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style license 3 | // that can be found in the LICENSE file. 4 | 5 | // dmpak.h: declarations for heap (dynamic memory) functions for cse 6 | 7 | /* functions in dmpak.cpp; 8 | [also former near heap functions in nheap.cpp for compilers whose libraries don't have near heap (Borland)] */ 9 | 10 | #ifndef DMPAK_H // endif at end file 11 | #define DMPAK_H // (because included in ancrec.h, at least temporarily) 12 | 13 | /*-------------------------------- DEFINES --------------------------------*/ 14 | 15 | // in cnglob.h for use in other .h files and many .cpp files: 16 | // typedef void *DMP; * Dynamic memory block pointer: ptr to any type, record struct, etc, of caller's. 17 | 18 | // options/erOp bits for indicated dmpak.cpp functions. Note EROP1... defined in cnglob.h. 19 | const int DMZERO = EROP1; // zero allocated storage: dmalloc, dmvalloc, [dmpal], etc. 20 | const int DMFREEOLD = EROP2; // if pointer nonNULL, free it first. [dmpal], etc. 21 | #if defined( _DEBUG) 22 | #define DMHEAPCHK( s) dmCheckMemory( s); 23 | #else 24 | #define DMHEAPCHK( s) 25 | #endif 26 | 27 | 28 | /*--------------------------- PUBLIC VARIABLES ----------------------------*/ 29 | 30 | extern size_t Dmused; // Current number of dm bytes in use 31 | extern size_t DmMax; // max Dmused seen 32 | 33 | /*------------------------- FUNCTION DECLARATIONS -------------------------*/ 34 | // dmpak.cpp 35 | RC dmCheckMemory( const char* where=NULL); 36 | RC dmal( DMP *pp, size_t sz, int erOp); 37 | RC dmral( DMP *pp, size_t sz, int erOp); 38 | RC dmfree( DMP *pp); // checks stack, no FC 39 | RC dmIncRef( DMP *pp, int erOp=ABT); 40 | RC dmPrivateCopy( DMP *pp, int erOp=ABT); 41 | int dmIsGoodPtr( DMP p, const char* s, int erOp); 42 | void dmInitMemoryChecking(); 43 | 44 | #ifdef DEBUG2 45 | void FC dmeatmem( USI sz); 46 | #endif 47 | 48 | #endif // #ifndef DMPAK_H at start file 49 | 50 | // end of dmpak.h 51 | -------------------------------------------------------------------------------- /doc/src/docs/input-data/index.md: -------------------------------------------------------------------------------- 1 | # Input Data 2 | 3 | This section describes the input for each CSE class (object type). For each object you wish to define, the usual input consists of the class name, your name for the particular object (usually), and zero or more member value statements of the form *name=expression*. The name of each subsection of this section is a class name (HOLIDAY, MATERIAL, CONSTRUCTION, etc.). The object name, if given, follows the class name; it is the first thing in each description (hdName, matName, conName, etc.). Exception: no statement is used to create or begin the predefined top-level object "Top" (of class TOP); its members are given without introduction. 4 | 5 | After the object name, each member's description is introduced with a line of the form *name=type*. *Type* indicates the appropriate expression type for the value: 6 | 7 | - *float* 8 | 9 | - *int* 10 | 11 | - *string* 12 | 13 | - ____*name* (object name for specified type of object) 14 | 15 | - *choice* 16 | 17 | - *date* 18 | 19 | These types discussed in the section on [expression types][expression-types]. 20 | 21 | Each member's description continues with a table of the form: 22 | 23 | {{ 24 | member_table({ 25 | "units": "ft^2^", 26 | "legal_range": "x > 0", 27 | "default": "wnHeight \\_ wnWidth", 28 | "required": "No", 29 | "variability": "constant" 30 | }) 31 | }} 32 | 33 | where the column headers have the following meaning: 34 | 35 | {{ csv_table("**Units**,units of measure (lb., ft, Btu, etc.) where applicable 36 | **Legal Range**,limits of valid range for numeric inputs; valid choices for *choice* members, etc. 37 | **Default**,value assumed if member not given; applicable only if not required 38 | **Required**,YES if you must give this member 39 | **Variability**,how often the given expression can change: hourly, daily, etc. See sections on [expressions][expressions-overview], [statements][member-statements], and [variation frequencies][variation-frequencies-revisited]") 40 | }} 41 | 42 | -------------------------------------------------------------------------------- /src/lookup.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) 1997-2019 The CSE Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style license 3 | // that can be found in the LICENSE file. 4 | 5 | // lookup.h -- declarations associated with table lookup functions in lookup.c 6 | 7 | /* ---------------------------- FUNCTIONS -------------------------------- */ 8 | extern int lookw(int key, const int* table); // word table searcher 9 | extern int lookww(int key, const struct WWTABLE* table); // word-word table lookup 10 | extern const char* lookws(int key, const struct WSTABLE* table); // word-string table lookup 11 | extern int lookswl(int index, const struct SWLTAB* table); // subscript-word-limits table lookup 12 | extern int looksw(const char*, const struct SWTABLE* table, bool bCaseSensitive=false); // string-word table lookup 13 | 14 | /*-------------------------------- TYPES ----------------------------------*/ 15 | 16 | // word key, word value table struct for lookww 17 | struct WWTABLE // terminate w/ last array entry of 32767, default/not found indicator 18 | { 19 | int key, value; 20 | int lookup( int _key) const 21 | { 22 | return lookww(_key, this); 23 | } 24 | 25 | }; 26 | 27 | // word key, string ptr value table structure for lookws 28 | struct WSTABLE // terminate w/ last array entry of 32767, default/not found indicator 29 | { 30 | int key; 31 | const char *string; 32 | 33 | }; 34 | 35 | // subscripted table of words with limits. for lookswl(); for choice handle and scdefHan tables. 36 | struct SWLTAB 37 | { 38 | SI ixMin; // smallest subscript represented (at value[0]) 39 | SI ixMax; // largest+1 subscript represented 40 | SI val[1]; // actually allocated in dm with .ixMax - .ixMin elements 41 | 42 | }; 43 | #define SZSWLTAB(n) (sizeof(SWLTAB) + sizeof(SI)*(n-1)) 44 | 45 | // string key, word value table structure for looksw 46 | struct SWTABLE // terminate w/ last array entry of NULL, default/not found indicator 47 | { 48 | const char* key; 49 | int val; 50 | 51 | }; 52 | 53 | 54 | 55 | // end of lookup.h 56 | -------------------------------------------------------------------------------- /src/cpgprput.cpp: -------------------------------------------------------------------------------- 1 | // Copyright (c) 1997-2019 The CSE Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style license 3 | // that can be found in the LICENSE file. 4 | 5 | /* cpgprput.c: virtual report [printer]-only PAGE output fcn 6 | CSE variant derived from ..\lib\pgprput.c 8-28-91 7 | 8 | separated from pgpak.c for flexible linking. */ 9 | 10 | /*------------------------------- INCLUDES --------------------------------*/ 11 | #include "cnglob.h" 12 | 13 | #include "vrpak.h" // vrStr 14 | 15 | #include "pgpak.h" // public pgpak defs and decls; decl for this file; 16 | 17 | 18 | //========================================================================= 19 | RC FC pgVrPut( // Output contents of (partial) page to [printer]/virtual report 20 | 21 | SI vrh, // virtual report handle (see vrpak.c) to receive output 22 | SI isFmt, // non-0 if these are page formatting lines to omit in unformatted reports or files 23 | char *pp, // Pointer to page. If NULL, no action. 24 | USI flags, // Function flag bit(s): PGGPTRIM: delete white space at bottom and right of page (pgpak.h). 25 | SI row1, // Row of page at which to start 26 | SI nrows ) // Number of rows to print. Also stops after last row. 27 | { 28 | SI r; 29 | SI lastr, lastcSink; 30 | RC rc; 31 | 32 | if (pp != NULL) 33 | { 34 | pgputrc( pp, flags & PGGPTRIM, 1, PP->rows, &lastr, &lastcSink); 35 | lastr = min( SI(row1+nrows-1), lastr); 36 | for (r = row1; r <= lastr; r++) 37 | { 38 | char *p = (char *)PGBUF(r,1); // point to row in PAGE structure 39 | p[*LINELEN(r)] = '\0'; // stash a null in extra byte after last used column 40 | rc = vrStrF( vrh, isFmt, p); // virtual print string, vrpak.c 41 | if (rc != RCOK) 42 | return rc; 43 | rc = vrStrF( vrh, isFmt, "\r\n"); // output newline to virtual report, vrpak.c 44 | if (rc != RCOK) 45 | return rc; 46 | PP->flags |= PGCON; // say (some) printed, for cpnat.c 47 | } // for (row) 48 | } 49 | return RCOK; 50 | } // [pgprput]/pgVrPut 51 | 52 | // end of cpgprput.c 53 | -------------------------------------------------------------------------------- /src/foundation.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) 1997-2018 The CSE Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style license 3 | // that can be found in the LICENSE file. 4 | 5 | /////////////////////////////////////////////////////////////////////////////// 6 | // foundation.h -- interface to Kiva 7 | /////////////////////////////////////////////////////////////////////////////// 8 | 9 | #if !defined( _FOUNDATION_H) 10 | #define _FOUNDATION_H 11 | 12 | #include "Instance.hpp" 13 | #include "Aggregator.hpp" 14 | #ifdef GROUND_PLOT 15 | #include 16 | #include 17 | #endif 18 | 19 | 20 | class KIVA 21 | { public: 22 | KIVA(int32_t floor_index, float foundation_depth, int32_t wall_construction_index, float weight) : 23 | kv_walls({}), kv_floor(floor_index), kv_depth(foundation_depth), kv_wallCon(wall_construction_index), kv_perimWeight(weight) 24 | {} 25 | 26 | ZNR* kv_GetZone() const; 27 | RC kv_Create(); 28 | RC kv_RddInit(); 29 | RC kv_SetInitBCs(DOY jDay); 30 | RC kv_SetBCs(); 31 | RC kv_Step(float dur); 32 | Kiva::Instance kv_instance; 33 | std::vector kv_walls; // list of wall references 34 | // Kiva instances are unique to each combination of: 35 | // 1. Floor surface 36 | // 2. Foundation depth 37 | // 3. Wall construction (if foundation depth > 0) 38 | int32_t kv_floor; // floor SFI (not XSRAT!) reference 39 | float kv_depth; // foundation depth 40 | int32_t kv_wallCon; // wall construction reference (or -1 if depth == 0) 41 | float kv_perimWeight; 42 | #ifdef GROUND_PLOT 43 | Kiva::SnapshotSettings kv_plotSettings; 44 | Kiva::GroundPlot kv_groundPlot; 45 | #endif 46 | 47 | }; // KIVA 48 | 49 | extern std::vector kivas; 50 | 51 | inline Kiva::Material kivaMat(float k, float rho, float cp) { 52 | if (rho == 0.f || cp == 0.f) 53 | { 54 | err( ERR, "Materials used in Kiva must have specific heat and density greater than zero."); // TODO KIVA improve? 55 | } 56 | return Kiva::Material(KIPtoSI(k), DIPtoSI(rho), SHIPtoSI(cp)); 57 | } 58 | 59 | struct KivaWallGroup { 60 | KivaWallGroup() : perimeter(0.0) {}; 61 | KivaWallGroup(double perimeter, std::vector wallIDs) : perimeter(perimeter), wallIDs(wallIDs) {}; 62 | double perimeter; 63 | std::vector wallIDs; 64 | }; 65 | 66 | #endif // _FOUNDATION_H 67 | -------------------------------------------------------------------------------- /doc/src/parsers/base.py: -------------------------------------------------------------------------------- 1 | import json 2 | import re 3 | from abc import ABC, abstractmethod 4 | from pathlib import Path 5 | from typing import Generic, TypeVar 6 | 7 | import yaml 8 | 9 | T = TypeVar("T") 10 | 11 | 12 | class BaseParser(ABC, Generic[T]): 13 | def __init__(self, path: Path): 14 | if not path: 15 | raise Exception("Provide the path to the file to be parsed.") 16 | 17 | self.path = path 18 | self.raw_text = "" 19 | self.clean_text = "" 20 | self.result: T | None = None 21 | 22 | def read(self): 23 | with open(self.path, "r") as f: 24 | self.raw_text = f.read() 25 | 26 | def strip_falsy_blocks(self, text: str) -> str: 27 | return re.sub(r"^\s*#if\s+0\b.*?^\s*#endif\b.*?$", "", text, flags=re.MULTILINE) 28 | 29 | def strip_block_comments(self, text: str) -> str: 30 | return re.sub(r"/\*.*?\*/", "", text, flags=re.DOTALL | re.MULTILINE) 31 | 32 | def strip_inline_comments(self, text: str) -> str: 33 | return re.sub(r"//.*$", "", text) 34 | 35 | def prepare_clean_text(self): 36 | if not self.raw_text: 37 | self.read() 38 | self.clean_text = self._prepare_clean_text() 39 | return self.clean_text 40 | 41 | @abstractmethod 42 | def _prepare_clean_text(self) -> str: 43 | pass 44 | 45 | def parse(self): 46 | if not self.clean_text: 47 | self.prepare_clean_text() 48 | self.result = self._parse() 49 | return self.result 50 | 51 | @abstractmethod 52 | def _parse(self) -> T: 53 | pass 54 | 55 | def to_json(self, output_path=None): 56 | if not self.result: 57 | self.parse() 58 | 59 | if not output_path: 60 | raise Exception("Specify the output path for the to_json method.") 61 | 62 | with open(output_path, "w") as f: 63 | json.dump(self.result, f, indent=2) 64 | 65 | def to_yaml(self, output_path=None): 66 | if not self.result: 67 | self.parse() 68 | 69 | if not output_path: 70 | raise Exception("Specify the output path for the to_yaml method.") 71 | 72 | with open(output_path, "w") as f: 73 | yaml.dump(self.result, f, default_flow_style=False, sort_keys=False) 74 | -------------------------------------------------------------------------------- /doc/src/docs/input-data/dhwlooppump.md: -------------------------------------------------------------------------------- 1 | # DHWLOOPPUMP 2 | 3 | DHWLOOPPUMP constructs an object representing a pump serving part a DHWLOOP. The model is identical to DHWPUMP *except* that that the electricity use calculation reflects wlRunF of the parent DHWLOOP. 4 | 5 | ### wlpName 6 | 7 | Optional name of pump; give after the word “DHWLOOPPUMP” if desired. 8 | 9 | {{ 10 | member_table({ 11 | "units": "", 12 | "legal_range": "*63 characters*", 13 | "default": "*none*", 14 | "required": "No", 15 | "variability": "constant" 16 | }) 17 | }} 18 | 19 | ### wlpMult 20 | 21 | Type: integer 22 | 23 | Number of identical pumps of this type. Any value $>1$ is equivalent to repeated entry of the same DHWPUMP. 24 | 25 | {{ 26 | member_table({ 27 | "units": "", 28 | "legal_range": "x > 0 ", 29 | "default": "1", 30 | "required": "No", 31 | "variability": "constant" 32 | }) 33 | }} 34 | 35 | ### wlpPwr 36 | 37 | Type: float 38 | 39 | Pump power. 40 | 41 | {{ 42 | member_table({ 43 | "units": "W", 44 | "legal_range": "x > 0", 45 | "default": "0", 46 | "required": "No", 47 | "variability": "hourly" 48 | }) 49 | }} 50 | 51 | ### wlpLiqHeatF 52 | 53 | Type: float 54 | 55 | Fraction of pump power that heats circulating liquid. The remainder is discarded. 56 | 57 | {{ 58 | member_table({ 59 | "units": "", 60 | "legal_range": "0 ≤ x ≤ 1", 61 | "default": "1", 62 | "required": "No", 63 | "variability": "hourly" 64 | }) 65 | }} 66 | 67 | ### wlpElecMtr 68 | 69 | Type: mtrName 70 | 71 | Name of METER object, if any, to which DHWLOOPPUMP electrical energy use is recorded (under end use dhwMFL). 72 | 73 | {{ 74 | member_table({ 75 | "units": "", 76 | "legal_range": "*name of a METER*", 77 | "default": "*Parent DHWLOOP wlElecMtr*", 78 | "required": "No", 79 | "variability": "constant" 80 | }) 81 | }} 82 | 83 | ### endDHWLOOPPUMP 84 | 85 | Optionally indicates the end of the DHWPUMP definition. 86 | 87 | {{ 88 | member_table({ 89 | "units": "", 90 | "legal_range": "", 91 | "default": "*none*", 92 | "required": "No", 93 | "variability": "constant" 94 | }) 95 | }} 96 | 97 | **Related Probes:** 98 | 99 | - @[DHWLoopPump][p_dhwlooppump] 100 | -------------------------------------------------------------------------------- /src/libstubs.cpp: -------------------------------------------------------------------------------- 1 | // Copyright (c) 1997-2019 The CSE Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style license 3 | // that can be found in the LICENSE file. 4 | 5 | // Library stubs -- function definition stubs when not using CSE definitions 6 | // e.g., for RCDEF and unit tests 7 | 8 | // #include "cnglob.h" NO: the idea here is minimal dependencies 9 | // provide only bare-bones definitions 10 | 11 | //------------------------------------------------------------------------------------------ 12 | int getCpl( class TOPRAT** /*pTp=NULL*/) // get chars/line (stub fcn, allows linking w/o full CSE runtime) 13 | { 14 | return 78; 15 | } 16 | //--------------------------------------------------------------------------------------------------------------------------- 17 | const char* getErrTitleText() 18 | { 19 | return ""; 20 | } 21 | //--------------------------------------------------------------------------------------------------------------------------- 22 | const char* getLogTitleText() 23 | 24 | { 25 | return ""; 26 | } 27 | //--------------------------------------------------------------------------------------------------------------------------- 28 | int getBodyLpp() 29 | { 30 | return 66; 31 | } 32 | //--------------------------------------------------------------------------------------------------------------------------- 33 | const char* getFooterText([[maybe_unused]] int pageN) 34 | { 35 | return ""; 36 | } 37 | //--------------------------------------------------------------------------------------------------------------------------- 38 | const char* getHeaderText([[maybe_unused]] int pageN) 39 | { 40 | return ""; 41 | } 42 | //----------------------------------------------------------------------------- 43 | int CheckAbort() 44 | // in CSE, CheckAbort is used re caller interrupt of DLL simulation 45 | // here provide stub 46 | { return 0; 47 | } 48 | //----------------------------------------------------------------------------- 49 | bool vrIsEmpty(int) 50 | { 51 | return true; // return "not empty" 52 | } 53 | //----------------------------------------------------------------------------- 54 | short vrStr(int, const char*) 55 | { 56 | return 0; // return RCOK 57 | } 58 | //----------------------------------------------------------------------------- 59 | short vrOpen(int *, const char*, int) 60 | { 61 | return 0; // return RCOK 62 | } 63 | //----------------------------------------------------------------------------- 64 | 65 | // libstubs.cpp end 66 | -------------------------------------------------------------------------------- /.github/pull_request_template.md: -------------------------------------------------------------------------------- 1 | ## Description 2 | 3 | Replace the content in this section with: 4 | - The motivation and context for this change (if it is not immediately clear from the title) 5 | - If it fixes an open issue, specify the issue number (e.g., "fixes #XXXX") 6 | - A summary of the behavior expected from this change 7 | - A description of tests performed 8 | 9 | ## Author Progress Checklist: 10 | 11 | - [ ] Open draft pull request 12 | - [ ] Make title clearly understandable in a standalone change log context 13 | - [ ] Assign yourself the issue 14 | - [ ] Add at least one label (enhancement, bug, or maintenance) 15 | - [ ] Link the issue(s) addressed by this PR (under "Development" in the sidebar menu) 16 | - [ ] Make code changes (if you haven't already) 17 | - [ ] Self-review of code 18 | - [ ] My code follows the style guidelines of this project 19 | - [ ] I have added comments to my code, particularly in hard-to-understand areas 20 | - [ ] I have only committed the necessary changes for this fix or feature 21 | - [ ] I have made corresponding changes to the documentation 22 | - [ ] My changes generate no new warnings 23 | - [ ] I have ensured that my fix is effective or that my feature works as intended by: 24 | - [ ] exercising the code changes in the test framework, and/or 25 | - [ ] manually verifying the changes (as explained in the the pull request description above) 26 | - [ ] My changes pass all local tests 27 | - [ ] My changes successfully passes CI checks 28 | - [ ] Add any unit test for proof and documentation. 29 | - [ ] Merge in main branch and address resulting conflicts and/or test failures. 30 | - [ ] Move pull request out of draft mode and assign reviewers 31 | - [ ] Iterate with reviewers until all changes are approved 32 | - [ ] Make changes in response to reviewer comments 33 | - [ ] Merge in main branch and address resulting conflicts and/or test failures. 34 | - [ ] Re-request review in GitHub 35 | 36 | ## Reviewer Checklist: 37 | 38 | - [ ] Read the pull request description 39 | - [ ] Perform a code review on GitHub 40 | - [ ] Confirm all CI checks pass and there are no build warnings 41 | - [ ] Pull, build, and run automated tests locally 42 | - [ ] Perform manual tests of the fix or feature locally 43 | - [ ] Add any review comments, if applicable 44 | - [ ] Submit review in GitHub as either 45 | - [ ] Request changes, or 46 | - [ ] Approve 47 | - [ ] Iterate with author until all changes are approved -------------------------------------------------------------------------------- /doc/src/docs/input-data/exportfile.md: -------------------------------------------------------------------------------- 1 | # EXPORTFILE 2 | 3 | EXPORTFILE allows optional specification of different or additional files to receive CSE EXPORTs. 4 | 5 | EXPORTs contain the same information as reports, but formatted for reading by other programs rather than by people. By default, CSE generates no exports. Exports are specified via the EXPORT object, described in Section 5.28 (next). As for REPORTs, CSE automatically supplies a primary export file; it has the same name and path as the input file, and extension .csv. 6 | 7 | Input for EXPORTFILEs and EXPORTs is similar to that for REPORTFILEs and REPORTs, except that there is no page formatting. Refer to their preceding descriptions (Sections 5.24 and 5.25) for more additional discussion. 8 | 9 | ### xfName 10 | 11 | Name of EXPORTFILE object. 12 | 13 | {{ 14 | member_table({ 15 | "units": "", 16 | "legal_range": "*63 characters*", 17 | "default": "*none*", 18 | "required": "No", 19 | "variability": "constant" 20 | }) 21 | }} 22 | 23 | ### xfFileName 24 | 25 | Type: string 26 | 27 | path name of file to be written. If no path is specified, the file is written in the current directory. If no extension is specified, .csv is used. 28 | 29 | {{ 30 | member_table({ 31 | "units": "", 32 | "legal_range": "*file name, path and extension optional*", 33 | "default": "*none*", 34 | "required": "Yes", 35 | "variability": "constant" 36 | }) 37 | }} 38 | 39 | ### xfFileStat 40 | 41 | Type: choice 42 | 43 | What CSE should do if file *xfFileName* already exists: 44 | 45 | {{ 46 | csv_table("OVERWRITE, Overwrite pre-existing file. 47 | NEW, Issue error message if file exists. 48 | APPEND, Append new output to present contents of existing file.") 49 | }} 50 | 51 | If the specified file does not exist, it is created and *xfFileStat* has no effect. 52 | 53 | {{ 54 | member_table({ 55 | "units": "", 56 | "legal_range": "OVERWRITE, NEW, APPEND", 57 | "default": "OVERWRITE", 58 | "required": "No", 59 | "variability": "constant" 60 | }) 61 | }} 62 | 63 | ### endExportFile 64 | 65 | Optionally indicates the end of the export file definition. Alternatively, the end of the Export file definition can be indicated by END or by beginning another object. 66 | 67 | {{ 68 | member_table({ 69 | "units": "", 70 | "legal_range": "", 71 | "default": "*none*", 72 | "required": "No", 73 | "variability": "constant" 74 | }) 75 | }} 76 | 77 | **Related Probes:** 78 | 79 | - @[exportFile][p_exportfile] 80 | -------------------------------------------------------------------------------- /doc/src/docs/assets/stylesheets/extra_styles.css: -------------------------------------------------------------------------------- 1 | .md-typeset .admonition, .md-typeset details { 2 | font-size: 0.9em; 3 | } 4 | 5 | @media screen and (min-width: 76.25em) { 6 | .md-nav { 7 | transition: unset !important; 8 | } 9 | } 10 | 11 | .no-header-table + * table:not([class]) thead { 12 | display: none; 13 | } 14 | 15 | .no-header-table + * table:not([class]) tr:first-child td { 16 | border-top: none; 17 | } 18 | 19 | .member-table-sibling + * .md-typeset__table { 20 | width: 100%; 21 | } 22 | 23 | .member-table-sibling + * table:not([class]) { 24 | border-radius: 6px; 25 | display: table; 26 | table-layout: fixed; 27 | width: 100%; 28 | } 29 | 30 | /* General dl styling */ 31 | .md-typeset dl, dl code { 32 | font-size: 14.8px; 33 | } 34 | 35 | .md-typeset dl dt, 36 | .md-typeset dl dd, 37 | .md-typeset dl dd > p, 38 | .md-typeset dl dd > div { 39 | margin-block: 0; 40 | } 41 | 42 | .md-typeset dl * + dt { 43 | margin-top: 1em; 44 | } 45 | 46 | /* Nested dl styling customizations */ 47 | .nested-dl, .nested-dl + .admonition { 48 | margin-left: 1.875em; 49 | } 50 | 51 | .nested-dl { 52 | grid-template-columns: fit-content(25%) 1fr; 53 | display: grid; 54 | gap: 0.5em 55 | } 56 | 57 | .nested-dl > dt { 58 | grid-column: 1 / 2; 59 | margin: 0 !important; 60 | text-align: end; 61 | } 62 | 63 | .nested-dl > dd { 64 | grid-column: 2 / 3; 65 | margin: 0 !important 66 | } 67 | 68 | 69 | /* Fix code block alignment if a code block appears (first) as the description value for a description item. 70 | 71 | Supported term 72 | : Some text can come first 73 | 74 | ```Then a text block can appear. We don't want margin-top: 0 for this code block``` 75 | 76 | Unsupported term 77 | : ```code block can't be the first part/block of a description value``` 78 | 79 | Workaround term requiring margin-top fix 80 | : 81 | ```code block as description value starts on the next line``` */ 82 | .nested-dl dd > div:first-child > pre:has(code) { 83 | margin-top: 0; 84 | } 85 | 86 | .probe-table-sibling + * .md-typeset__table { 87 | width: 100%; 88 | } 89 | 90 | .probe-table-sibling + * table:not([class]) { 91 | border-radius: 6px; 92 | display: table; 93 | table-layout: fixed; 94 | width: 100%; 95 | } 96 | 97 | .probe-table-sibling + * table:not([class]) th:last-child { 98 | width: 40%; 99 | } 100 | 101 | .probe-table-sibling + * table:not([class]) th:first-child { 102 | width: 25%; 103 | } 104 | 105 | .md-typeset img { 106 | max-width: 50%; 107 | } -------------------------------------------------------------------------------- /test/bt_test.cse: -------------------------------------------------------------------------------- 1 | #define kw_to_btuh 3412.142 2 | #define max_bt_pwr 4.08 3 | 4 | wuDays = 30 5 | WfName="Bishop.epw" // reference city for CA Climate Zone 16 6 | nSubSteps=1 7 | 8 | // This battery should go through warm-up with a default assumption of 100% SOE 9 | // at beginning of warmup. This battery should be initialized to the initSOE 10 | // value at the beginning of the warmup (default of 100%). Since we don't 11 | // explicitly see the warmup in the output reports, we should see that battery 12 | // SOE is (10 kWh - (30 days x 24 hrs/day x 0.01 kWh/hr)) / 10 kWh = 0.28 at 13 | // the beginning of first timestep. However, since we only report SOE at the 14 | // END of each timestep, the first value should be 0.28 - 0.01/10.0 = 0.279 and 15 | // decrease 0.01 each hour after that. 16 | METER "ElecMtrInitNo" 17 | GAIN "BuildingLoadInitNo" 18 | gnEndUse= Lit 19 | gnMeter = ElecMtrInitNo 20 | gnPower = 0.01 * kw_to_btuh 21 | BATTERY "BatteryInitNo" 22 | btMeter = ElecMtrInitNo 23 | btMaxCap = 10.0 // kWh 24 | btMaxChgPwr = 5.0 // kW 25 | btMaxDschgPwr = 5.0 // kW 26 | btUseUsrChg = No 27 | btChgEff = 1.0 28 | btDschgEff = 1.0 29 | 30 | // This battery should be initialized to the initSOE value at the beginning of 31 | // the simulation. Since the spreadsheet shows the SOE values at the END of 32 | // each timestep, we should see the first SOE at 0.799 (0.8 - 0.01 kWh / 10kWh) = 33 | // 0.799), then dropping 0.01 each additional hour. 34 | METER "ElecMtrInitYes" 35 | GAIN "BuildingLoadInitYes" LIKE "BuildingLoadInitNo" 36 | gnMeter = ElecMtrInitYes 37 | BATTERY "BatteryInitYes" LIKE "BatteryInitNo" 38 | btMeter = ElecMtrInitYes 39 | btInitSOE = 0.8 // 80% state of energy 40 | 41 | REPORT rpType=MTR rpMeter = "ElecMtrInitNo" rpFreq=MONTH 42 | REPORT rpType=MTR rpMeter = "ElecMtrInitYes" rpFreq=MONTH 43 | 44 | REPORT 45 | rpType = UDT 46 | rpFreq = HOUR 47 | rpTitle = "Battery and warmup with (Yes) & without (No) btInitSOE" 48 | rpDayBeg = jan 1 49 | rpDayEnd = jan 1 50 | rpHeader = "Yes" 51 | rpFooter = "No" 52 | ReportCol colhead="Day" colVal=@Top.dateStr 53 | ReportCol colhead="Hour" colVal=@Top.iHr 54 | ReportCol colhead="NoSOE" colWid=6 colVal=@BATTERY["BatteryInitNo"].soe 55 | ReportCol colhead="NoEgy[kWh]" colWid=10 colVal=@BATTERY["BatteryInitNo"].energy 56 | ReportCol colhead="NoBT[kW]" colWid=8 colVal=@METER["ElecMtrInitNo"].H.BT / kw_to_btuh 57 | ReportCol colhead="YesSOE" colWid=6 colVal=@BATTERY["BatteryInitYes"].soe 58 | ReportCol colhead="YesEgy[kWh]" colWid=11 colVal=@BATTERY["BatteryInitYes"].energy 59 | ReportCol colhead="YesBT[kW]" colWid=9 colVal=@METER["ElecMtrInitYes"].H.BT / kw_to_btuh 60 | 61 | DELETE REPORT "EB" 62 | 63 | RUN 64 | -------------------------------------------------------------------------------- /doc/src/main.py: -------------------------------------------------------------------------------- 1 | import csv 2 | from io import StringIO 3 | from pathlib import Path 4 | 5 | 6 | def define_env(env): 7 | """ 8 | This is the hook for the variables, macros and filters. 9 | """ 10 | 11 | @env.macro 12 | def csv_table(csv_string, header=False): 13 | rows = list(csv.reader(StringIO(csv_string))) 14 | 15 | max_length = max(len(row) for row in rows) 16 | padded_rows = [row + [""] * (max_length - len(row)) for row in rows] 17 | 18 | header_row = padded_rows[0] if header else ([""] * max_length) 19 | body_rows = padded_rows[1:] if header else padded_rows 20 | 21 | table = ( 22 | ('
\n' if not header else "") 23 | + "| " 24 | + " | ".join(header_row) 25 | + " |\n" 26 | + "| " 27 | + " | ".join("------" for _ in header_row) 28 | + " |\n" 29 | + ( 30 | "\n".join(("| " + " | ".join(f"{c}" for c in row) + " |") for row in body_rows) 31 | if len(body_rows) > 0 32 | else "" 33 | ) 34 | ) 35 | 36 | return table 37 | 38 | @env.macro 39 | def csv_table_from_file(file_path, header=False): 40 | full_path = Path(__file__).parent.resolve().joinpath(file_path) 41 | csv_content = "" 42 | 43 | try: 44 | with open(full_path, "r") as file: 45 | csv_content = file.read() 46 | except FileNotFoundError: 47 | print(f"Error: File not found at path: {file_path}") 48 | except Exception as e: 49 | print(f"An error occurred: {e}") 50 | 51 | return csv_table(csv_content, header) 52 | 53 | @env.macro 54 | def member_table(args): 55 | fallback = "—" 56 | units = args.get("units", fallback) 57 | legal_range = args.get("legal_range", fallback) 58 | default = args.get("default", fallback) 59 | required = args.get("required", "No") 60 | variability = args.get("variability", "constant") 61 | 62 | table = ( 63 | '
\n' 64 | + "| " 65 | + " | ".join(f"{c}" for c in ["Units", "Legal Range", "Default", "Required", "Variability"]) 66 | + " |\n" 67 | + "| " 68 | + " | ".join("------" for _ in 5 * [""]) 69 | + " |\n" 70 | + "| " 71 | + " | ".join( 72 | f"{c if c is not None else fallback}" for c in [units, legal_range, default, required, variability] 73 | ) 74 | + " |\n" 75 | ) 76 | 77 | return table 78 | -------------------------------------------------------------------------------- /doc/src/mkdocs.yml: -------------------------------------------------------------------------------- 1 | site_author: CSE Authors 2 | site_description: Documentation Website for CSE 3 | site_dir: ../build 4 | site_name: CSE Documentation 5 | site_url: "https://cse-sim.github.io/cse/" 6 | copyright: "© 2025 The CSE Authors. All rights reserved." 7 | watch: 8 | - main.py 9 | theme: 10 | name: material 11 | features: 12 | - content.code.copy 13 | - toc.follow 14 | - navigation.instant 15 | - navigation.indexes 16 | - navigation.footer 17 | # favicon: assets/favicon.ico 18 | # logo: assets/logo.svg 19 | palette: 20 | - media: "(prefers-color-scheme)" 21 | toggle: 22 | icon: material/brightness-auto 23 | name: Switch to light mode 24 | - media: "(prefers-color-scheme: light)" 25 | scheme: default 26 | toggle: 27 | icon: material/weather-sunny 28 | name: Switch to dark mode 29 | - media: "(prefers-color-scheme: dark)" 30 | scheme: slate 31 | toggle: 32 | icon: material/weather-night 33 | name: Switch to system preference 34 | repo_name: cse 35 | repo_url: https://github.com/cse-sim/cse 36 | plugins: 37 | - autorefs: 38 | resolve_closest: true 39 | - macros 40 | - search 41 | - awesome-nav 42 | - print-site: 43 | add_to_navigation: false 44 | print_page_title: 'CSE Documentation (Single Page)' 45 | print_page_basename: 'single_page' 46 | add_print_site_banner: false 47 | # Table of contents 48 | add_table_of_contents: true 49 | toc_title: 'Table of Contents' 50 | toc_depth: 6 51 | # Content-related 52 | add_full_urls: false 53 | enumerate_headings: true 54 | enumerate_figures: false 55 | add_cover_page: false 56 | include_css: true 57 | enabled: true 58 | hooks: 59 | - hooks.py 60 | markdown_extensions: 61 | - admonition 62 | - attr_list 63 | - def_list 64 | - toc: 65 | permalink: true 66 | - pymdownx.arithmatex: 67 | generic: true 68 | - pymdownx.blocks.caption 69 | - pymdownx.caret 70 | - pymdownx.critic 71 | - pymdownx.details 72 | - pymdownx.highlight: 73 | anchor_linenums: true 74 | line_spans: __span 75 | pygments_lang_class: true 76 | - pymdownx.inlinehilite 77 | - pymdownx.keys 78 | - pymdownx.mark 79 | - pymdownx.smartsymbols 80 | - pymdownx.snippets 81 | - pymdownx.superfences 82 | - pymdownx.tilde 83 | extra_css: 84 | - https://unpkg.com/katex@0/dist/katex.min.css 85 | - assets/stylesheets/extra_styles.css 86 | extra_javascript: 87 | - https://unpkg.com/katex@0/dist/katex.min.js 88 | - https://unpkg.com/katex@0/dist/contrib/auto-render.min.js 89 | - https://unpkg.com/tablesort@5.3.0/dist/tablesort.min.js 90 | - assets/javascript/extra_js.js 91 | -------------------------------------------------------------------------------- /doc/src/parsers/cndefns.py: -------------------------------------------------------------------------------- 1 | import re 2 | from typing import Dict, List, Literal, Tuple, TypedDict, cast 3 | 4 | from .base import BaseParser 5 | 6 | type BlockKey = Literal["OPTIONS"] | Literal["DEFINES"] 7 | 8 | type ParsedDefineLine = Tuple[str, int | str] 9 | 10 | 11 | class DefinitionsResult(TypedDict): 12 | bool: List[str] 13 | kvp: Dict[str, int | str] 14 | 15 | 16 | class DefinitionsParser(BaseParser[DefinitionsResult]): 17 | def get_block_by_key(self, key: BlockKey, text: str) -> str: 18 | pattern = re.compile( 19 | rf"^//-{{10,}}\s*{re.escape(key)}\s*-{{10,}}.*?\n" 20 | r"(.*?)" 21 | r"(?=^//-{{10,}}|\Z)", 22 | flags=re.MULTILINE | re.DOTALL, 23 | ) 24 | match = pattern.search(text) 25 | 26 | if not match: 27 | raise Exception(f"Could not find the {key} block.") 28 | 29 | return match.group(1).strip() 30 | 31 | def parse_define_line(self, line: str) -> Tuple[str, int | str | bool] | Tuple[None, None]: 32 | line = self.strip_inline_comments(line).strip() 33 | 34 | match = re.match(r"^#define\s+(\w+)(?:\s+(.*))?$", line) 35 | 36 | if not match: 37 | return None, None 38 | 39 | raw_key, raw_value = match.groups() 40 | key = cast(str, raw_key) 41 | raw_value = cast(str | None, raw_value) 42 | 43 | if raw_value is None: 44 | return key, True 45 | 46 | value: str | int | None = None 47 | try: 48 | value = int(raw_value) 49 | except ValueError: 50 | value = raw_value.strip('"').strip("'") 51 | 52 | return key, value 53 | 54 | def _prepare_clean_text(self): 55 | return self.raw_text 56 | 57 | def _parse(self): 58 | result: DefinitionsResult = {"bool": [], "kvp": {}} 59 | 60 | keys: List[BlockKey] = ["OPTIONS", "DEFINES"] 61 | 62 | for key in keys: 63 | block = self.get_block_by_key(key, self.clean_text) 64 | for line in block.splitlines(): 65 | parsed_key, parsed_value = self.parse_define_line(line) 66 | 67 | if not parsed_key: 68 | continue 69 | 70 | if type(parsed_value) is bool: 71 | result["bool"].append(parsed_key) 72 | else: 73 | # parsed_value can't be None, but Python type system doesn't realize that 74 | # It is only None when parsed_key is also None, but then "if not parsed_key: continue" 75 | # would prevent us from getting here. 76 | cast_value = cast(int | str, parsed_value) 77 | result["kvp"][parsed_key] = cast_value 78 | 79 | return result 80 | -------------------------------------------------------------------------------- /src/sytb.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) 1997-2019 The CSE Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style license 3 | // that can be found in the LICENSE file. 4 | 5 | // sytb.h: defines and decls for symbol table functions in sytb.cpp 6 | 7 | #if !defined( _SYTB_H) 8 | #define _SYTB_H 9 | 10 | /*------------------------ SYMBOL TABLE STRUCTURES ------------------------*/ 11 | struct STBK // symbol table block base class 12 | // (actual *stbk structs are up to appl but always have id 1st) 13 | { const char* id; 14 | STBK() : id( NULL) {} 15 | STBK( char* _id) : id( _id) {} 16 | STBK( const char* _id) : id( const_cast(_id)) {} 17 | const char* ID() const { return id; } 18 | }; 19 | struct STAE // sym table array struct: SYTBH.p points to array of these 20 | { 21 | // name of symbol (lookup key) is not in STAE itself, but is STAE.stbk.id. 22 | STBK* stbk; // appl's pointer to info dependent on type: block of whatever size and type appl needs. 23 | // FIRST member of stbk is always "char *id;" */ 24 | USI iTokTy; // SYTBCASI bit: on if case-insensitive symbol. 25 | // lo bits (TOKTYMASK): appl's token type etc for symbol 26 | // CUTxxx define) */ 27 | const char* ID() const { return stbk->ID(); } 28 | }; // struct STAE 29 | const USI SYTBCASI = 0x8000; // bit in iTokTy indicating case-insensitive entry 30 | const USI SYTBRES = 0x4000; // bit reserved for next feature to be added 31 | const USI TOKTYMASK = USI(~(SYTBCASI | SYTBRES)); 32 | 33 | struct SYTBH // symbol table header (base) structure 34 | { STAE *p; // pointer to array of STAE entries 35 | USI n; // # entries in use 36 | USI nAl; // # entries allocated, if in dm 37 | SI isSorted; // nz if is in ascii order: can binary search 38 | SI spare; 39 | }; 40 | 41 | /* initialization of SYTBH's: 42 | 1. an all-0 SYTBH will work; call sySort for it to make it a sorted table. 43 | 2. can data-initialize desired initial table contents; syAdd will 44 | duplicate in dm to permit modification. */ 45 | 46 | /*-------------------------------- DEFINES --------------------------------*/ 47 | // syAdd call "op" bits 48 | const int DUPOK=EROP2; // no error (and no add) if same id, tokTy, casi. stbk match NOT checked! (size not known) 49 | 50 | /*------------------------- FUNCTION DECLARATIONS -------------------------*/ 51 | RC FC syLu( SYTBH *sytbh, char *id, BOO casi, int* pTokty=NULL, void **pStb=NULL); 52 | RC FC syAdd( SYTBH *sytbh, SI tokTy, BOO casi, STBK* stbk, int op); 53 | RC FC syDel( SYTBH *sytbh, SI tokTy, BOO casi, BOO nearId, char *id, BOO uBad=FALSE, void **pStb=NULL); 54 | RC FC sySort( SYTBH *sytbh); 55 | RC FC syClear( SYTBH *st, SI tokTy=-1, BOO (*callBack)(SI tokTy, STBK *&pStbk) =NULL); 56 | 57 | #endif // _SYTB_H 58 | 59 | // end of sytb.h 60 | -------------------------------------------------------------------------------- /src/cse.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) 1997-2019 The CSE Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style license 3 | // that can be found in the LICENSE file. 4 | 5 | // cse.h: declarations for cse.cpp (CSE subroutine main function) 6 | // for use within CSE subroutine. 7 | 8 | 9 | /*--------------------------- PUBLIC VARIABLES ----------------------------*/ 10 | extern const char ProgName[]; // program name text, eg "CSE" 11 | extern const char ProgVersion[]; // static version number text for CSE program, e.g. "0.15", 12 | extern const char ProgVariant[]; // static variant text 13 | extern int TestOptions; // test option bits, set via -t command line argument 14 | #ifdef WINorDLL 15 | //extern const char ConsoleTitle[]; make public when need found: caption for "console" window displayed during run. 16 | extern const char MBoxTitle[]; // error and other message box caption text, cse.cpp, used in rmkerr.cpp. 17 | 18 | #ifdef __WINDOWS_H // defined in windows.h (Borland 3.1, 4) 19 | extern HINSTANCE cneHInstApp; // appl instance handle: needed eg for registering window classes in rmkerr.cpp 20 | extern HWND cneHPar; // appl window handle to use as parent for (error msg) windows opened eg in rmkerr.cpp 21 | #else /* windows.h not included. Declare as types would be declared in Windows 3.1 windows.h with "STRICT".. 22 | so can compile without windows.h. Undefined structs after the word "struct" are ok in unused declarations. */ 23 | //32: #define DECLARE_HANDLE(name) struct name##__ { int unused; }; typedef struct name##__ *name 24 | //16: #define DECLARE_HANDLE(name) struct name##__ { int unused; }; typedef const struct name##__ NEAR* name 25 | extern struct HINSTANCE__ * cneHInstApp; // appl instance handle: needed to register window classes 26 | extern struct HWND__ * cneHPar; // appl window handle for parent for windows eg errMsgBoxes 27 | #endif 28 | #if defined( _DLL) 29 | extern HINSTANCE hInstLib; // library's module instance handle 30 | #endif 31 | #endif 32 | #ifdef BINRES // CMake option 33 | extern struct BrHans* hans; // pointer to struct (cnewin.h) for returning memory handles of binary results data. 34 | // NULL if not returning memory handles. 35 | #endif 36 | 37 | /*--------------------------- PUBLIC FUNCTIONS ----------------------------*/ 38 | // public for use within CSE subroutine. 39 | #ifdef OUTPNAMS //cnglob.h 40 | #ifndef GLOB //decl in cnglob.h so don't need cse.h where this is called. 10-93. 41 | void FC saveAnOutPNam( const char * pNam); 42 | #endif 43 | #endif 44 | 45 | 46 | 47 | // re sending DLL screen msgs to calling EXE 48 | // defined but not used per LOGCALLBACK 49 | void LogMsgViaCallBack( const char* msg, int level=0); 50 | // int CheckAbort() -- see cnglob.h 51 | 52 | // end of cse.h 53 | -------------------------------------------------------------------------------- /test/ref-win32-msvc/MINIMUM_RUNNING_FILE.REP: -------------------------------------------------------------------------------- 1 | 2 | 3 | Monthly Energy Balance, Sum of Zones 4 | 5 | Mon Tair WBair Cond InfS Slr IgnS Mass Izone MechS BalS InfL IgnL IzoneL AirL MechL BalL 6 | ---- ----- ----- ------ ------ ----- ----- ------ ------ ------ ---- ------ ----- ------ ------ ------ ---- 7 | Jan 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 8 | Feb 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 9 | Mar 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 10 | Apr 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 11 | May 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 12 | Jun 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 13 | Jul 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 14 | Aug 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 15 | Sep 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 16 | Oct 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 17 | Nov 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 18 | Dec 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 19 | 20 | Yr 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 21 | 22 | 23 | 24 | ! Log for Run 001: 25 | 26 | ! CSE 0.909.0+error-handling-test-suite.7187f59d.20.dirty for Win32 console 27 | 28 | 29 | 30 | Input for Run 001: 31 | 32 | WfName="CTZ12S13B.CSW" 33 | 34 | RUN 35 | 36 | 37 | 38 | 39 | ! CSE 0.909.0+error-handling-test-suite.7187f59d.20.dirty for Win32 console run(s) done: Fri 07-Oct-22 12:06:04 pm 40 | 41 | ! Executable: d:\code\cse\msvc\cse.exe 42 | ! 07-Oct-22 12:05 pm (VS 14.29 3011584 bytes) (HPWH 1.18.1) 43 | ! Command line: -x! -b -t1 minimum_running_file 44 | ! Input file: D:\code\cse\test\minimum_running_file.cse 45 | ! Report file: D:\code\cse\test\minimum_running_file.rep 46 | 47 | ! Timing info -- 48 | 49 | ! Input: Time = 0.05 Calls = 1 T/C = 0.0480 50 | ! AutoSizing: Time = 0.00 Calls = 0 T/C = 0.0000 51 | ! Simulation: Time = 0.05 Calls = 1 T/C = 0.0520 52 | ! Reports: Time = 0.00 Calls = 1 T/C = 0.0000 53 | ! Total: Time = 0.10 Calls = 1 T/C = 0.1010 54 | -------------------------------------------------------------------------------- /src/exman.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) 1997-2019 The CSE Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style license 3 | // that can be found in the LICENSE file. 4 | 5 | /* exman.h: decls for expression manager (exman.cpp) */ 6 | 7 | /*---------- NANDLEs and NANDAT ----------*/ 8 | 9 | /* a NANDLE is a 32-bit quantity that is not a valid floating point 10 | number or string pointer, used to specify the "expression number" 11 | for data whose value is not known at input time, and also to specify 12 | UNSET (no value assigned yet). 13 | 14 | During input, NANDLEs are stored in place of string and float 15 | values and moved and copied freely; after input is set up, the data 16 | is searched for NANDLEs to build the expression table that drives 17 | evaluating and storing expressions during the run. (SI data is 18 | extended to 32 bits (TYLLI) where necessary to allow for NANDLEs.) 19 | 20 | The bit format of a NANDLE is: 0xFF800000 + n: 21 | n = 0 to indicate unset; 22 | n = expression number 1-16383 to indicate place to store expression. 23 | 24 | CAUTION: NANDLE format is system and software dependent: 25 | depends on IEEE floating point format (hi word FF80 is Not-A-Number); 26 | depends on IBM memory allocation (segment FF80 should not occur in 27 | data pointers as ROM is there); 28 | depends on user caution to limit SI data stored in 32-bit int to 16 bits 29 | to insure data not looking like a NANDLE. 30 | must be kept distinct from NCHOICEs (cnglob.h): 7F8x hi word. */ 31 | 32 | 33 | /*------------------------- FUNCTION DECLARATIONS -------------------------*/ 34 | void FC exClean(CLEANCASE cs); 35 | RC FC exPile( SI toprec, USI wanTy, USI choiDt, USI fdTy, USI _evfOk, USI useCl, 36 | const char* ermTx, SI isType, BP b, TI i, SI fn, 37 | NANDAT *pDest, USI *pGotTy, USI *pGotEvf ); 38 | RC FC uniLimCt( USI fdTy, SI ty, const char* ermTx, void *p ); 39 | void FC extAdj( BP b, TI minI, TI delta); 40 | void FC extMove( record *nuE, record *e); 41 | void FC extDup( record *nuE, record *e); 42 | void FC extDel( record *e); 43 | void FC extDelFn( BP b, TI i, SI fn); 44 | void FC extClr( void); 45 | RC FC exClrExUses( BOO jfc); // arg added 10-95 46 | RC FC exWalkRecs( void); 47 | // RC FC exReg( USI ancN, TI i, USI o); if wanted: restore when needed 48 | RC addChafIf ( NANDAT *pv, USI ancN, TI i, USI o); 49 | RC FC exEvEvf( USI evf, USI useCl); 50 | RC FC exInfo( USI h, USI *pEvf, USI *pTy, NANDAT *pv ); 51 | const char* FC whatEx( USI h); 52 | const char* FC whatNio( USI ratN, TI i, USI off); 53 | RC CDEC rer( MSGORHANDLE msg, ...); 54 | RC CDEC rerErOp( int erOp, MSGORHANDLE msg, ...); 55 | RC CDEC rWarn( MSGORHANDLE msg, ...); 56 | RC CDEC rWarnErOp( int erOp, MSGORHANDLE msg, ...); 57 | RC CDEC rInfo( MSGORHANDLE msg, ...); 58 | RC rerIV( int erOp, int isWarn, MSGORHANDLE fmt, va_list ap=NULL); 59 | 60 | 61 | // end of exman.h 62 | -------------------------------------------------------------------------------- /src/cncult.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) 1997-2019 The CSE Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style license 3 | // that can be found in the LICENSE file. 4 | 5 | // cncult.h: public declarations for cncult.cpp, cncult2,3,4,5,6.cpp. 6 | 7 | // see also: irats.h: declarations of input record arrays (rats) 8 | // cnculti.h: cncult internal functions shared only amoung cncult,2,3,4,5,6.cpp 9 | 10 | 11 | /*-------------------------------- DEFINES --------------------------------*/ 12 | 13 | /*--- "Use Class" bits for object member expressions --- 14 | 15 | Mechanism intended (1991) for use eg to not evaluate hourly-variable exprs for solar inputs 16 | on on-solar-calc days... But never (1995) used thus; now hold interval stage info (EVENDIVL, EVPSTIVL,) 17 | 18 | For CULT.uc and thence useCl args to exPile, exEvf. Data type: USI; unsigned:4 in CULT.uc. */ 19 | 20 | #if 0 21 | x //former use class values for CULT.uc, which is now (1995) always 0 (changed to 1 at access in cul.cpp) and could be deleted: 22 | x // #define UGEN 1 general: none of the below (may match a cul.cpp dfl) 23 | x // #define USOL 2 used in solar calcs only. no uses found (except in exEvfUp calls 12-91, deleted 9-95). 24 | 25 | x // end-interval-evaluation bit in use class: only bit now explicitly used, 9-95:x 26 | x #define UENDIVL 4 /* expression is to be evaluated at end of interval, not start (eg contains results probes). 27 | x supplied by exman:exPile upon seeing EVENDIVL bit in the 'evf' word, 12-9-91. 28 | x Should be only bit on. Make an independent characteristic of expr if found necessary. */ 29 | #endif 30 | 31 | 32 | /*------------------------- FUNCTION DECLARATIONS -------------------------*/ 33 | 34 | // cncult.cpp (many functions in cncult.cpp are called only via ptrs in CULT tables pointed to by cnTopCult) 35 | extern CULT cnTopCult[]; // top level CULT for CSE (CULT = Cse User Language Table, cul.c) 36 | void cnPreInit(); 37 | int culShowDoc(int (*print1)(const char* s, ...), int options=0); 38 | 39 | // cncult2.cpp 40 | void cncultClean(CLEANCASE cs); // cncultn.cpp cleanup fcn 12-3-93 41 | //topCkf: see cnculti.h. 42 | RC topReCkf(); // re-check/setup for main run after autosize 43 | 44 | // cncult4.cpp -- externally called fcns re report/export formatting 45 | const char* getErrTitleText(); // access ERR report title text 46 | const char* getLogTitleText(); // access LOG report title text 47 | const char* getInpTitleText(); // access INP report title text 48 | const char* getHeaderText( int pageN); // access header text 49 | const char* getFooterText( int pageN); // .. footer .. inserts given page number 50 | int getBodyLpp(); // get lines of report body per page, similarly 51 | void freeHdrFtr(); // free header, footer, report title texts 52 | RC FC freeRepTexts(); 53 | // impFcn(): import files: see impf.h 2-94. 54 | 55 | // end of cncult.h 56 | -------------------------------------------------------------------------------- /doc/src/docs/introduction.md: -------------------------------------------------------------------------------- 1 | # Introduction 2 | 3 | ## Greetings 4 | 5 | The purpose of this manual is to document the California Simulation Engine computer program, CSE. CSE is an hourly building and HVAC simulation program which calculates annual energy requirements for building space conditioning and lighting. CSE is specifically tailored for use as internal calculation machinery for compliance with the California building standards. 6 | 7 | CSE is a batch driven program which reads its input from a text file. It is not intended for direct use by people seeking to demonstrate compliance. Instead, it will be used within a shell program or by technically oriented users. As a result, this manual is aimed at several audiences: 8 | 9 | 1. People testing CSE during its development. 10 | 11 | 2. Developers of the CSE shell program. 12 | 13 | 3. Researchers and standards developers who will use the program to explore possible conservation opportunities. 14 | 15 | Each of these groups is highly sophisticated. Therefore this manual generally uses an exhaustive, one-pass approach: while a given topic is being treated, *everything* about that topic is presented with the emphasis on completeness and accuracy over ease of learning. 16 | 17 | Please note that CSE is under development and will be for many more months. Things will change and from time to time this manual may be inconsistent with the program. 18 | 19 | ## Manual Organization 20 | 21 | This Introduction covers general matters, including program installation. 22 | 23 | 28 | 29 | [Operation][operation] documents the operational aspects of CSE, such as command line switches, file naming conventions, and how CSE finds files it needs. 30 | 31 | [Input Structure][input-structure] documents the CSE input language in general. 32 | 33 | [Input Data][input-data] describes all of the specific input language statements. 34 | 35 | [Output Reports][output-reports] will describe the output reports. 36 | 37 | Lastly, [Probe Definitions][probe-definitions] lists all available probes. 38 | 39 | 40 | ## Installation 41 | 42 | ### Hardware and Software Requirements 43 | 44 | CSE is a command line application. That is, it runs in a terminal. Memory and disk space requirements depend on the size of projects being modeled, but are generally modest. 45 | 46 | To prepare input files, a text editor is required. Notepad will suffice, although a text editor intended for programming is generally more capable. Alternatively, some word processors can be used in "ASCII" or "text" or "non-document" mode. 47 | 48 | ### Installation Procedure 49 | 50 | Create a directory on your hard disk with the name \\CSE or some other name of your choice. Copy the files into that directory. Add the name of the directory to the PATH environment setting unless you intend to use CSE only from the CSE directory. 51 | -------------------------------------------------------------------------------- /doc/src/docs/input-data/shadex.md: -------------------------------------------------------------------------------- 1 | # SHADEX 2 | 3 | SHADEX describes an object that shades other building surfaces using an advanced shading model. Advanced shading calculations are provided only for [PVARRAYs][pvarray]. Advanced shading must be enabled via [Top exShadeModel][top-model-control-items]. 4 | 5 | ### sxName 6 | 7 | Name of photovoltaic array. Give after the word SHADEX. 8 | 9 | {{ 10 | member_table({ 11 | "units": "", 12 | "legal_range": "*63 characters*", 13 | "default": "*none*", 14 | "required": "No", 15 | "variability": "constant" 16 | }) 17 | }} 18 | 19 | ### sxMounting 20 | 21 | Type: choice 22 | 23 | Specifies the mounting location of the shade. sxMounting=Site indicates the SHADEX position is fixed and is not modified if the building is rotated. The position of SHADEXs with sxMounting=Building are modified to include the effect of building rotation specified via [Top bldgAzm][bldgazm] 24 | 25 | {{ 26 | member_table({ 27 | "units": "", 28 | "legal_range": "Building or Site", 29 | "default": "Site", 30 | "required": "No", 31 | "variability": "constant" 32 | }) 33 | }} 34 | 35 | ### sxVertices 36 | 37 | Type: *list of up to 36 floats* 38 | 39 | Vertices of a polygon representing the shape of the shading object. 40 | 41 | The values that follow sxVertices are a series of X, Y, and Z values for the vertices of the polygon. The coordinate system is defined from a viewpoint facing north. X and Y values convey east-west and north-south location respectively relative to an arbitrary origin (positive X value are to the east; positive Y values are to the north). Z values convey height relative to the building 0 level and positive values are upward. 42 | 43 | The vertices are specified in counter-clockwise order when facing the shading object from the south. The number of values provided must be a multiple of 3. The defined polygon must be planar and have no crossing edges. When sxType=Building, the effective position of the polygon reflects building rotation specified by [TOP bldgAzm][top-general-data-items]. 44 | 45 | For example, to specify a rectangular shade "tree" that is 10 x 40 ft, facing south, and 100 ft to the south of the nominal building origin -- 46 | 47 | sxVertices = 5, -100, 0, 15, -100, 0, 15, -100, 40, 5, -100, 40 48 | 49 | {{ 50 | member_table({ 51 | "units": "ft", 52 | "legal_range": "unrestricted", 53 | "default": "*none*", 54 | "required": "9, 12, 15, 18, 21, 24, 27, 30, 33 or 36 values", 55 | "variability": "constant" 56 | }) 57 | }} 58 | 59 | ### endSHADEX 60 | 61 | Optionally indicates the end of the SHADEX definition. Alternatively, the end of the definition can be indicated by END or by beginning another object. 62 | 63 | {{ 64 | member_table({ 65 | "units": "", 66 | "legal_range": "", 67 | "default": "*none*", 68 | "required": "No", 69 | "variability": "constant" 70 | }) 71 | }} 72 | 73 | **Related Probes:** 74 | 75 | - @[SHADEX][p_shadex] 76 | -------------------------------------------------------------------------------- /src/tdpak.h: -------------------------------------------------------------------------------- 1 | // tdpak.h -- declarations for time and date related functions (tdpak.cpp) 2 | 3 | // Copyright (c) 1997-2019 The CSE Authors. All rights reserved. 4 | // Use of this source code is governed by a BSD-style license 5 | // that can be found in the LICENSE file. 6 | 7 | /*-------------------------------- DEFINES --------------------------------*/ 8 | 9 | // Constants - Note that string lengths do NOT include room for '\0' 10 | #define TDFULLDATELENMAX 22 // Max date string length (full format) ("Sun September 26, 1986") 11 | #define TDDATELENMAX 13 // Max date string length (abbr format) ("Sun 26-Sep-86") 12 | #define TDTIMELENMAX 11 // Max time string length ("01:23:14 AM") 13 | #define TDFULLDTLENMAX TDFULLDATELENMAX+TDTIMELENMAX+2 // Max date/time string max length (full format) 14 | #define TDDTLENMAX TDDATELENMAX+TDTIMELENMAX+2 // Max date/time string max length (abbr format) 15 | #define TDYRNODOW -30000 // Pseudo-year which has no day of week associated with it. See tddyw(); 16 | 17 | 18 | // dtypes.def/dtypes.h types used in tdpak calls include: 19 | // IDATE: struct {SI year; SI month; SI mday; SI wday; } 20 | // ITIME: struct {SI hour; SI min; SI sec; } 21 | // IDATETIME: struct {SI year; SI month; SI mday; SI wday; SI hour; SI min; SI sec; } 22 | // LDATETIME: seconds from 1/1/70 23 | // 1-based: .month, .mday; 24 | // 0-based: .wday, .hour, .min, .sec.; typedef SI DOW. 25 | 26 | 27 | // public functions 28 | const char* tdldts( LDATETIME, char *); 29 | void tdldti( LDATETIME, IDATETIME *); 30 | const char* tddtis( IDATETIME *, char *); 31 | const char* tddys( DOY iDoy, int year=-1, char *s = NULL); 32 | void tddyi( IDATE& idt, DOY doy, int year=-1); 33 | DOY tddiy( const IDATE& idt); 34 | DOY tddiy( int month, int mday, int year=-1); 35 | #if 0 36 | int tddiw( IDATE *); 37 | #endif 38 | int tddyw( DOY, int); 39 | const char* tddis( const IDATE& idt, char *s=NULL); 40 | RC tddsi( char *, IDATE *); 41 | int tddmon( const char *); 42 | const char* tddMonAbbrev( int iMon); 43 | const char* tddMonName( int iMon); 44 | const char* tddDowName( int iDow); 45 | const char* tdtis( ITIME *, char *); 46 | DOY tddDoyMonBeg( int iMon); 47 | DOY tddDoyMonEnd( int iMon); 48 | int tddMonLen( int iMon); 49 | DOY tdHoliDate( int year, HDAYCASECH hCase, DOW hDow, int hMon); 50 | 51 | // modern-ish interface used by e.g. ASHRAE solar.cpp 52 | class CALENDAR 53 | { 54 | public: 55 | CALENDAR() {} 56 | 57 | int GetMonDoy( int iDoy, int yr=-1) const; 58 | int GetMDDoy( int iDoy, int yr=-1) const; 59 | int GetDoy( int month, int mDay, int yr=-1) const; 60 | const char* GetMonAbbrev( int month) const; 61 | WStr FmtDOY( int iDoy, int yr=-1, const char* fmt="%b-%d") const; 62 | void FillTM( struct tm& t, const IDATE& idt) const; 63 | 64 | 65 | }; // class CALENDAR 66 | //----------------------------------------------------------------------------- 67 | extern CALENDAR Calendar; // public intance 68 | //============================================================================= 69 | 70 | // tdpak.h end 71 | -------------------------------------------------------------------------------- /src/gmpak.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) 1997-2019 The CSE Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style license 3 | // that can be found in the LICENSE file. 4 | 5 | // abbreviated gmpak declarations for CSE -- gmutil.cpp. 6 | 7 | #ifdef GMPAKH 8 | error duplicate gmpak.h include -- add ifdef GMPAKH 9 | #endif 10 | #define GMPAKH 11 | 12 | 13 | /*-------------------------------- DEFINES --------------------------------*/ 14 | #if 0 // unused in CSE, if 0'd 9-92. 15 | x/* Definitions for gmlnsgpl etc. indicating whether calcs are for 16 | x a LINE (infinite length), RAY (semi-infinite), or SEG (point to point). */ 17 | x#define SEG 0 18 | x#define LINE 1 19 | x#define RAY 2 20 | x#define NEWENDCROSS 0x1000 /* Enables new defintion of GMENDCROSS 21 | x condition in gmlnsgpl() */ 22 | x 23 | x/* line intersection cases -- positive case are not usually fatal */ 24 | x#define LNTCROSS 2 /* "T" intersection */ 25 | x#define LNCONSECT 1 /* consective line segments */ 26 | x#define LNNOCROSS 0 /* no intersection */ 27 | x#define LNCROSS -2 /* plain old fashion "X" */ 28 | x#define LNOVERLAP -3 /* co-linear and overlapping */ 29 | x#define LN0LEN -4 /* line has 0 length */ 30 | x#define LNSETOK 0 /* gmlnset() is ok */ 31 | x 32 | x/* line - plane intersections. Note that gmlnsgpl() code depends on 33 | x these values. Do not change without looking at that routine */ 34 | x#define GMCOPLANAR -1 /* line and plane are coplanar */ 35 | x#define GMNOCROSS 0 /* line and plan do not cross */ 36 | x#define GMCROSS 1 /* plain old cross */ 37 | x#define GMENDCROSS 2 /* end point of segment lies on plane */ 38 | x 39 | x 40 | x/* plane-plane state */ 41 | x#define GMPARALLEL -2 /* planes are parallel */ 42 | x 43 | x#define GM2D 2 44 | x#define GM3D 3 45 | x#define LENGTH2D GM2D 46 | x#define LENGTH3D GM3D 47 | x 48 | x/* angle calculation cases */ 49 | x#define ANGUNDEF 0 /* One of the vectors is 0 */ 50 | x#define ANGOK 1 /* Angle is perfectly determined */ 51 | x#define ANGPI 2 /* Angle is Pi or -Pi */ 52 | #endif 53 | 54 | /* Azimuth Definitions */ 55 | #define GMAZM_N 0 56 | #define GMAZM_NE 1 57 | #define GMAZM_E 2 58 | #define GMAZM_SE 3 59 | #define GMAZM_S 4 60 | #define GMAZM_SW 5 61 | #define GMAZM_W 6 62 | #define GMAZM_NW 7 63 | 64 | #if 0 // unused in CSE, if 0'd 9-92. 65 | x/* Inside polygon test */ 66 | x#define OUTPOL 0 67 | x#define INPOL 1 68 | x#define ONLIN 2 69 | x#define ONPT 3 70 | x 71 | x#define DOT3D(a1,a2) (a1[0]*a2[0]+a1[1]*a2[1]+a1[2]*a2[2]) 72 | x 73 | x/* note POINT is defined in dtypes.h (included via cnglob.h). 74 | x POFF is also defined there. 75 | x a POFF is an offset into project's points array (points.c) */ 76 | #endif 77 | 78 | /*------------------------- FUNCTION DECLARATIONS -------------------------*/ 79 | 80 | // gmutil.cpp: gmpak routines shared with CALRES (including BSGS CALRES) 81 | void FC gmcos2alt( float *dcos, float *altp, float *azmp, SI tol); 82 | SI FC gmazm4( float azm); 83 | SI FC gmazm8( float azm); 84 | 85 | // end of gmpak.h 86 | -------------------------------------------------------------------------------- /src/cuparsei.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) 1997-2019 The CSE Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style license 3 | // that can be found in the LICENSE file. 4 | 5 | // cuparsei.h Operator table defines and decls for CSE user language 6 | 7 | 8 | /*--------------------- OPERATOR TABLE definitions ----------------------*/ 9 | 10 | /*----- "cs" values for opTbl, cuparse:expr(), ppcex:ceval() */ 11 | #define CSUNI 101 // unary integer operator 12 | #define CSUNN 102 // unary numeric operator. v1,2 are int, float psc 13 | #define CSBII 103 // binary integer operator 14 | #define CSBIF 104 // binary float operator ( ' for ft-inches) 15 | #define CSBIN 105 // binary numeric operator. .v1, .v2 ditto 16 | #define CSCMP 106 // comparison (args numeric, result int) 17 | #define CSLEO 107 // && or ||. v1 is cond jmp/pop to put between exprs 18 | #define CSGRP 108 // grouper ( [ 19 | #define CSCUT 109 // has subcase by token type 20 | #define CSU 110 // error if dispatched to (terminators) 21 | 22 | /*----- "prec" (precedence) values for opTbl, cuparse:expr(), ppcex:ceval() */ 23 | /* Data type SI. code assumes order of values !!!. */ 24 | #define PREOF 1 // end of file or end of preprocessor cmd 25 | #define PRVRB 2 // verbs (statement-initiating keywords) 26 | //verbs have unique prec so can test prec to test for any verb 27 | #define PRVRBL 3 // other verbLike words: AUTOSIZE, LIKE, TYPE,... 28 | #define PRTY 5 // types INTEGER,FLOAT,... . verb-like and other uses. 29 | // unique prec so can test for types as a group (not yet used 12-90) 30 | #define PRSEM 6 // ; 31 | #define PRRGR 7 // ) ]: close group, end fcn call 32 | #define PRDEFA 8 // "default" (replaces , in certain fcn calls) and misc keywords: FUNCTION, VARIABLE, . 33 | #define PRCOM 9 // , 34 | #define PRASS 10 // assignment 35 | // ... many included literally in opTbl[] ... 36 | // 13 ? 12 : (?: operator) 37 | // 15 || 16 && 38 | // 17 | 18 ^ 19 & 39 | // 24 == != 25 < <= > >= 28 << >> 40 | // 30 + - 32 * / % 41 | // 34 ! ~ unary + - month words (jan-dec, impl as unary ops) 42 | // 36 ' (feet-inches, 2-92. Note binding power hier than unary - ) 43 | #define PROP 40 /* all operands are this value OR LARGER: constant, variable, fcn ref, (, [, (expr), etc. 44 | (use diff values if want to distinguish by prec) */ 45 | #define perr 99 // not understood by parser 46 | 47 | 48 | /*------- OPERATOR/OPERAND TABLE to drive two parsers: 49 | preprocessor parser in ppCex.c, and compiler parser in cuparse.c. 50 | subscript is token type (defines in cutok.h) 51 | as returned by cutok.c:cuTok() and refined by cuparse.c:toke(), 52 | or returned by ppTok.c:ppTok() and refined by ppCex:ppToke(). */ 53 | struct OPTBL 54 | { SI prec; // (left) precedence: determines order of operations 55 | SI cs; // case: CSBIN CSUNN CSGRP 56 | SI v1; // value 1: si ps si ps expected CUTxx 57 | SI v2; // value 2: fl ps fl ps exp. 'token' 58 | const char* tx; // for ttTx, thence error messages. 59 | }; 60 | extern OPTBL opTbl[]; // data is in cuparse.cpp 61 | 62 | // end of cuparsei.h 63 | -------------------------------------------------------------------------------- /test/unit/nummeth.unit.cpp: -------------------------------------------------------------------------------- 1 | // nummeth.unit.cpp - test uses of numerical-method functions 2 | 3 | #include "gtest/gtest.h" 4 | 5 | #include "cnglob.h" 6 | #include "cvpak.h" 7 | #include "nummeth.h" 8 | 9 | // linear function 10 | static double linear_func(void *, double &x) { 11 | return x; 12 | } 13 | 14 | // inverse function 15 | static double inverse_func(void *, double &x) { 16 | double f = DBL_MAX; 17 | if (abs(x) > 0.0001) { 18 | f = 1. / x; 19 | } 20 | return f; 21 | } 22 | 23 | TEST(nummeth, secant_test) { 24 | 25 | double eps = .0001; 26 | 27 | { // solution of linear function 28 | double x1 = 1., x2 = 3.; 29 | double f1 = DBL_MIN, f2 = DBL_MIN; 30 | double fTarg = 2.; 31 | 32 | int ret = secant(linear_func, NULL, fTarg, eps * fTarg, x1, f1, // x1, f1 33 | x2, f2); // x2, f2 34 | 35 | EXPECT_EQ(ret, 0) << "secant solution of linear function failed."; 36 | double xExpected = fTarg; 37 | EXPECT_NEAR(x1, xExpected, eps) 38 | << "expected solution of linear function not found."; 39 | } 40 | 41 | { // solution of inverse function 42 | double x1 = 0.01, x2 = 1.0; 43 | double f1 = DBL_MIN, f2 = DBL_MIN; 44 | double fTarg = 2.; 45 | 46 | int ret = 47 | secant(inverse_func, NULL, fTarg, eps * fTarg, x1, f1, // x1, f1 48 | x2, f2); // x2, f2 49 | 50 | EXPECT_EQ(ret, 0) << "secant solution of inverse function failed."; 51 | double xExpected = 1. / fTarg; 52 | EXPECT_NEAR(x1, xExpected, eps) 53 | << "expected solution of inverse function not found."; 54 | } 55 | 56 | { // solution of inverted inverse function 57 | double x1 = 0.01, x2 = 1.0; 58 | double f1 = DBL_MIN, f2 = DBL_MIN; 59 | double fTarg = 1. / 2.; 60 | 61 | 62 | 63 | int ret = 64 | secant([](void*, double& x){return 1./inverse_func(NULL, x);}, NULL, fTarg, eps * fTarg, x1, f1, // x1, f1 65 | x2, f2); // x2, f2 66 | 67 | EXPECT_EQ(ret, 0) << "secant solution of inverted inverse function failed."; 68 | double xExpected = fTarg; 69 | EXPECT_NEAR(x1, xExpected, eps) 70 | << "expected solution of inverted inverse function not found."; 71 | } 72 | 73 | { // solution of inverted inverse function (below "zero" tolerance) 74 | double x1 = 0.01, x2 = 1.0; 75 | double f1 = DBL_MIN, f2 = DBL_MIN; 76 | double fTarg = 0.00005; 77 | 78 | 79 | 80 | int ret = 81 | secant([](void*, double& x){return 1./inverse_func(NULL, x);}, NULL, fTarg, eps * fTarg, x1, f1, // x1, f1 82 | x2, f2); // x2, f2 83 | 84 | EXPECT_EQ(ret, -3) << "secant solution of inverted inverse function failed."; 85 | double xExpected = fTarg; 86 | EXPECT_NEAR(x1, xExpected, eps) 87 | << "expected solution of inverted inverse function not found."; 88 | } 89 | 90 | 91 | } 92 | -------------------------------------------------------------------------------- /test/ref-win32-msvc/ExportFileOutput.rep: -------------------------------------------------------------------------------- 1 | 2 | 3 | Monthly Energy Balance, Sum of Zones 4 | 5 | Mon Tair WBair Cond InfS Slr IgnS Mass Izone MechS BalS InfL IgnL IzoneL AirL MechL BalL 6 | ---- ----- ----- ------ ------ ----- ----- ------ ------ ------ ---- ------ ----- ------ ------ ------ ---- 7 | Jan 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 8 | Feb 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 9 | Mar 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 10 | Apr 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 11 | May 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 12 | Jun 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 13 | Jul 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 14 | Aug 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 15 | Sep 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 16 | Oct 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 17 | Nov 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 18 | Dec 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 19 | 20 | Yr 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 21 | 22 | 23 | 24 | ! Log for Run 001: 25 | 26 | ! CSE 0.920.0+main.99c64c5b.17 for Win32 console 27 | 28 | 29 | 30 | Input for Run 001: 31 | 32 | EXPORTFILE 33 | xfFileName=EXPORT_FILE_ABSOLUTE_PATH 34 | 35 | EXPORTFILE 36 | xfFileName=".\\..\\test\\relativePathExportFile.csv" 37 | 38 | EXPORTFILE 39 | xfFileName="noPathExportFile.csv" 40 | 41 | WfName="Bishop.epw" 42 | 43 | RUN 44 | 45 | 46 | 47 | ! CSE 0.920.0+main.99c64c5b.17 for Win32 console run(s) done: Mon 18-Dec-23 4:38:33 pm 48 | 49 | ! Executable: d:\cse\msvc\cse.exe 50 | ! 18-Dec-23 4:07 pm (VS 14.29 2796544 bytes) (HPWH 1.22.0+HEAD.f9b8f77.122) 51 | ! Command line: -x! -b -t1 52 | ! -DEXPORT_FILE_ABSOLUTE_PATH="D:/cse/test/absolutePathEXPORTFILE.csv" 53 | ! ExportFileOutput 54 | ! Input file: D:\cse\test\ExportFileOutput.cse 55 | ! Report file: D:\CSE\TEST\EXPORTFILEOUTPUT.REP 56 | 57 | ! Timing info -- 58 | 59 | ! Input: Time = 0.11 Calls = 1 T/C = 0.1130 60 | ! AutoSizing: Time = 0.00 Calls = 0 T/C = 0.0000 61 | ! Simulation: Time = 0.10 Calls = 1 T/C = 0.0990 62 | ! Reports: Time = 0.00 Calls = 1 T/C = 0.0000 63 | ! Total: Time = 0.21 Calls = 1 T/C = 0.2120 64 | -------------------------------------------------------------------------------- /doc/src/docs/input-data/layer.md: -------------------------------------------------------------------------------- 1 | # LAYER 2 | 3 | LAYER constructs a subobject of class LAYER belonging to the current CONSTRUCTION. LAYER is not recognized except immediately following CONSTRUCTION or another LAYER. The members represent one layer (that optionally includes framing) within the CONSTRUCTION. 4 | 5 | The layers should be specified in inside to outside order. A framed layer (lrFrmMat and lrFrmFrac given) is modeled by creating a homogenized material with weighted combined conductivity and volumetric heat capacity. Caution: it is generally preferable to model framed constructions using two separate surfaces (one with framing, one without). At most one framed layer (lrFrmMat and lrFrmFrac given) is allowed per construction. 6 | 7 | The layer thickness may be given by lrThk, or matThk of the material, or matThk of the framing material if any. The thickness must be specified at least one of these three places; if specified in more than one place and not consistent, an error message occurs. 8 | 9 | ### lrName 10 | 11 | Name of layer (follows "LAYER"). Required only if the LAYER is later referenced in another object, for example with LIKE or ALTER; however, we suggest naming all objects for clearer error messages and future flexibility. 12 | 13 | {{ 14 | member_table({ 15 | "units": "", 16 | "legal_range": "*63 characters*", 17 | "default": "*none*", 18 | "required": "No", 19 | "variability": "constant" 20 | }) 21 | }} 22 | 23 | ### lrMat 24 | 25 | Type: matName 26 | 27 | Name of primary MATERIAL in layer. 28 | 29 | {{ 30 | member_table({ 31 | "units": "", 32 | "legal_range": "name of a *MATERIAL*", 33 | "default": "*none*", 34 | "required": "Yes", 35 | "variability": "constant" 36 | }) 37 | }} 38 | 39 | ### lrThk 40 | 41 | Type: float 42 | 43 | Thickness of layer. 44 | 45 | {{ 46 | member_table({ 47 | "units": "ft", 48 | "legal_range": "*x* > 0", 49 | "default": "Required if *matThk* not specified in referenced *lrMat*", 50 | "required": "No", 51 | "variability": "constant" 52 | }) 53 | }} 54 | 55 | ### lrFrmMat 56 | 57 | Type: matName 58 | 59 | Name of framing MATERIAL in layer, if any. At most one layer with lrFrmMat is allowed per CONSTRUCTION. See caution above regarding framed-layer model. 60 | 61 | {{ 62 | member_table({ 63 | "units": "", 64 | "legal_range": "name of a MATERIAL", 65 | "default": "*no framed layer*", 66 | "required": "No", 67 | "variability": "constant" 68 | }) 69 | }} 70 | 71 | ### lrFrmFrac 72 | 73 | Type: float 74 | 75 | Fraction of layer that is framing. Must be specified if frmMat is specified. See caution above regarding framed-layer model. 76 | 77 | {{ 78 | member_table({ 79 | "units": "", 80 | "legal_range": "0 ≤ *x* ≤ 1", 81 | "default": "*no framed layer*", 82 | "required": "Required if *lrFrmMat* specified, else disallowed", 83 | "variability": "constant" 84 | }) 85 | }} 86 | 87 | ### endLayer 88 | 89 | Optional end-of-LAYER indicator; LAYER definition may also be indicated by "END" or just starting the definition of another LAYER or other object. 90 | 91 | **Related Probes:** 92 | 93 | - @[layer][p_layer] 94 | -------------------------------------------------------------------------------- /doc/src/docs/input-data/loadmeter.md: -------------------------------------------------------------------------------- 1 | # LOADMETER 2 | 3 | A LOADMETER object is a user-defined "device" that records heating and cooling loads as computed by CSE. The user defines LOADMETERs and assigns them to ZONEs and/or RSYSs (see ZONE znLoadMtr and RSYS rsLoadMtr). 4 | 5 | Loads are accumulated for subhour, hour, day, month, and annual intervals. All values are in Btu. Values >0 indicated heat into the process or zone -- thus heating loads are >0 and cooling loads are <0. 6 | 7 | LOADMETER results must be reported using user-defined REPORTs or EXPORTs. For example -- 8 | 9 | REPORT rpType=UDT rpFreq=Month rpDayBeg=Jan 1 rpDayEnd=Dec 31 10 | REPORTCOL colHead="mon" colVal=$Month colWid=3 11 | REPORTCOL colHead="Heating" colVal=@LoadMeter[ 1].M.qHtg colDec=0 colWid=10 12 | REPORTCOL colHead="Cooling" colVal=@LoadMeter[ 1].M.qClg colDec=0 colWid=10 13 | 14 | 15 | ### ldMtrName 16 | 17 | Name of LOADMETER: required for assigning to ZONEs and RSYSs. 18 | 19 | {{ 20 | member_table({ 21 | "units": "", 22 | "legal_range": "*63 characters*", 23 | "default": "*none*", 24 | "required": "Yes", 25 | "variability": "constant" 26 | }) 27 | }} 28 | 29 | ### lmtSubmeters 30 | 31 | Type: *list of up to 50 LOADMETERs* 32 | 33 | A comma-separate list of LOADMETERs that are accumulated into this LOADMETER with optional multipliers (see lmtSubmeterMults). Submeters facilitate flexible categorization of loads results. In addition, use of lmtSubmeterMults allows load results from a representative model to be scaled and included in overall results. For example, a typical zone could be used to represent 5 similar spaces. The loads calculated for the typical zone could be assigned to a dedicated LOADMETER and that LOADMETER accumulated to a main LOADMETER with a multiplier of 5. Rules -- 34 | 35 | - A LOADMETER cannot reference itself as a submeter. 36 | - A given LOADMETER can be referenced only once in the lmtSubmeters list. 37 | - Circular references are not allowed. 38 | 39 | {{ 40 | member_table({ 41 | "units": "", 42 | "legal_range": "*names of LOADMETERs*", 43 | "default": "", 44 | "required": "No", 45 | "variability": "constant" 46 | }) 47 | }} 48 | 49 | ### lmtSubmeterMults 50 | 51 | Type: *list of up to 50 floats* 52 | 53 | Submeter multipliers. 54 | 55 | A note re default values: if lmtSubmeterMults is omitted, all multipliers are defaulted to 1. However, when lmtSubmeterMults is included, a multiplier value should be provided for each LOADMETER listed in lmtSubmeters since unspecified values are set to 0. 56 | 57 | {{ 58 | member_table({ 59 | "units": "", 60 | "legal_range": "", 61 | "default": "1", 62 | "required": "No", 63 | "variability": "subhourly" 64 | }) 65 | }} 66 | 67 | 68 | ### endLOADMETER 69 | 70 | Indicates the end of the meter definition. Alternatively, the end of the meter definition can be indicated by the declaration of another object or by END. 71 | 72 | {{ 73 | member_table({ 74 | "units": "", 75 | "legal_range": "", 76 | "default": "*none*", 77 | "required": "No", 78 | "variability": "constant" 79 | }) 80 | }} 81 | 82 | **Related Probes:** 83 | 84 | - @[loadmeter][p_loadmeter] 85 | -------------------------------------------------------------------------------- /src/lookup.cpp: -------------------------------------------------------------------------------- 1 | // Copyright (c) 1997-2019 The CSE Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style license 3 | // that can be found in the LICENSE file. 4 | 5 | // lookup.cpp -- various table look up functions. 6 | 7 | /* ----------------------------- INCLUDES -------------------------------- */ 8 | #include "cnglob.h" 9 | 10 | #include "lookup.h" // decls for this file; structure definitions for WWTABLE etc 11 | 12 | 13 | //=========================================================================== 14 | int lookw( // word table searcher 15 | 16 | int key, // value sought in table 17 | const int* table) // pointer to array of ints, ended by 32767 18 | 19 | // fcn value is 0-based position in table or -1 if not there 20 | { 21 | const int* sip = table; 22 | while (*sip != 32767) 23 | { 24 | if (*sip==key) 25 | return (sip - table); // found, return subscript 26 | sip++; 27 | } 28 | return -1; // not found 29 | 30 | } // lookw 31 | //=========================================================================== 32 | int lookww( // word-word table searcher -- general use routine 33 | 34 | int key, 35 | const WWTABLE* table ) // table is key, value pairs, ended by 32767, default 36 | 37 | // fcn value is table value for key, or default (last entry) if not found 38 | { 39 | while (1) 40 | { 41 | if (table->key==key || table->key==32767) 42 | return table->value; 43 | table++; 44 | } 45 | } // lookww 46 | //=========================================================================== 47 | const char* FC lookws( // word-string table searcher 48 | 49 | int key, 50 | const WSTABLE* table ) // key, string pairs, ended by 32767, default 51 | 52 | // fcn value is table value for key, or default (last entry) if not found 53 | { 54 | while (1) 55 | { 56 | if (table->key==key || table->key==32767) 57 | return table->string; 58 | table++; 59 | } 60 | } // lookws 61 | 62 | //=========================================================================== 63 | int lookswl( int index, const SWLTAB* table) 64 | 65 | // retrieve member from subscripted word with limits table (lookup.h) 66 | 67 | // returns contents of table slot, or 0 if index out of range 68 | { 69 | if (index < table->ixMin || index >= table->ixMax) 70 | return 0; 71 | return table->val[ index - table->ixMin ]; 72 | } // lookswl 73 | 74 | //========================================================================= 75 | int looksw( // string/word table lookup 76 | 77 | const char* string, // String sought 78 | const SWTABLE* swtab, // Table in which to look, terminated with NULL 79 | bool bCaseSensitive /*=false*/) 80 | 81 | // Returns value in table corresponding to name. 82 | // If not found, returns entry corresponding to NULL in table 83 | { 84 | int i = -1; 85 | while ((swtab+(++i))->key != NULL) 86 | { 87 | if ((bCaseSensitive ? strcmp : _stricmp)(string, (swtab + i)->key) == 0) 88 | break; 89 | } 90 | return (swtab+i)->val; 91 | 92 | } // looksw 93 | //========================================================================= 94 | 95 | // end of lookup.cpp 96 | -------------------------------------------------------------------------------- /test/PVTest.cse: -------------------------------------------------------------------------------- 1 | // PV Test file 2 | 3 | WfName="Boulder.epw" 4 | wuDays=0 5 | nSubSteps=1 6 | 7 | METER Elec0 8 | 9 | PVARRAY "Flat" 10 | pvElecMtr = Elec0 11 | pvEndUse = PV 12 | pvDCSysSize = 5 13 | pvModuleType = Standard 14 | pvArrayType = FixedOpenRack 15 | pvTilt = 0 16 | pvAzm = 180 17 | pvGrndRefl = 0.2 18 | 19 | PVARRAY "S_30" LIKE "Flat" 20 | pvTilt = 30 21 | pvAzm = 180 22 | 23 | PVARRAY "S_60" LIKE "Flat" 24 | pvTilt = 60 25 | pvAzm = 180 26 | 27 | PVARRAY "S_90" LIKE "Flat" 28 | pvTilt = 90 29 | pvAzm = 180 30 | 31 | PVARRAY "E_30" LIKE "Flat" 32 | pvTilt = 30 33 | pvAzm = 90 34 | 35 | PVARRAY "E_60" LIKE "Flat" 36 | pvTilt = 60 37 | pvAzm = 90 38 | 39 | PVARRAY "E_90" LIKE "Flat" 40 | pvTilt = 90 41 | pvAzm = 90 42 | 43 | PVARRAY "W_30" LIKE "Flat" 44 | pvTilt = 30 45 | pvAzm = 270 46 | 47 | PVARRAY "W_60" LIKE "Flat" 48 | pvTilt = 60 49 | pvAzm = 270 50 | 51 | PVARRAY "W_90" LIKE "Flat" 52 | pvTilt = 90 53 | pvAzm = 270 54 | 55 | PVARRAY "N_30" LIKE "Flat" 56 | pvTilt = 30 57 | pvAzm = 0 58 | 59 | PVARRAY "N_60" LIKE "Flat" 60 | pvTilt = 60 61 | pvAzm = 0 62 | 63 | PVARRAY "N_90" LIKE "Flat" 64 | pvTilt = 90 65 | pvAzm = 0 66 | 67 | PVARRAY "Premium" LIKE "S_30" 68 | pvModuleType = Premium 69 | 70 | PVARRAY "ThinFilm" LIKE "S_30" 71 | pvModuleType = ThinFilm 72 | 73 | PVARRAY "Custom" LIKE "S_30" 74 | pvModuleType = Custom 75 | pvCoverRefrInd = 1.5 76 | pvTempCoeff = -0.001 77 | 78 | PVARRAY "RoofMount" LIKE "S_30" 79 | pvArrayType = FixedRoofMount 80 | 81 | PVARRAY "OneAxis" LIKE "S_30" 82 | pvArrayType = OneAxisTracking 83 | 84 | PVARRAY "OneAxisBT" LIKE "S_30" 85 | pvArrayType = OneAxisTracking 86 | 87 | PVARRAY "TwoAxis" LIKE "S_30" 88 | pvArrayType = TwoAxisTracking 89 | UNSET pvTilt 90 | UNSET pvAzm 91 | 92 | PVARRAY "HighRatio" LIKE "S_30" 93 | pvDCtoACRatio = 1.5 94 | 95 | 96 | DELETE REPORT "EB" 97 | 98 | EXPORTFILE "PVout" 99 | xfFileName="PVout" 100 | xfFileStat=OVERWRITE 101 | 102 | #define PVCols( n ) \ 103 | ExportCol colhead=n colVal=@PVArray[n].acOut 104 | 105 | 106 | EXPORT exExportFile="PVout" exType=UDT exFreq=HOUR exTitle="PV Output" exDayBeg=jan 1 exDayEnd=dec 31 exHeader=ColumnsOnly 107 | ExportCol colhead="Day" colVal=@Top.dateStr 108 | ExportCol colhead="Hour" colVal=@Top.iHr 109 | ExportCol colhead="ST Hour" colVal=@Top.iHrST 110 | ExportCol colhead="Outdoor Drybulb" colVal=@Top.tDbOHrAv 111 | ExportCol colhead="Beam Radiation" colVal=@Top.radBeamHrAv 112 | ExportCol colhead="Diff. Radiation" colVal=@Top.radDiffHrAv 113 | PVCols( "Flat" ) 114 | PVCols( "S_30" ) 115 | PVCols( "S_60" ) 116 | PVCols( "S_90" ) 117 | PVCols( "E_30" ) 118 | PVCols( "E_60" ) 119 | PVCols( "E_90" ) 120 | PVCols( "W_30" ) 121 | PVCols( "W_60" ) 122 | PVCols( "W_90" ) 123 | PVCols( "N_30" ) 124 | PVCols( "N_60" ) 125 | PVCols( "N_90" ) 126 | PVCols( "Premium" ) 127 | PVCols( "ThinFilm" ) 128 | PVCols( "Custom" ) 129 | PVCols( "RoofMount" ) 130 | PVCols( "OneAxis" ) 131 | PVCols( "OneAxisBT" ) 132 | PVCols( "TwoAxis" ) 133 | PVCols( "HighRatio" ) 134 | 135 | REPORT rpType=MTR rpMeter=Elec0 rpFreq=Month 136 | 137 | RUN 138 | -------------------------------------------------------------------------------- /cmake/initialize-submodules.cmake: -------------------------------------------------------------------------------- 1 | macro(initialize_submodules) 2 | if(GIT_FOUND AND EXISTS "${PROJECT_SOURCE_DIR}/.git") 3 | # Initialize submodules 4 | set(git_modules_file "${PROJECT_SOURCE_DIR}/.gitmodules") 5 | if (EXISTS ${git_modules_file}) 6 | file(STRINGS ${git_modules_file} file_lines) 7 | foreach(line ${file_lines}) 8 | if (${line} MATCHES "url =") 9 | string(REGEX REPLACE "\\s*url = .*/(.*).git" "\\1" submodule "${line}") 10 | string(STRIP "${submodule}" submodule) 11 | if(NOT EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/${submodule}") 12 | message(FATAL_ERROR "Submodule directory \"${CMAKE_CURRENT_SOURCE_DIR}/${submodule}\" does not exist") 13 | endif() 14 | # Initialize submodule if it hasn't already been cloned 15 | if(NOT EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/${submodule}/.git") 16 | message(STATUS "Initialize ${submodule} submodule") 17 | execute_process(COMMAND ${GIT_EXECUTABLE} submodule update --init --recursive "${CMAKE_CURRENT_SOURCE_DIR}/${submodule}" 18 | WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} 19 | RESULT_VARIABLE GIT_SUBMOD_RESULT) 20 | if(NOT GIT_SUBMOD_RESULT EQUAL "0") 21 | message(FATAL_ERROR "git submodule update --init --recursive ${CMAKE_CURRENT_SOURCE_DIR}/${submodule} failed with ${GIT_SUBMOD_RESULT}, please checkout submodules") 22 | endif() 23 | endif() 24 | endif() 25 | endforeach() 26 | endif() 27 | 28 | # Create git hooks 29 | option(CREATE_GIT_HOOKS "Create git hooks to automatically update submodules." ON) 30 | if (CREATE_GIT_HOOKS) 31 | # post-checkout 32 | if (NOT EXISTS "${PROJECT_SOURCE_DIR}/.git/hooks/post-checkout") 33 | file(WRITE "${PROJECT_SOURCE_DIR}/.git/hooks/post-checkout" 34 | "#!/bin/sh 35 | 36 | echo \"Running .git/hooks/post-checkout\" 37 | echo 38 | 39 | echo \"git submodule sync --recursive\" 40 | echo 41 | git submodule sync --recursive 42 | 43 | echo \"git submodule update --init --recursive\" 44 | git submodule update --init --recursive 45 | 46 | " 47 | ) 48 | endif() 49 | # post-merge 50 | if (NOT EXISTS "${PROJECT_SOURCE_DIR}/.git/hooks/post-merge") 51 | file(WRITE "${PROJECT_SOURCE_DIR}/.git/hooks/post-merge" 52 | "#!/bin/sh 53 | 54 | # Note: Merge also happens after pull command. 55 | echo \"Running .git/hooks/post-merge\" 56 | echo 57 | 58 | echo \"git submodule sync --recursive\" 59 | echo 60 | git submodule sync --recursive 61 | 62 | echo \"git submodule update --init --recursive\" 63 | git submodule update --init --recursive 64 | 65 | " 66 | ) 67 | endif() 68 | # pre-push 69 | if (NOT EXISTS "${PROJECT_SOURCE_DIR}/.git/hooks/pre-push") 70 | file(WRITE "${PROJECT_SOURCE_DIR}/.git/hooks/pre-push" 71 | "#!/bin/sh 72 | 73 | echo \"Running .git/hooks/pre-push\" 74 | 75 | # Check if any submodules have unpushed commits. 76 | if ! [[ -z $(git submodule --quiet foreach --recursive 'git log --branches --not --remotes') ]]; then 77 | echo 78 | echo \"Warning: You have unpushed commits in one or more submodules. Don't forget to\" 79 | echo \"push them if the parent repository is expecting those changes.\" 80 | fi 81 | 82 | " 83 | ) 84 | endif() 85 | endif() 86 | endif() 87 | endmacro() -------------------------------------------------------------------------------- /test/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | add_subdirectory(unit) 2 | 3 | add_subdirectory(wcmp) 4 | 5 | add_subdirectory(error_handling) 6 | 7 | set( ref_dir "ref-${CSE_OS_NAME}${CSE_BUILD_ARCHITECTURE}-${CSE_COMPILER_NAME}") 8 | 9 | macro(make_cse_test case) 10 | get_filename_component(test_name ${case} NAME_WE) 11 | set(test_comment "! ") 12 | add_test(NAME ${test_name}.Run 13 | COMMAND $ -x${test_comment} -b -t1 ${ARGN} "${test_name}" 14 | WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}" 15 | ) 16 | 17 | if (EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/${ref_dir}") 18 | add_test(NAME ${test_name}.Regression 19 | COMMAND $ "${CMAKE_CURRENT_SOURCE_DIR}/${test_name}.rep" "${CMAKE_CURRENT_SOURCE_DIR}/${ref_dir}/${test_name}.rep" "!" 20 | WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}" 21 | ) 22 | set_tests_properties(${test_name}.Regression PROPERTIES DEPENDS ${test_name}.Run) 23 | endif () 24 | endmacro() 25 | 26 | make_cse_test(minimum_running_file.cse) 27 | make_cse_test(commands.cse) 28 | make_cse_test(expressions.cse) 29 | make_cse_test(wthr01.cse) 30 | make_cse_test(accumulator.cse) 31 | make_cse_test(600.cse) 32 | make_cse_test(930.cse) 33 | make_cse_test(960.cse) 34 | make_cse_test(2Zone.cse) 35 | make_cse_test(3ZAirNetAH.cse) 36 | make_cse_test(Fresno.cse) 37 | make_cse_test(Autosize.cse) 38 | make_cse_test(masstest1.cse) 39 | #make_cse_test(12P21M) 40 | #make_cse_test(1ZCZMU) 41 | make_cse_test(Z2SG.cse) 42 | make_cse_test(zonetest4W.cse) 43 | make_cse_test(zt5d.cse) 44 | make_cse_test(qw5ds.cse) 45 | make_cse_test(izfantest.cse) 46 | #make_cse_test(2700x) 47 | make_cse_test(2zun.cse) 48 | make_cse_test(1zattic.cse) 49 | make_cse_test(1ZKiva.cse) 50 | make_cse_test(2zattic.cse) 51 | make_cse_test(convection.cse) 52 | make_cse_test(actest1bL.cse) 53 | make_cse_test(ashptest2) 54 | make_cse_test(ashpPkgRoom) 55 | make_cse_test(ashp_dfng) 56 | make_cse_test(perfmap) 57 | make_cse_test(perfmap3) 58 | make_cse_test(perfmap2z) 59 | make_cse_test(fancoil) 60 | make_cse_test(wshp) 61 | make_cse_test(herv) 62 | make_cse_test(Multifamily-DOAS) 63 | make_cse_test(oavtest2) 64 | make_cse_test(bgtest) 65 | make_cse_test(ashwat1) 66 | make_cse_test(loadAndAFMeters) 67 | make_cse_test(dhw02) 68 | make_cse_test(dhwX) 69 | make_cse_test(dhwDU) 70 | make_cse_test(dhw_C) 71 | make_cse_test(dhw_solar) 72 | make_cse_test(dhw_zone) 73 | make_cse_test(dhw_dr) 74 | make_cse_test(dwhr) 75 | make_cse_test(dhwls) 76 | make_cse_test(DHW_INV ) 77 | make_cse_test(dhw_uef) 78 | make_cse_test(dhw_brwl) 79 | make_cse_test(dhwloop32U) 80 | make_cse_test(dhw_mfsizing) 81 | make_cse_test(dhw_aquathermaire) 82 | make_cse_test(chdhw) 83 | make_cse_test(pvtest) 84 | make_cse_test(pv_bt_test) 85 | make_cse_test(bt_test) 86 | make_cse_test(submeter) 87 | make_cse_test(shadetest) 88 | make_cse_test(CRTerminalAH) 89 | make_cse_test(MF8X) 90 | make_cse_test(ExportFileOutput -DEXPORT_FILE_ABSOLUTE_PATH="${CMAKE_SOURCE_DIR}/test/absolutePathEXPORTFILE.csv") 91 | 92 | if (${CMAKE_HOST_SYSTEM_NAME} STREQUAL "Windows") 93 | set(script_ext "bat") 94 | set(shell_path "REM Batch script") 95 | else() 96 | set(script_ext "sh") 97 | set(shell_path "#!/bin/bash") 98 | endif() 99 | 100 | configure_file("diff.bat.in" "${CMAKE_BINARY_DIR}/diff.${script_ext}" FILE_PERMISSIONS OWNER_EXECUTE OWNER_WRITE OWNER_READ) 101 | configure_file("update.bat.in" "${CMAKE_BINARY_DIR}/update.${script_ext}" FILE_PERMISSIONS OWNER_EXECUTE OWNER_WRITE OWNER_READ) 102 | 103 | 104 | -------------------------------------------------------------------------------- /cmake/CSEVersion.cmake: -------------------------------------------------------------------------------- 1 | # Generate CSE Version header 2 | 3 | if(DEFINED ENV{CI_GIT_BRANCH}) 4 | set(GIT_BRANCH "$ENV{CI_GIT_BRANCH}") 5 | else() 6 | execute_process( 7 | COMMAND git rev-parse --abbrev-ref HEAD 8 | WORKING_DIRECTORY ${PROJECT_SOURCE_DIR} 9 | RESULT_VARIABLE git_branch_exit_status 10 | OUTPUT_VARIABLE GIT_BRANCH 11 | OUTPUT_STRIP_TRAILING_WHITESPACE 12 | ) 13 | if (NOT ${git_branch_exit_status} MATCHES "0") 14 | message(FATAL_ERROR "GIT_BRANCH is not accessible." ) 15 | endif() 16 | endif() 17 | 18 | execute_process( 19 | COMMAND ${GIT_EXECUTABLE} rev-parse --verify --short HEAD 20 | WORKING_DIRECTORY ${PROJECT_SOURCE_DIR} 21 | RESULT_VARIABLE git_sha_exit_status 22 | OUTPUT_VARIABLE GIT_SHA 23 | OUTPUT_STRIP_TRAILING_WHITESPACE 24 | ) 25 | 26 | if (NOT ${git_sha_exit_status} MATCHES "0") 27 | message(FATAL_ERROR "GIT_SHA is not accessible." ) 28 | endif() 29 | 30 | execute_process( 31 | COMMAND ${GIT_EXECUTABLE} describe --tags --abbrev=0 32 | WORKING_DIRECTORY ${PROJECT_SOURCE_DIR} 33 | RESULT_VARIABLE git_tag_exit_status 34 | OUTPUT_VARIABLE GIT_TAG 35 | OUTPUT_STRIP_TRAILING_WHITESPACE 36 | ) 37 | 38 | if (NOT ${git_tag_exit_status} MATCHES "0") 39 | message(FATAL_ERROR "GIT_TAG is not accessible." ) 40 | endif() 41 | 42 | if (GIT_TAG MATCHES "^v[0-9]+\\.[0-9]+\\.[0-9]+(\\-[0-9A-Za-z-]+)?$") 43 | string(REGEX REPLACE "^v([0-9]+)\\.[0-9]+\\.[0-9]+(\\-[0-9A-Za-z-]+)?$" "\\1" CSEVRSN_MAJOR "${GIT_TAG}") 44 | string(REGEX REPLACE "^v[0-9]+\\.([0-9]+)\\.[0-9]+(\\-[0-9A-Za-z-]+)?$" "\\1" CSEVRSN_MINOR "${GIT_TAG}") 45 | string(REGEX REPLACE "^v[0-9]+\\.[0-9]+\\.([0-9]+)(\\-[0-9A-Za-z-]+)?$" "\\1" CSEVRSN_PATCH "${GIT_TAG}") 46 | if (GIT_TAG MATCHES "^v[0-9]+\\.[0-9]+\\.[0-9]+(\\-[0-9A-Za-z-]+)$") 47 | string(REGEX REPLACE "^v[0-9]+\\.[0-9]+\\.[0-9]+(\\-[0-9A-Za-z-]+)$" "\\1" CSEVRSN_PRERELEASE "${GIT_TAG}") 48 | endif() 49 | elseif(GIT_TAG MATCHES "^cse\\.[0-9]+$") 50 | # old version scheme 51 | set(CSEVRSN_MAJOR "0") 52 | string(REGEX REPLACE "^cse\\.([0-9]+)$" "\\1" CSEVRSN_MINOR "${GIT_TAG}") 53 | set(CSEVRSN_PATCH "0") 54 | else() 55 | message(FATAL_ERROR "GIT_TAG ${GIT_TAG} must have format 'v..' or 'v..-'." ) 56 | endif() 57 | 58 | execute_process( 59 | COMMAND ${GIT_EXECUTABLE} rev-list --count HEAD ^${GIT_TAG} 60 | WORKING_DIRECTORY ${PROJECT_SOURCE_DIR} 61 | RESULT_VARIABLE git_build_exit_status 62 | OUTPUT_VARIABLE GIT_BUILD 63 | OUTPUT_STRIP_TRAILING_WHITESPACE 64 | ) 65 | 66 | if (NOT ${git_build_exit_status} MATCHES "0") 67 | message(FATAL_ERROR "GIT_BUILD value ${GIT_BUILD} is not accessible." ) 68 | endif() 69 | 70 | # Check for modified ("dirty") state 71 | execute_process( 72 | COMMAND ${GIT_EXECUTABLE} diff --shortstat 73 | WORKING_DIRECTORY ${PROJECT_SOURCE_DIR} 74 | RESULT_VARIABLE git_stat_exit_status 75 | OUTPUT_VARIABLE GIT_STATUS 76 | OUTPUT_STRIP_TRAILING_WHITESPACE 77 | ) 78 | 79 | if (${GIT_STATUS} MATCHES "changed") 80 | set(GIT_STATUS ".dirty") 81 | endif() 82 | 83 | if(NOT ${GIT_BUILD} MATCHES "^0$") 84 | set(CSEVRSN_META "+${GIT_BRANCH}.${GIT_SHA}.${GIT_BUILD}${GIT_STATUS}") 85 | else() 86 | set(CSEVRSN_META "") 87 | endif() 88 | #TODO: Add OS, compiler, and target architecture Ex. ${TARGET_OS}-${CMAKE_CXX_COMPILER_ID}-${CSE_BUILD_ARCHITECTURE} 89 | message("Building CSE ${CSEVRSN_MAJOR}.${CSEVRSN_MINOR}.${CSEVRSN_PATCH}${CSEVRSN_PRERELEASE}${CSEVRSN_META}") 90 | 91 | configure_file( 92 | "${PROJECT_SOURCE_DIR}/src/csevrsn.in.h" 93 | "${PROJECT_BINARY_DIR}/src/csevrsn.h" 94 | ) 95 | -------------------------------------------------------------------------------- /.github/workflows/build-and-test.yml: -------------------------------------------------------------------------------- 1 | name: Build and Test 2 | 3 | on: push 4 | 5 | jobs: 6 | build-cse: 7 | strategy: 8 | fail-fast: false 9 | matrix: 10 | include: 11 | - os: windows 12 | os_ver: "2022" 13 | config: Release 14 | arch: "32" 15 | compiler: msvc 16 | experimental: false 17 | - os: windows 18 | os_ver: "2022" 19 | config: Release 20 | arch: "64" 21 | compiler: msvc 22 | experimental: false 23 | # - os: windows 24 | # os_ver: "2022" 25 | # config: Release 26 | # arch: "64" 27 | # compiler: clang 28 | # experimental: true 29 | - os: macos 30 | os_ver: "13" 31 | config: Release 32 | arch: "64" 33 | compiler: clang 34 | experimental: true 35 | # - os: ubuntu 36 | # os_ver: "22.04" 37 | # config: Release 38 | # arch: "64" 39 | # compiler: gcc 40 | # experimental: true 41 | defaults: 42 | run: 43 | shell: bash 44 | name: ${{ matrix.os }}-${{ matrix.os_ver }}-${{ matrix.compiler }}-${{ matrix.arch }}bit ${{ matrix.config }} 45 | runs-on: ${{ matrix.os }}-${{ matrix.os_ver }} 46 | continue-on-error: ${{ matrix.experimental }} 47 | steps: 48 | - name: Checkout 49 | uses: actions/checkout@v4 50 | with: 51 | fetch-depth: 0 52 | submodules: recursive 53 | - name: Get number of CPU cores # Can replace when CMake is upgraded to 3.29 54 | uses: SimenB/github-actions-cpu-cores@v2 55 | id: cpu-cores 56 | # - name: Setup Mesa3D 57 | # uses: bigladder/github-actions/setup-mesa3d@main 58 | # with: 59 | # install-directory: msvc 60 | - name: Install uv and set the python version 61 | uses: astral-sh/setup-uv@v5 62 | with: 63 | python-version: "3.13" 64 | - name: Build CSE 65 | run: cmake -DBUILD_ARCHITECTURE=${{ matrix.arch }} -DCOMPILER_ID=${{ matrix.compiler }} -DCONFIGURATION=${{ matrix.config }} -DBUILD_DIRECTORY=build -DBUILD_DOCS_WITH_ALL=ON -P cmake/configure-and-build.cmake 66 | - name: Upload executable artifact 67 | uses: actions/upload-artifact@v4 68 | with: 69 | name: CSE-${{ matrix.os }}-${{ matrix.os_ver }}-${{ matrix.arch }}bit-${{ matrix.config }} 70 | path: | 71 | build/CSE* 72 | build/cse* 73 | - name: Test 74 | id: test 75 | run: ctest -C ${{ matrix.config }} -j ${{ steps.cpu-cores.outputs.count }} --output-on-failure -E shadetest # CI can't do GPU calcs at this time (the steps above get us close, but throws an exception on destruction) 76 | working-directory: build 77 | continue-on-error: true 78 | - name: Upload report files artifact 79 | if: steps.test.outcome == 'failure' 80 | uses: actions/upload-artifact@v4 81 | with: 82 | name: Reports-${{ matrix.os }}-${{ matrix.os_ver }}-${{ matrix.arch }}bit_${{ matrix.config }} 83 | path: | 84 | test/*.rep 85 | test/*.REP 86 | - name: Upload documentation 87 | uses: actions/upload-artifact@v4 88 | with: 89 | name: Documentation-${{ matrix.os }}-${{ matrix.os_ver }}-${{ matrix.arch }} 90 | path: | 91 | doc/build 92 | - name: Check test failure 93 | if: steps.test.outcome == 'failure' 94 | run: exit 1 95 | -------------------------------------------------------------------------------- /test/shadeTest.cse: -------------------------------------------------------------------------------- 1 | 2 | #if 0 3 | #redefine INFILM (1.461-.903) //interior film, e = 0.9, convective only 4 | //see appendix D 5 | #define WinINFILM (1.461) //window interior film 6 | #redefine WALEXF 5.158 //wall exterior film, emissivity = 0.9 7 | #redefine WINEXF 3.697 //window exterior film, emissivity = 0.9 8 | #define INABSORP 0.9 9 | #define ABSORP 0.5 10 | #define SURFMODEL forward_difference 11 | #define WINH 4 12 | #define WINW 3 13 | #define OHDPTH 2 14 | #define COOLTEMP 75 15 | #define JAN4REP 0 //1 for hourly reports, 0 otherwise 16 | #define JAN4NAME "600jan4.csv" 17 | #define MAR5REP 0 //1 for hourly reports, 0 otherwise 18 | #define MAR5NAME "mar5s.csv" 19 | #define JUL27REP 0 //1 for hourly reports, 0 otherwise 20 | #define JUL27NAME "600jul27s.csv" 21 | #endif 22 | 23 | #if 0 24 | dbgPrintMaskC = 8 25 | dbgPrintMask = $dayofyear == 191 ? 64 : 0 26 | #endif 27 | 28 | repHdrL="1Z Test" 29 | repHdrR="" 30 | repTestPfx = "! " 31 | WfName= "Boulder.epw" 32 | // WfName= "CTZ12S13B.CSW" 33 | // tdvfName = "test2x.tdv" 34 | BEGDay=Jan 1 // 35 | ENDDay=Dec 31 // 36 | ebTolHour=.001 ebTolDay=.001 ebTolMon=.001 37 | Jan1DOW=Tue 38 | wuDays=30 // 39 | nSubSteps=10 // 40 | skyModel=anisotropic // 41 | windf = .25 42 | 43 | bldgAzm=0 44 | elevation=0 45 | DT=Yes 46 | 47 | DELETE HOLIDAY "New Year's Day" 48 | DELETE HOLIDAY "M L King Day" 49 | DELETE HOLIDAY "President's Day" 50 | DELETE HOLIDAY "Memorial Day" 51 | DELETE HOLIDAY "Fourth of July" 52 | DELETE HOLIDAY "Labor Day" 53 | DELETE HOLIDAY "Columbus Day" 54 | DELETE HOLIDAY "Veterans Day" 55 | DELETE HOLIDAY "Thanksgiving" 56 | DELETE HOLIDAY "Christmas" 57 | 58 | METER MtrElec; 59 | 60 | PVARRAY "pvarray 1" 61 | pvDCSysSize = 2 // Rated array output, kW 62 | pvModuleType = "Standard" 63 | pvArrayType = "FixedOpenRack" 64 | pvMounting = Building 65 | pvVertices = 0, 0, 15, 20, 0, 15, 20, 7.07, 22.07, 0, 7.07, 22.07 66 | 67 | // pvTilt = 45 // Array tilt (0=H, 90=V), deg 68 | // pvAzm = 180 // Array azimuth (0=N, 90=E, ...), deg 69 | pvSIF = 2.0 70 | pvInverterEff = 0.96 // Inverter efficiency at full load, frac 71 | pvElecMtr = "MtrElec" // Electric meter to report results to 72 | 73 | SHADEX Tree 74 | sxMounting = Site 75 | sxVertices = 0,-100,0, 20,-100,0, 20,-100,150, 0,-100, 150 76 | 77 | DELETE Report EB 78 | 79 | REPORT rpType=MTR rpMeter=MtrElec rpFreq=month 80 | 81 | REPORT rpType=UDT rpFreq=hour rpDayBeg = Jan 1 rpDayEnd = Dec 31 rpCPL=88 82 | reportcol colVal=$Month colWid = 3 colHead="Mon" 83 | reportcol colVal=$dayofmonth colWid = 3 colHead="Day" 84 | reportcol colVal=$Hour colWid = 2 colHead="Hr" 85 | reportcol colVal=@Top.iHrST colWid = 4 colHead="HrSt" 86 | reportcol colVal=@Top.radBeamHrAv colHead="radBeam" 87 | reportcol colVal=@Top.radDiffHrAv colHead="radDiff" 88 | reportcol colVal=@PVARRAY[ 1].fBeam colHead="FBeam" 89 | reportcol colVal=@PVARRAY[ 1].poa colHead="POASlr" 90 | reportcol colVal=@PVARRAY[ 1].radI colHead="IncSlr" 91 | reportcol colVal=@PVARRAY[ 1].radIEff colHead="EffIncSlr" 92 | endReport 93 | 94 | 95 | RUN 96 | 97 | UNSET bldgAzm 98 | bldgAzm = 30 99 | 100 | RUN 101 | 102 | $EOF 103 | -------------------------------------------------------------------------------- /doc/src/docs/input-data/exportcol.md: -------------------------------------------------------------------------------- 1 | # EXPORTCOL 2 | 3 | Each EXPORTCOL defines a single datum of a User Defined Table (UDT) export; EXPORTCOLs are not used with other export types. 4 | 5 | Use as many EXPORTCOLs as there are values to be shown in each row of the user-defined export. The values will appear in the order defined in each data row output. Be sure to include values needed to identify the data, such as the month, day, and hour, as appropriate -- these are NOT automatically supplied in user-defined exports. 6 | 7 | EXPORTCOL members are similar to the corresponding REPORTCOL members. See Section 5.265.1.5 for further discussion. 8 | 9 | ### colName 10 | 11 | Name of EXPORTCOL. 12 | 13 | {{ 14 | member_table({ 15 | "units": "", 16 | "legal_range": "*63 characters*", 17 | "default": "*none*", 18 | "required": "No", 19 | "variability": "constant" 20 | }) 21 | }} 22 | 23 | ### colExport 24 | 25 | Type: exName 26 | 27 | Name of export to which this column belongs. If the EXPORTCOL is given within an EXPORT object, then *colExport* defaults to that export. 28 | 29 | {{ 30 | member_table({ 31 | "units": "", 32 | "legal_range": "name of an *EXPORT*", 33 | "default": "*current export, if any*", 34 | "required": "Unless in an *EXPORT*", 35 | "variability": "constant" 36 | }) 37 | }} 38 | 39 | ### colVal 40 | 41 | Type: expression 42 | 43 | Value to show in this position in each row of export. 44 | 45 | {{ 46 | member_table({ 47 | "units": "", 48 | "legal_range": "*any numeric or string expression*", 49 | "default": "*none*", 50 | "required": "Yes", 51 | "variability": "subhour /end interval" 52 | }) 53 | }} 54 | 55 | ### colHead 56 | 57 | Type: string 58 | 59 | Text used for field name in export header. 60 | 61 | Note: Due to quirk (or bug?) in CSE parsing, setting *colHead* equal to "sum", "all", or "all_but" (case-insensitive) will trigger an error message along the lines of "'SUM' cannot be used here." Adding a space avoids this issue. For example, colHead = " Sum" is accepted. 62 | 63 | {{ 64 | member_table({ 65 | "units": "", 66 | "legal_range": "", 67 | "default": "*colName* or blank", 68 | "required": "No", 69 | "variability": "constant" 70 | }) 71 | }} 72 | 73 | ### colWid 74 | 75 | Type: int 76 | 77 | Maximum width. Leading and trailing spaces and non-significant zeroes are removed from export data to save file space. Specifying a *colWid* less than the default may reduce the maximum number of significant digits output. 78 | 79 | {{ 80 | member_table({ 81 | "units": "", 82 | "legal_range": "x ≥ 0", 83 | "default": "13", 84 | "required": "No", 85 | "variability": "constant" 86 | }) 87 | }} 88 | 89 | ### colDec 90 | 91 | Type: int 92 | 93 | Number of digits after decimal point. 94 | 95 | {{ 96 | member_table({ 97 | "units": "", 98 | "legal_range": "x ≥ 0", 99 | "default": "*flexible format*", 100 | "required": "No", 101 | "variability": "constant" 102 | }) 103 | }} 104 | 105 | ### colJust 106 | 107 | Type: choice 108 | 109 | Specifies positioning of data within column: 110 | 111 | {{ 112 | csv_table("Left, Left justified 113 | Right, Right justified") 114 | }} 115 | 116 | ### endExportCol 117 | 118 | Optionally indicates the end of the EXPORTCOL. Alternatively, the end of the definition can be indicated by END or by beginning another object. 119 | 120 | {{ 121 | member_table({ 122 | "units": "", 123 | "legal_range": "", 124 | "default": "*none*", 125 | "required": "No", 126 | "variability": "constant" 127 | }) 128 | }} 129 | 130 | **Related Probes:** 131 | 132 | - @[exportCol][p_exportcol] 133 | -------------------------------------------------------------------------------- /vendor/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | include(initialize-submodules) 2 | initialize_submodules() 3 | 4 | # Penumbra 5 | add_subdirectory(penumbra) 6 | 7 | set_target_properties(glfw PROPERTIES FOLDER Dependencies/Penumbra/GLFW) 8 | set_target_properties(glad PROPERTIES FOLDER Dependencies/Penumbra) 9 | set_target_properties(penumbra PROPERTIES FOLDER Dependencies/Penumbra) 10 | set_target_properties(tess2 PROPERTIES FOLDER Dependencies/Penumbra) 11 | 12 | mark_as_advanced( 13 | BUILD_PENUMBRA_TESTING 14 | PENUMBRA_COVERAGE 15 | PENUMBRA_STATIC_LIB 16 | # Should be marked in future Penumbra update 17 | GLFW_BUILD_DOCS 18 | GLFW_BUILD_EXAMPLES 19 | GLFW_BUILD_TESTS 20 | GLFW_DOCUMENT_INTERNALS 21 | GLFW_INSTALL 22 | GLFW_USE_HYBRID_HPG 23 | GLFW_VULKAN_STATIC 24 | LIB_SUFFIX 25 | USE_MSVC_RUNTIME_LIBRARY_DLL 26 | ) 27 | 28 | # Kiva 29 | set(KIVA_TESTING OFF CACHE BOOL "" FORCE) 30 | set(KIVA_EXE_BUILD OFF CACHE BOOL "" FORCE) 31 | set(KIVA_COVERAGE OFF CACHE BOOL "" FORCE) 32 | set(KIVA_3D OFF CACHE BOOL "" FORCE) 33 | set(BUILD_TESTING OFF CACHE BOOL "" FORCE) # Polution from eigen 34 | 35 | option( KIVA_GROUND_PLOT "Build ground plotting library" OFF ) 36 | 37 | add_subdirectory(kiva) 38 | 39 | set_target_properties(libkiva PROPERTIES FOLDER Dependencies/Kiva) 40 | set_target_properties(fmt PROPERTIES FOLDER Dependencies/Kiva) 41 | 42 | mark_as_advanced( 43 | KIVA_3D 44 | KIVA_EXE_BUILD 45 | KIVA_COVERAGE 46 | KIVA_GROUND_PLOT 47 | KIVA_STATIC_LIB 48 | KIVA_TESTING 49 | ENABLE_OPENMP 50 | ) 51 | 52 | # Should be marked in future Kiva update 53 | mark_as_advanced( 54 | FMT_TEST 55 | FMT_CUDA_TEST 56 | FMT_DEBUG_POSTFIX 57 | FMT_DOC 58 | FMT_FUZZ 59 | FMT_MODULE 60 | FMT_INSTALL 61 | FMT_OS 62 | FMT_PEDANTIC 63 | FMT_WERROR 64 | FMT_INC_DIR 65 | ) 66 | 67 | if (KIVA_GROUND_PLOT) 68 | set_target_properties(groundplot PROPERTIES FOLDER Dependencies/Kiva/GroundPlot) 69 | set_target_properties(mgl-static PROPERTIES FOLDER Dependencies/Kiva/GroundPlot/Dependencies) 70 | set_target_properties(png_static PROPERTIES FOLDER Dependencies/Kiva/GroundPlot/Dependencies) 71 | set_target_properties(genfiles PROPERTIES FOLDER Dependencies/Kiva/GroundPlot/Dependencies) 72 | endif() 73 | 74 | # HPWHsim 75 | set(HPWHSIM_OMIT_TESTTOOL ON CACHE BOOL "HPWHsim: Do not build testing code" FORCE) 76 | set(HPWHSIM_ABRIDGED ON CACHE BOOL "HPWHsim: omit code not used by CSE" FORCE) 77 | mark_as_advanced( 78 | HPWHSIM_OMIT_TESTTOOL 79 | HPWHSIM_ABRIDGED 80 | ) 81 | add_subdirectory(HPWHsim) 82 | 83 | set_target_properties(HPWHsim PROPERTIES FOLDER Dependencies/HPWHsim) 84 | if (NOT HPWHSIM_OMIT_TESTTOOL) 85 | set_target_properties(results_directory PROPERTIES FOLDER Dependencies/Test) 86 | endif() 87 | 88 | set_target_properties(btwxt PROPERTIES FOLDER Dependencies) 89 | mark_as_advanced( 90 | BTWXT_COVERAGE 91 | BTWXT_STATIC_LIB 92 | BUILD_BTWXT_TESTING 93 | GIT_SUBMODULE # Should go away with Btwxt update 94 | ) 95 | 96 | if (NOT TARGET gtest) 97 | # Prevent GoogleTest from overriding our compiler/linker options 98 | # when building with Visual Studio 99 | set(gtest_force_shared_crt ON CACHE BOOL "" FORCE) 100 | set(BUILD_GTEST ON CACHE BOOL "" FORCE MARK) 101 | set(BUILD_GMOCK ON CACHE BOOL "" FORCE) 102 | set(INSTALL_GTEST OFF CACHE BOOL "" FORCE) 103 | mark_as_advanced(BUILD_GTEST BUILD_GMOCK INSTALL_GTEST) 104 | add_subdirectory(googletest) 105 | set_target_properties(gtest PROPERTIES FOLDER Dependencies/Test) 106 | set_target_properties(gmock PROPERTIES FOLDER Dependencies/Test) 107 | set_target_properties(gtest_main PROPERTIES FOLDER Dependencies/Test) 108 | set_target_properties(gmock_main PROPERTIES FOLDER Dependencies/Test) 109 | endif () 110 | 111 | -------------------------------------------------------------------------------- /doc/src/docs/input-data/dhwloopseg.md: -------------------------------------------------------------------------------- 1 | # DHWLOOPSEG 2 | 3 | DHWLOOPSEG constructs one or more objects representing a segment of the preceeding DHWLOOP. A DHWLOOP can have any number of DHWLOOPSEGs to represent the segments of the loop with possibly differing sizes, insulation, or surrounding conditions. 4 | 5 | ### wgName 6 | 7 | Optional name of segment; give after the word “DHWLOOPSEG” if desired. 8 | 9 | {{ 10 | member_table({ 11 | "units": "", 12 | "legal_range": "*63 characters*", 13 | "default": "*none*", 14 | "required": "No", 15 | "variability": "constant" 16 | }) 17 | }} 18 | 19 | ### wgTy 20 | 21 | Type: choice 22 | 23 | Specifies the type of segment. RETURN segments, if any, must follow SUPPLY segments. 24 | 25 | {{ 26 | csv_table("SUPPLY, Indicates a supply segment (flow is sum of circulation and draw flow, child DHWLOOPBRANCHs permitted). 27 | RETURN, Indicates a return segment (flow is only due to circulation, child DHWLOOPBRANCHs not allowed)") 28 | }} 29 | 30 | {{ 31 | member_table({ 32 | "units": "", 33 | "legal_range": "", 34 | "default": "*none*", 35 | "required": "Yes", 36 | "variability": "constant" 37 | }) 38 | }} 39 | 40 | ### wgLength 41 | 42 | Type: float 43 | 44 | Length of segment. 45 | 46 | {{ 47 | member_table({ 48 | "units": "ft", 49 | "legal_range": "x ≥ 0", 50 | "default": "0", 51 | "required": "No", 52 | "variability": "constant" 53 | }) 54 | }} 55 | 56 | ### wgSize 57 | 58 | Type: float 59 | 60 | Nominal size of pipe. CSE assumes the pipe outside diameter = size + 0.125 in. 61 | 62 | {{ 63 | member_table({ 64 | "units": "in", 65 | "legal_range": "x > 0", 66 | "default": "1", 67 | "required": "Yes", 68 | "variability": "constant" 69 | }) 70 | }} 71 | 72 | ### wgInsulK 73 | 74 | Type: float 75 | 76 | Pipe insulation conductivity 77 | 78 | {{ 79 | member_table({ 80 | "units": "Btuh-ft/ft^2^-°F", 81 | "legal_range": "x > 0", 82 | "default": "0.02167", 83 | "required": "No", 84 | "variability": "constant" 85 | }) 86 | }} 87 | 88 | ### wgInsulThk 89 | 90 | Type: float 91 | 92 | Pipe insulation thickness 93 | 94 | {{ 95 | member_table({ 96 | "units": "in", 97 | "legal_range": "x ≥ 0", 98 | "default": "1", 99 | "required": "No", 100 | "variability": "constant" 101 | }) 102 | }} 103 | 104 | ### wgExH 105 | 106 | Type: float 107 | 108 | Combined radiant/convective exterior surface conductance between insulation (or pipe if no insulation) and surround. 109 | 110 | {{ 111 | member_table({ 112 | "units": "Btuh/ft^2^-°F", 113 | "legal_range": "x > 0", 114 | "default": "1.5", 115 | "required": "No", 116 | "variability": "hourly" 117 | }) 118 | }} 119 | 120 | ### wgExT 121 | 122 | Type: float 123 | 124 | Surrounding equivalent temperature. 125 | 126 | {{ 127 | member_table({ 128 | "units": "°F", 129 | "legal_range": "x > 0", 130 | "default": "70", 131 | "required": "No", 132 | "variability": "hourly" 133 | }) 134 | }} 135 | 136 | ### wgFNoDraw 137 | 138 | Type: float 139 | 140 | Fraction of hour when no draw occurs. 141 | 142 | {{ 143 | member_table({ 144 | "units": "°F", 145 | "legal_range": "x > 0", 146 | "default": "70", 147 | "required": "No", 148 | "variability": "hourly" 149 | }) 150 | }} 151 | 152 | ### endDHWLoopSeg 153 | 154 | Optionally indicates the end of the DHWLOOPSEG definition. 155 | 156 | {{ 157 | member_table({ 158 | "units": "", 159 | "legal_range": "", 160 | "default": "*none*", 161 | "required": "No", 162 | "variability": "" 163 | }) 164 | }} 165 | 166 | **Related Probes:** 167 | 168 | - @[DHWLoopSeg][p_dhwloopseg] 169 | -------------------------------------------------------------------------------- /doc/src/docs/input-data/accumulator.md: -------------------------------------------------------------------------------- 1 | # ACCUMULATOR 2 | 3 | An ACCUMULATOR is driven by arbitrary subhourly expression value computed during the CSE simulation and calculates minimum, maximum, mean, and sum values for hour, day, month, and year intervals. In addition, timestamps are retained for the minimum and maximum values. ACCUMULATORs are useful for summarizing and reporting values for which there is not built-in accounting (for example, ZNRES or RSYSRES). One common use case is for reporting hour average values of internal variables that vary subhourly. 4 | 5 | ACCUMULATORs are "observing" devices -- they have no effect on the CSE building model or calculations. ACCUMULATOR values must be reported using user-defined REPORTs or EXPORTs. 6 | 7 | As a simple example, a report of monthly outdoor drybulb temperatures can be generated as follows -- 8 | 9 | ACCUMULATOR "ACTDB" acmValue=$tdbosh 10 | 11 | REPORT "TODB" rpType=UDT rpFreq=Month rpTitle="Outdoor drybulb temp (F)" 12 | REPORTCOL colHead="Mon" colVal=$Month colWid=3 13 | REPORTCOL colHead="Min" colVal=@Accumulator[ "ACTDB"].M.acmMin colDec=2 colWid=6 14 | REPORTCOL colHead="Mean" colVal=@Accumulator[ "ACTDB"].M.acmMean colDec=2 colWid=6 15 | REPORTCOL colHead="Max" colVal=@Accumulator[ "ACTDB"].M.acmMax colDec=2 colWid=6 16 | REPORT rpType=UDT rpFreq=Year rpHeader=No 17 | REPORTCOL colVal="Yr" colWid=3 18 | REPORTCOL colVal=@Accumulator[ "ACTDB"].Y.acmMin colDec=2 colWid=6 19 | REPORTCOL colVal=@Accumulator[ "ACTDB"].Y.acmMean colDec=2 colWid=6 20 | REPORTCOL colVal=@Accumulator[ "ACTDB"].Y.acmMax colDec=2 colWid=6 21 | 22 | Resulting output -- 23 | 24 | Outdoor drybulb temp (F) 25 | 26 | Mon Min Mean Max 27 | --- ------ ------ ------ 28 | 1 28.22 46.87 60.08 29 | 2 32.00 49.26 69.98 30 | 3 42.08 60.79 91.40 31 | 4 34.70 58.13 79.16 32 | 5 44.42 67.07 97.88 33 | 6 50.36 73.43 107.96 34 | 7 55.04 74.02 101.48 35 | 8 53.60 74.99 104.18 36 | 9 48.92 69.24 97.52 37 | 10 47.84 64.00 98.42 38 | 11 32.54 54.47 77.00 39 | 12 28.04 46.58 64.04 40 | 41 | Yr 28.04 61.65 107.96 42 | 43 | Generalizing what is illustrated, probing @accumulator[ ].H yields statistics for the current hour, .D for the current day, .M the current month, and .Y for the year (or, more precisely, the full run, which may or may not be a full year). 44 | 45 | A complete list of the available statistics for each interval is found in the ACCUMULATOR probe documentation. 46 | 47 | Note: The initial version of ACCUMULATOR contains unresolved bugs related to the timing of the determination of acmValue. In some cases, acmValue is set to the expression value from the prior substep. This is being investigated. 48 | 49 | 50 | ### acmName 51 | 52 | Name of ACCUMULATOR: required for referencing in reports. 53 | 54 | {{ 55 | member_table({ 56 | "units": "", 57 | "legal_range": "*63 characters*", 58 | "default": "*none*", 59 | "required": "Yes", 60 | "variability": "constant" 61 | }) 62 | }} 63 | 64 | ### acmValue 65 | 66 | Type: *float* 67 | 68 | The value being accumulated. Generally expression with subhourly variability. 69 | 70 | {{ 71 | member_table({ 72 | "units": "any", 73 | "legal_range": "", 74 | "default": "", 75 | "required": "Yes", 76 | "variability": "subhourly" 77 | }) 78 | }} 79 | 80 | 81 | ### endACCUMULATOR 82 | 83 | Indicates the end of the ACCUMULATOR definition. Alternatively, the end of the definition can be indicated by the declaration of another object or by END. 84 | 85 | {{ 86 | member_table({ 87 | "units": "", 88 | "legal_range": "", 89 | "default": "*none*", 90 | "required": "No", 91 | "variability": "constant" 92 | }) 93 | }} 94 | 95 | **Related Probes:** 96 | 97 | - @[accumulator][p_accumulator] -------------------------------------------------------------------------------- /doc/src/docs/input-data/sgdist.md: -------------------------------------------------------------------------------- 1 | # SGDIST 2 | 3 | SGDIST creates a subobject of the current window that distributes a specified fraction of that window's solar gain to a specified delayed model (massive) surface. Any remaining solar gain (all of the window's solar gain if no SGDISTs are given) is added to the air of the zone containing the window. A window may have up to three SGDISTs; an error occurs if more than 100% of the window's gain is distributed. 4 | 5 | Via members sgFSO and sgFSC, the fraction of the insolation distributed to the surface can be made dependent on whether the zone's shades are open or closed (see ZONE member znSC). 6 | 7 | ### sgName 8 | 9 | Name of solar gain distribution (follows "SGDIST" if given). 10 | 11 | {{ 12 | member_table({ 13 | "units": "", 14 | "legal_range": "*63 characters*", 15 | "default": "*none*", 16 | "required": "No", 17 | "variability": "constant" 18 | }) 19 | }} 20 | 21 | ### sgSurf 22 | 23 | Type: sfName 24 | 25 | Name of surface to which gain is targeted. 26 | 27 | If there is more than surface with the specified name: if one of the surfaces is in the current zone, it is used; otherwise, an error message is issued. 28 | 29 | 32 | The specified surface must be modeled with the Delayed model. If gain is targeted to a Quick model surface, a warning message is issued and the gain is redirected to the air of the associated zone. 33 | 34 | {{ 35 | member_table({ 36 | "units": "", 37 | "legal_range": "name of a *SURFACE*", 38 | "default": "*none*", 39 | "required": "Yes", 40 | "variability": "constant" 41 | }) 42 | }} 43 | 44 | ### sgSide 45 | 46 | Type: choice 47 | 48 | Designates the side of the surface to which the gain is to be targeted: 49 | 50 | {{ 51 | csv_table("INTERIOR, Apply gain to interior of surface 52 | EXTERIOR, Apply gain to exterior of surface") 53 | }} 54 | 55 | {{ 56 | member_table({ 57 | "units": "", 58 | "legal_range": "INTERIOR, EXTERIOR", 59 | "default": "Side of surface in zone containing window; or INTERIOR if both sides are in zone containing window.", 60 | "required": "Yes", 61 | "variability": "constant" 62 | }) 63 | }} 64 | 65 | 68 | 69 | ### sgFSO 70 | 71 | Type: float 72 | 73 | Fraction of solar gain directed to specified surface when the owning window's interior shading is in the open position (when the window's zone's shade closure (znSC) is 0). 74 | 75 | {{ 76 | member_table({ 77 | "units": "", 78 | "legal_range": "0 ≤ *x* ≤ 1,and sum of window's sgFSO's ≤ 1", 79 | "default": "*none*", 80 | "required": "Yes", 81 | "variability": "monthly-hourly" 82 | }) 83 | }} 84 | 85 | ### sgFSC 86 | 87 | Type: float 88 | 89 | Fraction of solar gain directed to specified surface when the owning window's interior shading is in the closed position. If the zone's shades are partly closed (znSC between 0 and 1), a proportional fraction between sgFSO and sgFSC is used. 90 | 91 | {{ 92 | member_table({ 93 | "units": "", 94 | "legal_range": "0 ≤ *x* ≤ 1, and sum of window's sgFSC's ≤ 1", 95 | "default": "*sgFSO*", 96 | "required": "No", 97 | "variability": "monthly-hourly" 98 | }) 99 | }} 100 | 101 | ### endSGDist 102 | 103 | Optionally indicates the end of the solar gain distribution definition. Alternatively, the end of the solar gain distribution definition can be indicated by END or by just beginning another object. 104 | 105 | {{ 106 | member_table({ 107 | "units": "", 108 | "legal_range": "", 109 | "default": "*none*", 110 | "required": "No", 111 | "variability": "constant" 112 | }) 113 | }} 114 | 115 | **Related Probes:** 116 | 117 | - @[sgdist][p_sgdist] 118 | -------------------------------------------------------------------------------- /doc/src/docs/input-data/dhwtank.md: -------------------------------------------------------------------------------- 1 | # DHWTANK 2 | 3 | DHWTANK constructs an object representing one or more unfired water storage tanks in a DHWSYS. DHWTANK heat losses contribute to the water heating load. 4 | 5 | ### wtName 6 | 7 | Optional name of tank; give after the word “DHWTANK” if desired. 8 | 9 | {{ 10 | member_table({ 11 | "units": "", 12 | "legal_range": "*63 characters*", 13 | "default": "*none*", 14 | "required": "No", 15 | "variability": "constant" 16 | }) 17 | }} 18 | 19 | ### wtMult 20 | 21 | Type: integer 22 | 23 | Number of identical tanks of this type. Any value $>1$ is equivalent to repeated entry of the same DHWTANK. 24 | 25 | {{ 26 | member_table({ 27 | "units": "", 28 | "legal_range": "x > 0", 29 | "default": "1", 30 | "required": "No", 31 | "variability": "constant" 32 | }) 33 | }} 34 | 35 | Tank heat loss is calculated hourly (note that default heat loss is 0) -- 36 | 37 | $$ 38 | \text{qLoss} = \text{wtMult} \cdot (\text{wtUA} \cdot (\text{wtTTank} - \text{wtTEx}) + \text{wtXLoss}) 39 | $$ 40 | 41 | ### wtUA 42 | 43 | Type: float 44 | 45 | Tank heat loss coefficient. 46 | 47 | {{ 48 | member_table({ 49 | "units": "Btuh/°F", 50 | "legal_range": "x ≥ 0", 51 | "default": "Derived from wtVol and wtInsulR", 52 | "required": "No", 53 | "variability": "constant" 54 | }) 55 | }} 56 | 57 | ### wtVol 58 | 59 | Type: float 60 | 61 | Specifies tank volume. 62 | 63 | {{ 64 | member_table({ 65 | "units": "gal", 66 | "legal_range": "x ≥ 0", 67 | "default": "0", 68 | "required": "No", 69 | "variability": "constant" 70 | }) 71 | }} 72 | 73 | ### wtInsulR 74 | 75 | Type: float 76 | 77 | Specifies total tank insulation resistance. The input value should represent the total resistance from the water to the surroundings, including both built-in insulation and additional exterior wrap insulation. 78 | 79 | {{ 80 | member_table({ 81 | "units": "ft^2^-°F/Btuh", 82 | "legal_range": "x ≥ 0.01", 83 | "default": "0", 84 | "required": "No", 85 | "variability": "constant" 86 | }) 87 | }} 88 | 89 | ### wtZone 90 | 91 | Type: znName 92 | 93 | Zone location of DHWTANK regarding tank loss. The value of zero only valid if wtTEx is being used. Half of the heat losses go to zone air and the other goes to half radiant. 94 | 95 | {{ 96 | member_table({ 97 | "units": "", 98 | "legal_range": "*Name of ZONE*", 99 | "default": "0", 100 | "required": "No", 101 | "variability": "constant" 102 | }) 103 | }} 104 | 105 | ### wtTEx 106 | 107 | Type: float 108 | 109 | Tank surround temperature. 110 | 111 | {{ 112 | member_table({ 113 | "units": "°F", 114 | "legal_range": "x ≥ 0", 115 | "default": "70", 116 | "required": "No", 117 | "variability": "hourly" 118 | }) 119 | }} 120 | 121 | ### wtTTank 122 | 123 | Type: float 124 | 125 | Tank average water temperature. 126 | 127 | {{ 128 | member_table({ 129 | "units": "°F", 130 | "legal_range": "> 32 °F", 131 | "default": "Parent DHWSYSTEM wsTUse", 132 | "required": "No", 133 | "variability": "hourly" 134 | }) 135 | }} 136 | 137 | ### wtXLoss 138 | 139 | Type: float 140 | 141 | Additional tank heat loss. To duplicate CEC 2016 procedures, this value should be used to specify the fitting loss of 61.4 Btuh. 142 | 143 | {{ 144 | member_table({ 145 | "units": "Btuh", 146 | "legal_range": "(any)", 147 | "default": "0", 148 | "required": "No", 149 | "variability": "hourly" 150 | }) 151 | }} 152 | 153 | ### endDHWTank 154 | 155 | Optionally indicates the end of the DHWTANK definition. 156 | 157 | {{ 158 | member_table({ 159 | "units": "", 160 | "legal_range": "", 161 | "default": "*none*", 162 | "required": "No", 163 | "variability": "constant" 164 | }) 165 | }} 166 | 167 | **Related Probes:** 168 | 169 | - @[DHWTank][p_dhwtank] 170 | -------------------------------------------------------------------------------- /test/unit/cvpak.unit.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | #include "gtest/gtest.h" 4 | 5 | #include "cnglob.h" 6 | #include "cvpak.h" 7 | 8 | TEST(cvpak, output_convert) 9 | { 10 | 11 | // float tests -- special cases (NANDLES) 12 | NANDAT unset{ UNSET }; 13 | const char* str = cvin2s(&unset, DTFLOAT, UNNONE, 10, 0, 0); 14 | EXPECT_STREQ(str, ""); 15 | 16 | NANDAT expr13{ NANDLE(13) }; 17 | str = cvin2s(&expr13, DTFLOAT, UNNONE, 10, 0, 0); 18 | EXPECT_STREQ(str, ""); 19 | 20 | auto x{ NCHOICE(3 | NCNAN) }; 21 | NANDAT chn3{ AsNANDAT(x) }; 22 | // NANDAT chn3{ AsNANDAT(NCHOICE(3 | NCNAN) }; 23 | str = cvin2s(&chn3, DTFLOAT, UNNONE, 6, 0, 0); 24 | EXPECT_STREQ(str, "? "); 25 | 26 | // float tests -- numeric values 27 | struct FVTOS 28 | { 29 | float fV; 30 | SI units; 31 | int mfw; 32 | int fmt; 33 | int xfw; 34 | const char* exp; 35 | }; 36 | 37 | float nanf = std::numeric_limits::infinity()/std::numeric_limits::infinity(); 38 | 39 | FVTOS fvt[] = 40 | { { 5.f, UNNONE, 10, FMTLJ, 0, "5 " }, 41 | #if 0 42 | // units don't work due to imcomplete test environment 43 | { 22.3f, UNENERGYDEN, 10, FMTLJ+2, 0, "22.30 Btu/ft2" }, 44 | #endif 45 | { 5.f, UNNONE, 10, FMTRJ, 0, " 5" }, 46 | { 5000000.f, UNNONE, 6, FMTLJ, 0, "5000 k" }, 47 | { -11.3700f, UNNONE, 10, (FMTSQ | FMTRTZ) + 4, 0, "-11.37" }, 48 | { nanf, UNNONE, 10, (FMTSQ | FMTRTZ) + 4, 0, "nan" }, 49 | { nanf, UNLENGTH, 10, (FMTSQ | FMTRTZ) + 4, 0, "nan" }, 50 | { 1.5f, UNLENGTH, 10, (FMTSQ | FMTRTZ) + 6, 0, "1'6\"" }, 51 | { 1.55f, UNLENGTH, 10, (FMTSQ | FMTRTZ) + 6, 0, "1'6.6\"" }, 52 | { 1.0f, UNLENGTH, 10, (FMTSQ | FMTRTZ) + 6, 0, "1'0\"" }, 53 | { 1.5f, UNLENGTH, 10, (FMTRTZ) + 6, 0, "1' 6\" " }, 54 | }; 55 | 56 | for (FVTOS& fv : fvt) 57 | { 58 | const char* str = cvin2s(&fv.fV, DTFLOAT, fv.units, fv.mfw, fv.fmt, fv.xfw); 59 | EXPECT_STREQ(str, fv.exp); 60 | } 61 | 62 | // double tests -- numeric values 63 | struct DVTOS 64 | { 65 | double dV; 66 | SI units; 67 | int mfw; 68 | int fmt; 69 | int xfw; 70 | const char* exp; 71 | }; 72 | 73 | double nand = std::numeric_limits::infinity()/std::numeric_limits::infinity(); 74 | 75 | DVTOS dvt[] = 76 | { 77 | { nand, UNENERGY1, 10, FMTSQ+FMTUNITS+4, 0, "nan kBtu" } 78 | }; 79 | 80 | for (DVTOS& dv : dvt) 81 | { 82 | const char* str = cvin2s(&dv.dV, DTDBL, dv.units, dv.mfw, dv.fmt, dv.xfw); 83 | EXPECT_STREQ(str, dv.exp); 84 | } 85 | 86 | #if 0 87 | 88 | const void* data, // Pointer to data in internal form, or NULL to do nothing and return NULL 89 | // (for DTCHP, is ptr to ptr to string to print, 11-91) */ 90 | USI dt, // Data type of internal data, or DTNA for "--" or DTUNDEF for "?" from cvfddisp() 91 | SI units, // Units of internal data (made signed 5-89) 92 | USI _mfw, // Maximum field width (not including '\0'). If requested format results in string longer 93 | // than mfw, format will be altered if possible to give max significance within mfw; 94 | // when not possible (never possible for inteters or if field too narrow for e or k format), 95 | // field of **** is returned (but see _xfw). 96 | USI _fmt, // Format. See cvpak.h for definition of fields. 97 | USI _xfw /*=0*/) /* 0 or extra field width available: if value cannot be formatted in _mfw columns does fit 98 | in _mfw + _xfw or fewer cols, return the overlong text rather than ******. added by rob, 4-92. */ 99 | 100 | // Returns pointer to result in Tmpstr. 101 | // Also sets global Cvnchars to the number of characters placed in str (not incl. '\0'). 102 | #endif 103 | 104 | } 105 | -------------------------------------------------------------------------------- /src/nummeth.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) 1997-2019 The CSE Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style license 3 | // that can be found in the LICENSE file. 4 | 5 | // nummeth.h -- declarations for numerical methods functions 6 | 7 | #if !defined( _NUMMETH_H) 8 | #define _NUMMETH_H 9 | 10 | #include 11 | #include 12 | 13 | /*------------------------- FUNCTION DECLARATIONS -------------------------*/ 14 | int gaussjb( double* a, int n, double* b, int m, int invflg=0); 15 | 16 | int secant( double (*pFunc)( void *pO, double &x), void *pO, double f, 17 | double eps, double &x1, double &f1, double x2, double f2=DBL_MIN, 18 | double epsLo=-1.); 19 | 20 | int regula(double (*pFunc)(void* pO, double& x), void* pO, double f, 21 | double eps, double& x1, double xMin, double xMax); 22 | 23 | /////////////////////////////////////////////////////////////////////////////// 24 | // class DGRAPH: directed graph 25 | /////////////////////////////////////////////////////////////////////////////// 26 | class DGRAPH 27 | { 28 | public: 29 | DGRAPH(int nV, int base = 0) : dg_nV{ nV }, 30 | dg_edges(nV), dg_edgesRev(nV) { } 31 | void dg_AddEdge(int ivFrom, int ivTo) 32 | { dg_edges[ivFrom].push_back(ivTo); 33 | dg_edgesRev[ivTo].push_back(ivFrom); 34 | } 35 | template< typename T> 36 | void dg_AddEdges(T ivFrom, const T* ivTo, int count) 37 | { 38 | for (int i = 0; i& vSorted); 42 | bool dg_CountRefs(int ivRoot, std::vector< int>& vRefCounts); 43 | int dg_ChildCount(int iV) const 44 | { return int(dg_edges[iV].size()); } 45 | int dg_ParentCount(int iV) const 46 | { return int(dg_edgesRev[iV].size()); } 47 | 48 | private: 49 | int dg_nV; // # of verticies 50 | std::vector< std::vector> dg_edges; // edges 51 | std::vector< std::vector> dg_edgesRev; // reverse edges 52 | std::vector< unsigned char> dg_status; // 0: not seen; 1: processing; 2: seen 53 | bool dg_TopologicalSortDFS(int iV, std::vector& vSorted); 54 | bool dg_CountRefsDFS(int iV, std::vector& vRefCounts); 55 | }; // class DGRAPH 56 | 57 | #if 0 58 | x // prior functions (source lost as of 1-9-2013) 59 | x // svdfitb.c 60 | x float FC svdfitb( float **data, SI nRow, SI colMap[], float *a); 61 | x // lsfit.c 62 | x // (all functions currently #ifd out -- need work. 9-3-90). 63 | x // svdecomp.c 64 | x SI FC svdcmp( float **a, SI m, SI n, float *w, float **v); 65 | x void FC svbksb( float **u, float *w, float **v, SI m, SI n, float *b, float *x); 66 | x // spline.c 67 | x void FC spline( float x[], float y[], SI n, float yp1, float ypn, float u[], float y2[]); 68 | x SI FC splint( float x[], float y[], float y2[], SI n, float X, float *pY); 69 | x // nmroot.c 70 | x SI FC nmRootBrent( double (*)(double), double, double, double, double * ); 71 | x // nrutilb.c 72 | x void FC nrerror( char *error_text); 73 | x float * FC vector( SI nl, SI nh); 74 | x void FC free_vector( float *v, SI nl, SI nh); 75 | x SI * FC ivector( SI nl, SI nh); 76 | x void FC free_ivector( SI *v, SI nl, SI nh); 77 | x double * FC dvector( SI nl, SI nh); 78 | x void FC free_dvector( double *v, SI nl, SI nh); 79 | x float ** FC matrix( SI nrl, SI nrh, SI ncl, SI nch); 80 | x void FC free_matrix( float **m, SI nrl, SI nrh, SI ncl, SI nch); 81 | x SI ** FC imatrix( SI nrl, SI nrh, SI ncl, SI nch); 82 | x void FC free_imatrix( SI **m, SI nrl, SI nrh, SI ncl, SI nch); 83 | x double ** FC dmatrix( SI nrl, SI nrh, SI ncl, SI nch); 84 | x void FC free_dmatrix( double **m, SI nrl, SI nrh, SI ncl, SI nch); 85 | x float ** FC submatrix( float **a, SI oldrl, SI oldrh, SI oldcl, SI oldch, SI newrl, SI newcl); 86 | x void FC free_submatrix( float **b, SI nrl, SI nrh, SI ncl, SI nch); 87 | x float ** FC convert_matrix( float *a, SI nrl, SI nrh, SI ncl, SI nch); 88 | x void FC free_convert_matrix( float **b, SI nrl, SI nrh, SI ncl, SI nch); 89 | #endif 90 | 91 | #endif // _NUMMETH_H 92 | 93 | // nummeth.h end 94 | -------------------------------------------------------------------------------- /src/cuevf.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) 1997-2019 The CSE Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style license 3 | // that can be found in the LICENSE file. 4 | 5 | // cuevf.h evaluation frequency and variability definitions 6 | 7 | // for cuparse/cul world, runtime, rcdef. 8 | 9 | // evaluation frequency (variation) bits for operand or expression 10 | // how often program may change value 11 | // constants defined as int, must fit in USI 12 | const int EVFMAX = 1024; // largest evf bit value. 128-->256 6-95; 256->1024 8-17 13 | const int EVFSUBHR = 1024; // every sub-time-step 14 | const int EVFHR = 512; // hourly 15 | const int EVFMH = 256; // monthly-hourly -- but not daily: 16 | // for solar etc stuff appl computes for each hour on 1st day of month & uses for whole month. 17 | // cuparse.cpp:cleanEvf() cond'ly changes MON|HR to MH. 18 | const int EVFDAY = 128; // daily 19 | const int EVFMON = 64; // monthly 20 | const int EVFRUN = 32; // at start of autosize and run, after check/setup, or at end if EVENDIVL bit also on. 21 | 22 | // interval stages: beg, end, post 23 | const int EVPSTIVL = 8; // set for values available after post-processing calcs for their intervals 24 | // (eg load management) 25 | const int EVENDIVL = 4; // set for values available at END of their calcs for intervals (results rather than inputs) 26 | const int EVBEGIVL = 0; // implicit for values available at beg of interval (inputs) 27 | const int EVXBEGIVL = EVENDIVL | EVPSTIVL; // all non-beg stages 28 | 29 | // EVEOI, EVFFAZ are evaluted to input rats b4 check/setup (ie b4 topCkf); others at runtime to run rats. 30 | const int EVFFAZ = 2; // evaluate before check/setup of autosize and of main simulation (run) phases 6-95 31 | const int EVEOI = 1; // evaluate before initial check/setup (end-of-input). 32 | // for constant use zero. 33 | const int EVFDUMMY = 0x4000; // cuparse.c internal: expr contains dummy arg ref 34 | // --> don't eval or konstize in absence of call. 35 | 36 | //--- variabilities for CULT.evf table member (cul.h/c): acceptable evaluation frequencies for input exprs. USI or unsigned:12. 37 | 38 | #if 0 // historical; believe (no case at hand) MH value used in hrly context would yield wrong value when not 1st day of month 39 | x #define VSUBHRLY (EVEOI|EVFFAZ|EVFRUN|EVFMON|EVFMH|EVFDAY|EVFHR|EVFSUBHR) // subhourly or less 40 | x #define VHRLY (EVEOI|EVFFAZ|EVFRUN|EVFMON|EVFMH|EVFDAY|EVFHR) // hourly or less 41 | #else // 9-16-95: remove MH from HR, SUB. 42 | const int VSUBHRLY = EVEOI|EVFFAZ|EVFRUN|EVFMON|EVFDAY|EVFHR|EVFSUBHR; // subhourly or less 43 | const int VHRLY = EVEOI|EVFFAZ|EVFRUN|EVFMON|EVFDAY|EVFHR; // hourly or less 44 | #endif 45 | 46 | #if 0 // historical; believe hourly value works but wastes time when not 1st day of month 47 | x #define VMHLY (EVEOI|EVFFAZ|EVFRUN|EVFMON|EVFMH|EVFHR) /* "monthly-hourly": depends on mon & hr, not on day: for inputs 48 | x to appl's solar data: computed for 24 hrs once at month start.*/ 49 | #else // 9-16-95: remove HR; changed cleanEvf. 50 | const int VMHLY = EVEOI|EVFFAZ|EVFRUN|EVFMON|EVFMH; 51 | // "monthly-hourly": depends on mon & hr, not on day: for inputs 52 | // to appl's solar data: computed for 24 hrs once at month start. 53 | // Note cuparse.cpp:cleanEvf cnd'ly rets EVFMH for EVFHR, 9-95. 54 | #endif 55 | 56 | const int VDAILY = EVEOI|EVFFAZ|EVFRUN|EVFMON|EVFDAY; // daily or less 57 | const int VMONLY = EVEOI|EVFFAZ|EVFRUN|EVFMON; // monthly or less 58 | //const int VINITLY = EVEOI|EVFFAZ|EVFRUN; // add if need found: at start of run or less (less = end of input or constant) 59 | //const int VENDLY = EVEOI|EVFFAZ|EVFRUN|EVENDIVL; // add if need found: at end of run only 60 | const int VFAZLY = EVEOI|EVFFAZ; // at start of autosizing and start of main simulation or less 6-95 61 | const int VEOI = EVEOI; // eval can only be deferred til end of input 62 | // if constant required, use 0 63 | 64 | // end of cuevf.h 65 | -------------------------------------------------------------------------------- /doc/src/docs/input-data/dhwsolarsys.md: -------------------------------------------------------------------------------- 1 | # DHWSOLARSYS 2 | 3 | Solar water heating system. 4 | 5 | - DHWSOLARSYS 6 | - DHWSOLARCOLLECTOR 7 | - DHWSOLARTANK 8 | 9 | May have any number of solar collectors, but only one tank. 10 | 11 | May have no tank for direct system? What if system has multiple primary tanks? 12 | 13 | ### swElecMtr 14 | 15 | Type: mtrName 16 | 17 | Name of METER object, if any, to which DHWSOLARSYS electrical energy use is recorded (under end use ???). 18 | 19 | {{ 20 | member_table({ 21 | "units": "°F", 22 | "legal_range": "*name of a METER*", 23 | "default": "*not recorded*", 24 | "required": "No", 25 | "variability": "constant" 26 | }) 27 | }} 28 | 29 | ### swSCFluidSpHt 30 | 31 | Type: float 32 | 33 | Specific heat for the collector fluid. 34 | 35 | {{ 36 | member_table({ 37 | "units": "Btu/lbm-°F", 38 | "legal_range": "x > 0", 39 | "default": "0.9", 40 | "required": "No", 41 | "variability": "constant" 42 | }) 43 | }} 44 | 45 | ### swSCFluidDens 46 | 47 | Type: float 48 | 49 | Density for the collector fluid. 50 | 51 | {{ 52 | member_table({ 53 | "units": "lb/ft^3^", 54 | "legal_range": "x > 0", 55 | "default": "64.0", 56 | "required": "No", 57 | "variability": "constant" 58 | }) 59 | }} 60 | 61 | ### swEndUse 62 | 63 | End use of pump energy; defaults to "DHW". 64 | 65 | ### swParElec 66 | 67 | Type: float 68 | 69 | {{ 70 | member_table({ 71 | "units": "", 72 | "legal_range": "x ≥ 0", 73 | "default": "0", 74 | "required": "No", 75 | "variability": "hourly" 76 | }) 77 | }} 78 | 79 | ### swTankHXEff 80 | 81 | Type: float 82 | 83 | Tank heat exchanger effectiveness. 84 | 85 | {{ 86 | member_table({ 87 | "units": "", 88 | "legal_range": "0 ≤ x ≤ 0.99", 89 | "default": "0", 90 | "required": "No", 91 | "variability": "hourly" 92 | }) 93 | }} 94 | 95 | ### swTankTHxLimit 96 | 97 | Type: float 98 | 99 | Temperature limit for the tank collector. 100 | 101 | {{ 102 | member_table({ 103 | "units": "°F", 104 | "legal_range": "x ≥ 0", 105 | "default": "180.0", 106 | "required": "No", 107 | "variability": "constant" 108 | }) 109 | }} 110 | 111 | ### swTankUA 112 | 113 | Type: float 114 | 115 | Heat transfer coefficient for the tank multiplied by area. 116 | 117 | {{ 118 | member_table({ 119 | "units": "Btuh/°F", 120 | "legal_range": "", 121 | "default": "", 122 | "required": "No", 123 | "variability": "constant" 124 | }) 125 | }} 126 | 127 | ### swTankVol 128 | 129 | Type: float 130 | 131 | {{ 132 | member_table({ 133 | "units": "gal", 134 | "legal_range": "", 135 | "default": "", 136 | "required": "No", 137 | "variability": "constant" 138 | }) 139 | }} 140 | 141 | ### swTankInsulR 142 | 143 | Type: float 144 | 145 | Total tank insulation resistance, built-in plus exterior wrap. 146 | 147 | {{ 148 | member_table({ 149 | "units": "ft^2^-°F/Btuh", 150 | "legal_range": "", 151 | "default": "", 152 | "required": "No", 153 | "variability": "constant" 154 | }) 155 | }} 156 | 157 | ### swTankZone 158 | 159 | Type: znName 160 | 161 | Pointer to tank zone location, use sw_tankTEx if NULL 162 | 163 | {{ 164 | member_table({ 165 | "units": "", 166 | "legal_range": "*Name of ZONE*", 167 | "default": "", 168 | "required": "No", 169 | "variability": "constant" 170 | }) 171 | }} 172 | 173 | ### swTankTEx 174 | 175 | Type: float 176 | 177 | Surrounding temperature. 178 | 179 | {{ 180 | member_table({ 181 | "units": "°F", 182 | "legal_range": "", 183 | "default": "", 184 | "required": "No", 185 | "variability": "hourly" 186 | }) 187 | }} 188 | 189 | ### endDHWSOLARSYS 190 | 191 | Optionally indicates the end of the DHWSOLARSYS definition. 192 | 193 | {{ 194 | member_table({ 195 | "units": "", 196 | "legal_range": "", 197 | "default": "*none*", 198 | "required": "No", 199 | "variability": "" 200 | }) 201 | }} 202 | 203 | --------------------------------------------------------------------------------