Skip to content

Commit

Permalink
Initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
antalszava committed May 8, 2017
0 parents commit 8b60492
Show file tree
Hide file tree
Showing 588 changed files with 365,878 additions and 0 deletions.
Empty file added .gitignore
Empty file.
363 changes: 363 additions & 0 deletions HuckelCode.ipynb
Original file line number Diff line number Diff line change
@@ -0,0 +1,363 @@
{
"cells": [
{
"cell_type": "code",
"execution_count": 1,
"metadata": {
"collapsed": true
},
"outputs": [],
"source": [
"#load modules\n",
"import os\n",
"import subprocess\n",
"import time\n",
"import fnmatch\n",
"from subprocess import Popen, PIPE\n",
"from IPython.display import display, clear_output, Image\n",
"from ipywidgets import interact, interactive, fixed, interact_manual, Checkbox\n",
"import ipywidgets as widgets\n",
"\n",
"\n",
"import matplotlib.pyplot as plt\n",
"import numpy as np\n",
"%matplotlib inline\n",
"import gc\n",
"\n",
"from IPython.core.display import Image"
]
},
{
"cell_type": "code",
"execution_count": 2,
"metadata": {
"collapsed": true
},
"outputs": [],
"source": [
"distance_mx = Checkbox(\n",
" description='Distance matrix',\n",
" value=False\n",
")\n",
"overlap_pop = Checkbox(\n",
" value=False,\n",
" description='Overlap population'\n",
")\n",
"red_overlap_pop = Checkbox(\n",
" value=False,\n",
" description='Reduced overlap population'\n",
")\n",
"charge_mx = Checkbox(\n",
" value=False,\n",
" description='Charge matrix'\n",
")\n",
"wave_func = Checkbox(\n",
" value=False,\n",
" description='Wave functions'\n",
")\n",
"net_charges = Checkbox(\n",
" value=False,\n",
" description='Net charges'\n",
")\n",
"overlap = Checkbox(\n",
" value=False,\n",
" description='Overlap matrix'\n",
")\n",
"\n",
"hamil = Checkbox(\n",
" value=False,\n",
" description='Hamiltonian matrix'\n",
")\n",
"\n",
"electrostatic = Checkbox(\n",
" value=False,\n",
" description='Electrostatic'\n",
")\n",
"\n",
"levels = Checkbox(\n",
" value=False,\n",
" description='Levels'\n",
")\n",
"\n",
"fermi = Checkbox(\n",
" value=False,\n",
" description='Fermi'\n",
")\n",
"\n",
"orbital_energy = Checkbox(\n",
" value=False,\n",
" description='Orbital energy'\n",
")\n",
"\n",
"orbital_coeff = Checkbox(\n",
" value=False,\n",
" description='Orbital coefficient'\n",
")\n",
"\n",
"orbital_mapping = Checkbox(\n",
" value=False,\n",
" description='Orbital mapping'\n",
")\n",
"\n",
"dump_overlap = Checkbox(\n",
" value=False,\n",
" description='Dump overlap'\n",
")\n",
"\n",
"dump_hamil = Checkbox(\n",
" value=False,\n",
" description='Dump Hamiltonian'\n",
")\n",
"\n",
"dump_sparse = Checkbox(\n",
" value=False,\n",
" description='Dump sparse'\n",
")\n",
"\n",
"\n",
"firstgroup = [distance_mx, overlap_pop,red_overlap_pop, charge_mx,\n",
" wave_func,net_charges,overlap, hamil, electrostatic]\n",
"\n",
"\n",
"secondgroup = [levels, fermi,orbital_energy, orbital_coeff,\n",
" orbital_mapping,dump_overlap,dump_hamil, dump_sparse]\n"
]
},
{
"cell_type": "code",
"execution_count": 3,
"metadata": {
"collapsed": true
},
"outputs": [],
"source": [
"#Dictionary for checkboxes and for configuration keywords\n",
"propertiesdictionary = {distance_mx.description: 'distance matrix',\n",
" overlap_pop.description: 'overlap population',\n",
" red_overlap_pop.description: 'reduced overlap population',\n",
" charge_mx.description:'charge matrix',\n",
" wave_func.description: 'wave functions',\n",
" net_charges.description:'net charges',\n",
" overlap.description:'overlap',\n",
" hamil.description:'hamil',\n",
" electrostatic.description:'electrostatic',\n",
" levels.description:'levels',\n",
" fermi.description:'fermi',\n",
" orbital_energy.description:'orbital energy',\n",
" orbital_coeff.description:'orbital coeff',\n",
" orbital_mapping.description:'orbital mapping',\n",
" levels.description:'levels',\n",
" dump_overlap.description:'dump overlap',\n",
" dump_hamil.description:'dump hamil',\n",
" dump_sparse.description:'dump sparse'}"
]
},
{
"cell_type": "code",
"execution_count": 4,
"metadata": {
"collapsed": true
},
"outputs": [],
"source": [
"def createinput( arg1, arg2 ):\n",
" process = Popen([\"/home/toncsi/ClionProjects/IPython/input_pdb\", arg1, arg2], stdout=subprocess.PIPE, stderr=subprocess.PIPE)\n",
" (output, err) = process.communicate()\n",
" exit_code = process.wait()\n",
" if err == b'':\n",
" print('Creation of input file was successful')\n",
" return\n",
" else:\n",
" return err\n",
"\n",
"def huckel(arg):\n",
" process = Popen([\"/home/toncsi/ClionProjects/IPython/bind\", arg], stdout=subprocess.PIPE, stderr=subprocess.PIPE)\n",
" (output, err) = process.communicate()\n",
" exit_code = process.wait()\n",
" if err == b'':\n",
" print('Extended Huckel calculations were successful')\n",
" return\n",
" else:\n",
" return err"
]
},
{
"cell_type": "code",
"execution_count": 5,
"metadata": {
"collapsed": true
},
"outputs": [],
"source": [
"#Write own configuration file based on given properties\n",
"\n",
"def writeproperties( arg ):\n",
" for item in arg:\n",
" if item.value == True:\n",
" f.write(propertiesdictionary[item.description]+'=true\\n')\n",
" else:\n",
" f.write(propertiesdictionary[item.description]+'=false\\n')\n",
" return"
]
},
{
"cell_type": "code",
"execution_count": 21,
"metadata": {
"collapsed": true
},
"outputs": [],
"source": [
"def writeconfigfile():\n",
" f = open(configFileName, 'w')\n",
" f.write('molecule name='+ molName + '\\n')\n",
" for item in firstgroup:\n",
" if item.value == True:\n",
" f.write(propertiesdictionary[item.description]+'=true\\n')\n",
" else:\n",
" f.write(propertiesdictionary[item.description]+'=false\\n')\n",
" for item in secondgroup:\n",
" if item.value == True:\n",
" f.write(propertiesdictionary[item.description]+'=true\\n')\n",
" else:\n",
" f.write(propertiesdictionary[item.description]+'=false\\n')\n",
" f.close()"
]
},
{
"cell_type": "code",
"execution_count": 22,
"metadata": {
"scrolled": false
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Molecule filename: 1bna.pdb\n",
"Configuration filename: config.txt\n"
]
}
],
"source": [
"#Specify input file names\n",
"molFileName = input(\"Molecule filename: \")\n",
"configFileName = input(\"Configuration filename: \")\n",
"molName = molFileName[:molFileName.find('.')]\n",
"yahFileName= molName + '.yah'"
]
},
{
"cell_type": "code",
"execution_count": 23,
"metadata": {},
"outputs": [
{
"data": {
"application/vnd.jupyter.widget-view+json": {
"model_id": "92fa4190e95e45a19d8b4730215ea76c"
}
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"#If not using a configuration file that was created before, use the following checkboxes\n",
"#and then uncomment the cell containing the writeconfigfile function\n",
"#Parameters of the configuration file\n",
"container1 = widgets.HBox([widgets.VBox(firstgroup)])\n",
"display(container1)"
]
},
{
"cell_type": "code",
"execution_count": 24,
"metadata": {},
"outputs": [
{
"data": {
"application/vnd.jupyter.widget-view+json": {
"model_id": "7fbb5c56be11415488d27abdbedb645b"
}
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"container2 = widgets.HBox([widgets.VBox(secondgroup)])\n",
"display(container2) "
]
},
{
"cell_type": "code",
"execution_count": 25,
"metadata": {},
"outputs": [],
"source": [
"#Uncomment the following line if specific configuration file is to be created\n",
"writeconfigfile()"
]
},
{
"cell_type": "code",
"execution_count": 26,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Creation of input file was successful\n"
]
}
],
"source": [
"createinput(molFileName,configFileName)"
]
},
{
"cell_type": "code",
"execution_count": 28,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"b'Invalid Printing Option: DUMP SPARSE\\n in input file.\\nDid you forget to include end_print?\\nERROR: Bad print option..\\n'"
]
},
"execution_count": 28,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"huckel(yahFileName)"
]
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 3",
"language": "python",
"name": "python3"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.5.2"
}
},
"nbformat": 4,
"nbformat_minor": 2
}
10 changes: 10 additions & 0 deletions huckelcode/.idea/misc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 8 additions & 0 deletions huckelcode/.idea/modules.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions huckelcode/.idea/parallel.iml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 8b60492

Please sign in to comment.