Andrew Dawes
unread,Nov 17, 2017, 12:44:52 AM11/17/17Sign in to reply to author
Sign in to forward
You do not have permission to delete messages in this group
Sign in to report message
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to qu...@googlegroups.com
TLDR; is there an elegant way to pass several time-dependent coefficients based on the same function (but with different arguments) into mesolve?
I’m working on a problem with multiple time-dependent coefficients and using the form where
H = [H0,[H1,H1_coeff],[H2,H2_coeff]]
but in reality H1_coeff and H2_coeff are the same function but with different arguments. For the sake of simplicity say they are:
def H1_coeff(t, args):
return args[“A”] * cos(args[“k”] * t)
It seems duplicitous to have to write this twice just to pass in different args:
def H1_coeff(t, args):
return args[“A”] * cos(args[“k”] * t)
def H2_coeff(t, args):
return args[“A2”] * cos(args[“k2”] * t)
but I can’t seem to think of a better way to do it since ultimately the args have to be passed in to mesolve as one big dict.
This example is somewhat trivial since I can manage two functions just fine, but four, five or more and it gets unwieldy. I’d like to see about allowing a format like:
H = [H0,[H1,H1_coeff, H1_args],[H2,H2_coeff, H2_args]]
Tracking this possibility through the code, I see there is potential issue in drho_list_td where L_list is being assembled from all the elements in H:
L = L_list[n][0]
L_td = L_list[n][1]
if L_list[n][2]:
spmvpy_csr(L.data, L.indices, L.indptr,
rho, L_td(t, args)**2, out)
There already appears to be something handling the case of a three-element list (to deal with c_square?). I don’t know if there are other dealbreakers for trying to implement something like this, or perhaps I’m missing a simpler way forward.
Hope this makes some sense, and thanks for any insight.
Andy