javascript - Plasma concentration multiple doses Equations in js -
currently app needs calculate plasma concentration (multiple doses). i'm expecting cyclical depicted in case:
however, when seek calculate , plot out, comes out
the equation told should , function looks 1 below
function calculateplasmaconcentration(x, bioavailability, vd, ka, ke, dosing, dose) { var firstpart, secondpart, c; firstpart = ((bioavailability * dose * ka) / (vd * ka - vd * ke)); secondpart = (math.exp(-ke * x) / (1 - math.exp(-ke * dosing))) - (math.exp(-ka * x) / (1 - math.exp(-ka * dosing))); c = firstpart * secondpart; homecoming c; } i can't seem see wrote equation wrong, doing wrong? parameter x should time in hours.
adding default values here:
defaultdruginfo = { dose: 500, dosing: 24, bioavailability: .89, ka: .883, ke: .0578, vd: 6, optimaltoprange: 10, optimalbottomrange: 5 } thanks in advance!
you need phone call function calculateplasmaconcentration(...) way:
// 4 cycles (cycle = 0; cycle < 4; cycle++) { // 24 hr dosing (t = 0; t < 24; t++) { nums.push(math.round(calculateplasmaconcentration(t, 0.89, 6, 0.883, 0.0578, 24, 500) * 1000) / 1000); } } the graph created numbers generated function is:
[edit]when time hits 24 hr intervals, plasma concentration values next day supposed add together lastly plasma concentration value previous day, since dose doesn't disappear body.
next, when append tau(τ), (i in our case) along plasma concentration value(temp.push([i + delta, pcstack + pc]);) need add together 24 i, everytime time hits 24 hr intervals.
this updated function.
function generatedata(druginfo) { var pcstack = 0; var temp = [], mainarray = [], tempobject = {}; var start = 0; var end = 24; var delta = 0; (cycle = 0; cycle < 4; cycle++) { (i = 0; < 24; += 0.05) { var pc = calculateplasmaconcentration(i, druginfo.bioavailability, druginfo.vd, druginfo.ka, druginfo.ke, druginfo.dosing, druginfo.dosage); temp.push([i + delta, pcstack + pc]); } pcstack += pc; delta += 24; } tempobject = { data: temp }; mainarray.push(tempobject); homecoming mainarray; } javascript equation-solving
No comments:
Post a Comment