Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Module for high-level API #30

Closed
1 of 2 tasks
schneiderfelipe opened this issue May 23, 2020 · 6 comments
Closed
1 of 2 tasks

Module for high-level API #30

schneiderfelipe opened this issue May 23, 2020 · 6 comments
Assignees
Labels
documentation Improvements or additions to documentation enhancement New feature or request
Milestone

Comments

@schneiderfelipe
Copy link
Member

schneiderfelipe commented May 23, 2020

We could benefit from a high-level interface, defined as an interface that deals with logfile and model objects directly. All functions would be higher-level versions of internal procedures. This is related to the discussion in #28.

  • As such, the user would be able to do something similar to:
from overreact import api, io, simulate
import matplotlib.pyplot as plt

model = io.parse_model("my-model.jk")
for temperature in [200.0, 300.0, 400.0]:
    enthalpies = api.get_enthalpies(model.compounds, temperature=temperature)
    entropies = api.get_entropies(model.compounds, temperature=temperature)
    freeenenergies = enthalpies - temperature * entropies

    delta_freeenergies = api.get_delta(model.scheme.B, freeenergies)
    k = api.get_k(delta_freeenergies)
    kappa = api.get_kappa(delta_freeenergies, model.scheme)
    k = kappa * k

    y0 = [1.0, 0.0]
    dydt = simulate.get_dydt(scheme, k)
    t, y = simulate.get_y(dydt, y0=y0, method="Radau")
    plt.plot(t, y[1], label=f"P @{temperature}K")

plt.legend()
plt.xlabel("Time (s)")
plt.ylabel("Concentration (M)")
plt.show()

Furthermore, other related things are proposed:

  • Calculate the degree of rate control with a factory function that receives the free energies as first parameter and returns one reaction rate:
...
def factory(freeenergies, scheme, y0, t):
    delta_freeenergies = api.get_delta(scheme.B, freeenergies)
    k = api.get_k(delta_freeenergies)
    kappa = api.get_kappa(delta_freeenergies, scheme)
    k = kappa * k

    dydt = simulate.get_dydt(scheme, k)
    t, y = simulate.get_y(dydt, y0, [0.0, t], method="Radau")
    return dydt(t[-1], y.T)

t = 60.0
y0 = [1.0, 0.0]
drc = get_drc(factory, args=(model.scheme, y0, t))

# degree of rate control of the formation of 1 (P) with respect to all compounds
print(drc[1, :])

The (square) array-like object drc would contain the derivatives of equation 1 of Campbell (2020) for the rate of formation of all compounds with respect to the free energies of all compounds.

@schneiderfelipe schneiderfelipe added documentation Improvements or additions to documentation enhancement New feature or request labels May 23, 2020
@schneiderfelipe schneiderfelipe added this to the 1.0 milestone May 23, 2020
@schneiderfelipe schneiderfelipe self-assigned this May 23, 2020
@schneiderfelipe
Copy link
Member Author

Projects and issues related to the degree of rate control were moved to milestone 1.2.

@schneiderfelipe schneiderfelipe modified the milestones: 1.0, 1.1, 1.2 Jul 4, 2020
@schneiderfelipe schneiderfelipe modified the milestones: 1.2, 1.1 Nov 12, 2020
@schneiderfelipe
Copy link
Member Author

The ideas on rate control are still planned for 1.2, but all other suggestions are expected to be ready in 1.1.

@schneiderfelipe schneiderfelipe mentioned this issue Nov 20, 2020
3 tasks
@schneiderfelipe schneiderfelipe modified the milestones: 1.1, 1.0 Nov 23, 2020
@schneiderfelipe
Copy link
Member Author

This is important to have as we go public as we want to publish tutorials as Jupyter Notebooks (see #49).

@schneiderfelipe schneiderfelipe pinned this issue Nov 25, 2020
@schneiderfelipe
Copy link
Member Author

There is a demand for an API in Python for thermochemistry; see bobbypaton/GoodVibes#35.

@schneiderfelipe
Copy link
Member Author

We could benefit from a high-level interface, defined as an interface that deals with logfile and model objects directly. All functions would be higher-level versions of internal procedures. This is related to the discussion in #28.

* [x]  As such, the user would be able to do something similar to:

The current status has improved the example above a lot. A draft of how we can currently accomplish the same thing now:

import numpy as np
import matplotlib.pyplot as plt

import overreact as rx

model = rx.parse_model("my-model.k")
for temperature in [200.0, 300.0, 400.0]:
    # already multiplies contains transmission coefficients
    k = rx.get_k(model.scheme, model.compounds)
    dydt = rx.get_dydt(model.scheme, k)

    y0 = [1.0, 0.0]
    y, r = simulate.get_y(dydt, y0)

    t = np.linspace(y.t_min, y.t_max)
    plt.plot(t, y(t)[1], label=f"P @{temperature}K")

plt.legend()
plt.xlabel("Time (s)")
plt.ylabel("Concentration (M)")
plt.show()

Furthermore, other related things are proposed:

* [ ]  Calculate the degree of rate control with a factory function that receives the free energies as first parameter and returns one reaction rate:

I'm postponing this for now as I currently don't prioritize this anymore. The example above is good though. As such, this is going to 1.2 again.

@schneiderfelipe schneiderfelipe modified the milestones: 1.0, 1.2 Dec 21, 2020
@schneiderfelipe
Copy link
Member Author

I'm postponing the development on the degree of rate control and sensitivity analysis in general. The rest of this issue is there already.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation Improvements or additions to documentation enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant