Install Github Desktop, and git (all default).
brew install --cask github
- Register a GitHub account with your Lehigh email, then fork the develop branch. It will make a copy under your account.
- Sign in GitHub Desktop, clone your fork to the local computer. The fork should be under your username.
- After validating your proposed changes, go to Github Desktop to
commit
andpush
new code to your fork.
Remember to write detailed comments so other people can understand your proposed changes.
-
Go to GitHub website (there should be a shortcut in Github Desktop) and send a pull request.
-
DO NOT include any sensitive information such as plant name and address when contributing code.
-
After reviewing the code, The IAC Admin can approve and merge your proposed changes.
An automated template is usually made of 3 parts:
template.docx
with${tags}
to be replaced.database.json5
saving input numbers and strings.automate.py
performing calculation and formatting.
For electricity:
- Calculate current power draw CPD in [kW]
- Calculate proposed power draw PPD in [kW]
- Calculate electricity savings ES = CPD * Operating Hours [hr] - PPD * Opearting Hours [hr], in [kWh/yr]
- Calculate demand savings DS = (CPD - PPD) * Coincidence Factor [%/month] * n [month/year], in [kW/yr]
For natural gas: 5. Calculate natural gas savings NGS (or any other fuel) in MMBtu/yr
Overall: 6. Calculate annnal cost savings ACS = sum(energy savings * unit price), in $
- Use linear equations as much as possible.
- Make sure all physics units can be properly cancelled (also use that as a validation of your template).
- Make .json5 database by writing detailed comments, including description, unit, data type(int, float, str or list), and default value (if available). The key name could be abbreviation such as "ES", as long as it's consistent with the word document.
- Clean up word document formatting. In rare scenario, the document could be a legacy .doc file with .docx extension. You need to copy all the text and paste it into a new document.
- Replace numbers/strings with tags, example:
${XX}
. Make sure to adjust the formatting of the tag, as the format will be preserved.
- Read .json5 databases and convert it to
EasyDict
. Then you can easily access the variable byiac.XX
instead ofiac['XX']
. - Perform calculations. Remember to keep the data type consistent which means you'll use
round()
frequently. - Format strings. Everything needs to be formatted as strings before replacing. Thousand separator is required. Currency needs to be formatted with $ sign.
- Import the .docx template.
- Replace keys with
docx_replace()
. - Save file and print caveats if requires more manual operations.
Currently, python-docx-replace
doesn't support replacing keys in Word equations. If possible please use regular linear text instead of equations. If the equation is unavoidable, the workaround is to write the equation in LaTeX then convert it to Word equation and insert it to empty tags like ${XXEqn}
. Check the Reduce Set Pressure template for examples.
Make a numpy array with table values, then use np.interp
to get the result.
If there's any table that needs to be filled with calculated numbers, do the following:
If the table has fixed length, simply access the table and fill in texts.
If the table has variable length, make more reserved lines in the word template, then fill in texts and delete empty lines. See Repair Leaks template for examples.
The .docx can have pre-defined blocks with XML tags. E.g. starts with <XX>
and ends with </XX>
. Then you may choose to enable/disable the block with docx_blocks()