void ColumnDerivative(Mode m, Mode mj, Geometry geo, Vec dfR, Vec dfI, Vec vIpsi, Vec vpsisq, int ih){ // vIpsi is for m, vpsisq is for mj // use pointers so can check whether ih = jh // purposely don't set df = 0 here to allow multiple ih's double mjc = get_c(mj); dcomp mw = get_w(m), yw = gamma_w(m, geo); Complexfun psi, eps; CreateComplexfun(&psi,m->vpsi, vIpsi); CreateComplexfun(&eps,geo->veps, geo->vIeps); Vecfun f,H, psisq; CreateVecfun(&f, geo->vf); CreateVecfun(&H, geo->vH); CreateVecfun(&psisq, vpsisq); int i; for(i=psi.ns; i<psi.ne; i++){ dcomp dfdk = 0.0, dfdc = 0.0, DfywHpsi = geo->D * valr(&f, i) * yw * valr(&H, i) * valc(&psi, i); if(m == mj) dfdk += ( -csqr(mw)*yw / geo->y +2.0*mw ) * DfywHpsi + 2.0*mw* valc(&eps, i)*valc(&psi, i); // note: adding dcomp to a double ignores the imaginary part if(m->lasing && valr(&f, i) != 0.0){ // dHdk removed; field simply rescaled -DL 6/15/14 dfdc = csqr(mw) * DfywHpsi * valr(&H, i); dfdc *= (-2.0*mjc)*valr(&psisq, i); } if( !m->lasing) VecSetComplex(dfR, dfI, i+offset(geo, ih), ir(geo, i), dfdk, INSERT_VALUES); else{ VecSetValue(dfR, i+offset(geo, ih), ir(geo, i)? cimag(dfdk) : creal(dfdk), INSERT_VALUES ); VecSetValue(dfI, i+offset(geo, ih), ir(geo, i)? cimag(dfdc) : creal(dfdc), INSERT_VALUES ); // df is assembled in SetJacobian } } DestroyComplexfun(&eps); DestroyComplexfun(&psi); DestroyVecfun(&f); DestroyVecfun(&H); DestroyVecfun(&psisq); }
void TensorDerivative(Mode m, Mode mj, Geometry geo, Vec df, Vec vpsibra, Vec vIpsi, int ih){ double mjc = get_c(mj); dcomp mw = get_w(m), yw = gamma_w(m, geo) ; Vecfun f, H, psibra; CreateVecfun(&f, geo->vf); CreateVecfun(&H, geo->vH); CreateVecfun(&psibra, vpsibra); Complexfun psi; CreateComplexfun(&psi, m->vpsi, vIpsi); int i; for(i=f.ns; i<f.ne; i++){ if( valr(&f, i) == 0.0) continue; dcomp ket_term = -csqr(mw ) * sqr(mjc) * 2.0 * sqr(valr(&H, i) ) * geo->D * valr(&f, i) * yw * valc(&psi, i); double val = valr(&psibra, i) * (ir(geo, i)? cimag(ket_term) : creal(ket_term) ); VecSetValue(df, i+offset(geo, ih), val, INSERT_VALUES); // df is assembled in SetJacobian } DestroyVecfun(&f); DestroyVecfun(&H); DestroyVecfun(&psibra); DestroyComplexfun(&psi); }
double RenderableEffect::GetValueCurveDouble(wxString name, double def, const SettingsMap &SettingsMap, float offset) { double res = SettingsMap.GetDouble("TEXTCTRL_" + name, def); wxString vc = SettingsMap.Get("VALUECURVE_" + name, ""); if (vc != "") { ValueCurve valc(vc.ToStdString()); if (valc.IsActive()) { res = valc.GetOutputValueAt(offset); } } return res; }
void LinearDerivative(Mode m, Geometry geo, Vec dfR, Vec dfI, int ih){ Complexfun eps; CreateComplexfun(&eps, geo->veps, geo->vIeps); Vecfun f, H; CreateVecfun(&f, geo->vf); CreateVecfun(&H, geo->vH); dcomp mw = get_w(m), yw = gamma_w(m, geo); int i; for(i=eps.ns; i<eps.ne; i++){ dcomp val = csqr(mw) * (valc(&eps, i) + geo->D * yw * valr(&f, i) * valr(&H, i) ); VecSetComplex(dfR, dfI, i+offset(geo, ih), ir(geo, i), val, INSERT_VALUES); // df is assembled in SetJacobian } DestroyVecfun(&f); DestroyVecfun(&H); DestroyComplexfun(&eps); }
int RenderableEffect::GetValueCurveInt(wxString name, int def, const SettingsMap &SettingsMap, float offset) { int res = def; if (SettingsMap.Contains("SLIDER_" + name)) { res = SettingsMap.GetInt("SLIDER_" + name, def); } else if (SettingsMap.Contains("TEXTCTRL_" + name)) { res = SettingsMap.GetInt("TEXTCTRL_" + name, def); } if (SettingsMap.Contains("VALUECURVE_" + name)) { wxString vc = SettingsMap.Get("VALUECURVE_" + name, ""); ValueCurve valc(vc.ToStdString()); if (valc.IsActive()) { res = valc.GetOutputValueAt(offset); } } return res; }