Skip to content

Commit 7decc8e

Browse files
author
[Mackenze Fahey]
committed
reupload recommit
0 parents  commit 7decc8e

File tree

4 files changed

+170
-0
lines changed

4 files changed

+170
-0
lines changed

.gitignore

Whitespace-only changes.

EnergyConversions.py

+106
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,106 @@
1+
compatible_units = ('eV', 'nm', 'wavenumber', 'hartree', 'kcal/mol', 'kJ/mol')
2+
3+
def convert2eV(energy, units):
4+
if units == 'eV':
5+
print(f'{energy} eV')
6+
if units == 'nm' :
7+
print(f'{((1/float(energy))*1240)} eV')
8+
if units == 'wavenumber':
9+
print(f'{float(energy)/8065.6} eV')
10+
if units == 'hartree':
11+
print(f'{float(energy)/3.6749E-2} eV')
12+
if units == 'kcal/mol':
13+
print(f'{float(energy)/23.061} eV')
14+
if units == 'kJ/mol':
15+
print(f'{float(energy)/96.485} eV')
16+
17+
def convert2nm(energy, units):
18+
if units == 'eV':
19+
print(f'{(1240/float(energy))} nm')
20+
if units == 'nm':
21+
print(f'{energy} nm')
22+
if units == 'wavenumber':
23+
print(f'{10000000/float(energy)} nm')
24+
if units == 'hartree':
25+
print(f'{1240/(float(energy)/3.6749E-2)} nm')
26+
if units == 'kcal/mol':
27+
print(f'{1240/(float(energy)/23.061)} nm')
28+
if units == 'kJ/mol':
29+
print(f'{1240/(float(energy)/96.485)} nm')
30+
31+
def convert2wavenumber(energy, units):
32+
if units == 'eV':
33+
print(f'{float(energy)*8065.6} wavenumber')
34+
if units == 'nm':
35+
print(f'{(1/float(energy)*10000000)} wavenumber')
36+
if units == 'wavenumber':
37+
print(f'{energy} wavenumber')
38+
if units == 'hartree':
39+
print(f'{float(energy)/4.5563E-6} wavenumber')
40+
if units == 'kcal/mol':
41+
print(f'{float(energy)/2.8591E-3} wavenumber')
42+
if units == 'kJ/mol':
43+
print(f'{float(energy)/1.1963E-2} wavenumber')
44+
45+
def convert2hartree(energy, units):
46+
if units == 'eV':
47+
print(f'{float(energy)/27.212} hartree')
48+
if units == 'nm':
49+
print(f'{((1/float(energy))*1240)/27.212} hartree')
50+
if units == 'wavenumber':
51+
print(f'{float(energy)/2.1947E5} hartree')
52+
if units == 'hartree':
53+
print(f'{float(energy)} hartree')
54+
if units == 'kcal/mol':
55+
print(f'{float(energy)/627.51} hartree')
56+
if units == 'kJ/mol':
57+
print(f'{float(energy)/2625.50} hartree')
58+
59+
def convert2kcal(energy,units):
60+
if units == 'eV':
61+
print(f'{float(energy)/4.3363E-2} kcal/mol')
62+
if units == 'nm':
63+
print(f'{((1/float(energy))*1240)/4.3363E-2} kcal/mol')
64+
if units == 'wavenumber':
65+
print(f'{float(energy)/349.75} kcal/mol')
66+
if units == 'hartree':
67+
print(f'{float(energy)/1.5936E-3} kcal/mol')
68+
if units == 'kcal/mol':
69+
print(f'{float(energy)} kcal/mol')
70+
if units == 'kJ/mol':
71+
print(f'{float(energy)/4.1840} kcal/mol')
72+
73+
def convert2joule(energy, units):
74+
if units == 'eV':
75+
print(f'{float(energy)/1.0364E-2} kJ/mol')
76+
if units == 'nm':
77+
print(f'{((1/float(energy))*1240)/1.0364E-2} kJ/mol')
78+
if units == 'wavenumber':
79+
print(f'{float(energy)/83.593} kJ/mol')
80+
if units == 'hartree':
81+
print(f'{float(energy)/3.8088E-4} kJ/mol')
82+
if units == 'kcal/mol':
83+
print(f'{float(energy)/0.23901} kJ/mol')
84+
if units == 'kJ/mol':
85+
print(f'{float(energy)} kJ/mol')
86+
87+
def main():
88+
print(f'Compatible units: {compatible_units}')
89+
units = input('Units of value you want to convert: ')
90+
#check that unit input is in compatible units
91+
if units in compatible_units:
92+
energy = input(f'Energy in {units} to convert: ')
93+
#Convert to hartree, kcal, um, Thz, ps
94+
print('-'*50)
95+
convert2eV(energy, units)
96+
convert2nm(energy, units)
97+
convert2wavenumber(energy, units)
98+
convert2hartree(energy, units)
99+
convert2kcal(energy,units)
100+
convert2joule(energy,units)
101+
print('-'*50)
102+
else:
103+
print(f'Did not enter a compatible unit or with the correct syntax{compatible_units}')
104+
105+
if __name__ == '__main__':
106+
main()

LICENSE.md

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
MIT License
2+
3+
Copyright (c) 2021 Mackenzie Fahey
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.

README.md

+43
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
# Spectrochemical Energy Converter
2+
3+
## Description
4+
Android APK written in python/kivy that allows scientists to quickly and easily convert common energy units used.
5+
6+
## Project Status
7+
Published on Google Play, small bug fixes will be made and potentially an IOS version will be released in the coming months.
8+
9+
## Installation
10+
The live APK can be found on the Google Play store and can be installed on any android device.
11+
12+
On Windows or Linux computers, the python package (main.py) can be run as long as the EnergyConversions.py is found in the same directory. This will generate the GUI and allow users to work with the energy conversion tools on their PCs.
13+
14+
Building a modified APK from the python package requires Buildozer to be configured on a linux machine or VM.
15+
16+
## Usage
17+
18+
'''python main.py'''
19+
20+
## Support
21+
Contact the author at [email protected]
22+
23+
## Roadmap
24+
Plan on releasing and IOS version by Fall 2021 and plan on continued bug fixes and update implementations as wanted or needed.
25+
26+
## Contributing
27+
Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.
28+
29+
Please make sure to update tests as appropriate.
30+
31+
# Authors and Acknowledgment
32+
Mackenzie Fahey
33+
34+
mmfahey Programming
35+
36+
37+
38+
https://mmfahey-portfolio-app.herokuapp.com/
39+
40+
https://github.com/mmfahey
41+
42+
## License
43+
[MIT](https://choosealicense.com/licenses/mit/)

0 commit comments

Comments
 (0)