{"action":"created","issue":{"url":"https://api.github.com/repos/choderalab/bayesian-itc/issues/10","labels_url":"https://api.github.com/repos/choderalab/bayesian-itc/issues/10/labels{/name}","comments_url":"https://api.github.com/repos/choderalab/bayesian-itc/issues/10/comments","events_url":"https://api.github.com/repos/choderalab/bayesian-itc/issues/10/events","html_url":"https://github.com/choderalab/bayesian-itc/issues/10","id":55714572,"number":10,"title":"Making ITC code faster","user":{"login":"pgrinaway","id":4674712,"avatar_url":"https://avatars.githubusercontent.com/u/4674712?v=3","gravatar_id":"","url":"https://api.github.com/users/pgrinaway","html_url":"https://github.com/pgrinaway","followers_url":"https://api.github.com/users/pgrinaway/followers","following_url":"https://api.github.com/users/pgrinaway/following{/other_user}","gists_url":"https://api.github.com/users/pgrinaway/gists{/gist_id}","starred_url":"https://api.github.com/users/pgrinaway/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/pgrinaway/subscriptions","organizations_url":"https://api.github.com/users/pgrinaway/orgs","repos_url":"https://api.github.com/users/pgrinaway/repos","events_url":"https://api.github.com/users/pgrinaway/events{/privacy}","received_events_url":"https://api.github.com/users/pgrinaway/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/choderalab/bayesian-itc/labels/enhancement","name":"enhancement","color":"84b6eb"},{"url":"https://api.github.com/repos/choderalab/bayesian-itc/labels/question","name":"question","color":"cc317c"}],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":6,"created_at":"2015-01-28T04:56:23Z","updated_at":"2015-01-28T20:06:43Z","closed_at":null,"body":"Hey,\r\n\r\nI was messing around with the code and discovered that stripping the units from the `expected_injection_heats` improves performance by something like two orders of magnitude. In other words, calling the function below (with units stripped in a wrapper):\r\n```\r\n    @staticmethod\r\n    def _calculate_expected_heats(P0, V0, Ls, DeltaG, DeltaH, DeltaH_0, DeltaVn, beta, N):\r\n\r\n        Kd = exp(beta * DeltaG)\r\n\r\n        Pn  = numpy.zeros([N])\r\n        Ln  = numpy.zeros([N])\r\n        PLn = numpy.zeros([N])\r\n\r\n        dcum = 1.0\r\n        for n in range(N):\r\n            d = 1.0 - (DeltaVn[n] / V0) # dilution factor for this injection (dimensionless)\r\n            dcum *= d # cumulative dilution factor\r\n            P = V0 * P0 * dcum # total quantity of protein in sample cell after n injections (mol)\r\n            L = V0 * Ls * (1. -dcum)  # total quantity of ligand in sample cell after n injections (mol)\r\n            PLn[n] = (0.5/V0 * ((P + L + Kd*V0) - ((P + L + Kd*V0)**2 - 4*P*L)**0.5)) # complex concentration (M)\r\n            Pn[n] = P/V0 - PLn[n]  # free protein concentration in sample cell after n injections (M)\r\n            Ln[n] = L/V0 - PLn[n]  # free ligand concentration in sample cell after n injections (M)\r\n        q_n = numpy.zeros([N]) # q_n_model[n] is the expected heat from injection n\r\n        q_n[0] = (DeltaH) * V0 * PLn[0] + DeltaH_0  # first injection # review removed a factor 1000 here, presumably leftover from a unit conversion\r\n        for n in range(1,N):\r\n            d = 1.0 - (DeltaVn[n] / V0)  # dilution factor (dimensionless)\r\n            q_n[n] = DeltaH * V0 * (PLn[n] - d*PLn[n-1]) + DeltaH_0 # subsequent injections # review removed a factor 1000 here, presumably leftover from a unit conversion\r\n        return q_n\r\n```"},"comment":{"url":"https://api.github.com/repos/choderalab/bayesian-itc/issues/comments/71905831","html_url":"https://github.com/choderalab/bayesian-itc/issues/10#issuecomment-71905831","issue_url":"https://api.github.com/repos/choderalab/bayesian-itc/issues/10","id":71905831,"user":{"login":"bas-rustenburg","id":3977731,"avatar_url":"https://avatars.githubusercontent.com/u/3977731?v=3","gravatar_id":"","url":"https://api.github.com/users/bas-rustenburg","html_url":"https://github.com/bas-rustenburg","followers_url":"https://api.github.com/users/bas-rustenburg/followers","following_url":"https://api.github.com/users/bas-rustenburg/following{/other_user}","gists_url":"https://api.github.com/users/bas-rustenburg/gists{/gist_id}","starred_url":"https://api.github.com/users/bas-rustenburg/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/bas-rustenburg/subscriptions","organizations_url":"https://api.github.com/users/bas-rustenburg/orgs","repos_url":"https://api.github.com/users/bas-rustenburg/repos","events_url":"https://api.github.com/users/bas-rustenburg/events{/privacy}","received_events_url":"https://api.github.com/users/bas-rustenburg/received_events","type":"User","site_admin":false},"created_at":"2015-01-28T20:06:43Z","updated_at":"2015-01-28T20:06:43Z","body":"Got it. At least one order of magnitude speedup achieved. [Here](https://github.com/bas-rustenburg/bayesian-itc/blob/96806790eebe30c4f6ad98172af3fd88442b53c7/python/bayesianitc/models.py#L249) is the wrapper that handles units. "}}