def requiv_contact_L23(q, sma, compno, **kwargs): """ for the contact case we can make the assumption of aligned, synchronous, and circular """ logger.debug("requiv_contact_L23(q={}, sma={}, compno={})".format( q, sma, compno)) crit_pot_L23 = potential_contact_L23(q) logger.debug( "libphoebe.roche_contact_neck_min(phi=pi/2, q={}, d=1., crit_pot_L23={})" .format(q, crit_pot_L23)) nekmin = libphoebe.roche_contact_neck_min(np.pi / 2., q, 1., crit_pot_L23)['xmin'] # we now have the critical potential and nekmin as if we were the primary star, so now we'll use compno=0 regardless logger.debug( "libphoebe.roche_contact_partial_area_volume(nekmin={}, q={}, d=1, Omega={}, compno={})" .format(nekmin, q, crit_pot_L23, compno - 1)) crit_vol_L23 = libphoebe.roche_contact_partial_area_volume( nekmin, q, 1., crit_pot_L23, compno - 1, lvolume=True, ldvolume=False, larea=False)['lvolume'] logger.debug("resulting vol: {}, requiv: {}".format( crit_vol_L23, (3. / 4 * 1. / np.pi * crit_vol_L23)**(1. / 3) * sma)) return (3. / 4 * 1. / np.pi * crit_vol_L23)**(1. / 3) * sma
def pot_to_requiv_contact(pot, q, sma, compno=1): """ """ logger.debug( "pot_to_requiv_contact(pot={}, q={}, sma={}, compno={})".format( pot, q, sma, compno)) d = 1. F = 1. crit_pots = libphoebe.roche_critical_potential(q, d, F) crit_pot_L1 = crit_pots['L1'] crit_pot_L23 = max(crit_pots['L2'], crit_pots['L3']) if pot > crit_pot_L1: raise ValueError("potential > L1 critical value") if pot < crit_pot_L23: raise ValueError("potential < L2/L3 critical value") try: logger.debug( "libphoebe.roche_contact_neck_min(pi/2, q={}, d={}, pot={})". format(q, d, pot)) nekmin = libphoebe.roche_contact_neck_min(np.pi / 2., q, d, pot)['xmin'] logger.debug( "libphoebe.roche_contact_partial_area_volume(nekmin={}, q={}, d={}, pot={}, compno={})" .format(nekmin, q, d, pot, compno - 1)) volume_equiv = libphoebe.roche_contact_partial_area_volume( nekmin, q, d, pot, compno - 1)['lvolume'] # returns normalized vequiv, should multiply by sma back for requiv in SI return sma * (3. / 4 * 1. / np.pi * volume_equiv)**(1. / 3) except: # replace this with actual check in the beginning or before function call raise ValueError( 'potential probably out of bounds for contact envelope')
def test_contact_neck(plot=False): q = 0.1 d = 1. Omega0 = 1.9 neck_xy = libphoebe.roche_contact_neck_min(0., q, d, Omega0) neck_xz = libphoebe.roche_contact_neck_min(np.pi / 2., q, d, Omega0) neck_xy0 = {'xmin': 0.742892957853368, 'rmin': 0.14601804638933566} neck_xz0 = {'xmin': 0.7383492639142092, 'rmin': 0.13255145166593718} assert (abs(neck_xy['xmin'] - neck_xy0['xmin']) < 1e-12 * neck_xy0['xmin']) assert (abs(neck_xz['xmin'] - neck_xz0['xmin']) < 1e-12 * neck_xz0['xmin']) if plot: print "neck_xy=", neck_xy print "neck_xz=", neck_xz
def test_contact_omega_at_vol(plot=False): q = 0.1 d = 1. Omega0 = 1.9 phi = np.pi/2 neck = libphoebe.roche_contact_neck_min(phi, q, d, Omega0) x = neck["xmin"] # where we cut it choice = 0 # 0 for left and 1 for right pvol = libphoebe.roche_contact_partial_area_volume(x, q, d, Omega0, choice=choice) vol= pvol['lvolume'] Omega1 = libphoebe.roche_contact_Omega_at_partial_vol(vol, phi, q, d, choice=choice) assert(abs(Omega0 - Omega1) < 1e-12*Omega0) if plot: print("neck=",neck) print("pvol=", pvol) print("Omega0={}, Omega1={}".format(Omega0, Omega1))