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

be Unitful #2

Open
rkurchin opened this issue Sep 13, 2021 · 5 comments
Open

be Unitful #2

rkurchin opened this issue Sep 13, 2021 · 5 comments
Labels
enhancement New feature or request

Comments

@rkurchin
Copy link
Member

rkurchin commented Sep 13, 2021

Could be kind of neat to allow user to feed in either T or kT, or energies in other units than eV, etc...wouldn't want to clutter up interface though...

@rkurchin rkurchin added the enhancement New feature or request label Jul 26, 2022
@longemen3000
Copy link

hi!, i saw your package during juliacon 2022. i think i can help with this, but i need to get some familiarity on how the code works

@rkurchin
Copy link
Member Author

Awesome, happy to discuss! And let me know if you have questions about the codebase, too, I did some cleanup before registering so there are semi-decent docstrings/comments, but obviously the only docs that really exist right now are the readme...

@longemen3000
Copy link

longemen3000 commented Jul 27, 2022

on the unitful support, maybe you could do a function like this?

import Unitful
using Unitful: @u_str

V,T = nounits_vt(V,T)

function nounits_vt(_V,_T)
  V = nounits_v(V)
  T = nounits_t(T)
  return V,T
end

nounits_t(T::Real) = T
nounits_v(T::Real) = T
nounits_t(T::Unitful.Temperature) = Unitful.ustrip(Unitful.uconvert(u"K",T))
nounits_t(T::Unitful.Energy) = Unitful.ustrip(Unitful.uconvert(u"J",T))/1.380649e-23 #kT
nounits_v(V::Unitful.Voltage) = Unitful.ustrip(Unitful.uconvert(u"Volt",T))

that, given a normal number, returns the identity, but on unitful quantities it will convert to the correct ones?

and then, on each kinetic model, at the start:

function rate_constant(V_app, bv::ButlerVolmer, ::Val{true}; T = 298)
   V_app,T =  nounits_vt(V_app,T)
   exp_arg = (bv.α .* V_app) / (kB * T)
    bv.A .* exp.(exp_arg)
end

@longemen3000
Copy link

@rkurchin is ok if i make a PR this weekend?

@rkurchin
Copy link
Member Author

rkurchin commented Jul 30, 2022 via email

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

No branches or pull requests

2 participants