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_roche_semidetached(plot=False): #print "roche semi-detached" q = 1 F = 1 d = 1 r_crit = libphoebe.roche_critical_potential(q, F, d, L1 = True, L2 = False, L3 = False) Omega0 = r_crit["L1"] choice = 0 # determine area and volume r_av = libphoebe.roche_area_volume(q, F, d, Omega0, choice, larea=True, lvolume=True) #print r_av # calculate delta ntriangles=1000 delta = np.sqrt(r_av["larea"]/(np.sqrt(3)*ntriangles/4)) max_triangles = int(1.5*ntriangles) # generate mesh r_mesh = libphoebe.roche_marching_mesh(q, F, d, Omega0, delta, choice, max_triangles, vertices=True, vnormals=True, triangles=True, tnormals=True, areas=True, area=True, volume=True, full=True) # check the number of triagles of the mesh #print len(r_mesh["triangles"]) assert(0.75*ntriangles < len(r_mesh["triangles"]) < 1.35*ntriangles) # check is the vertices are really on isosurface #print np.max(np.abs([potential_roche(r, q, F, d) - Omega0 for r in r_mesh["vertices"]])) assert(np.max(np.abs([potential_roche(r, q, F, d) - Omega0 for r in r_mesh["vertices"]])) < 1e-12) # check the area -0.00524575234831 #print (r_mesh["area"]-r_av["larea"])/r_av["larea"] assert (np.abs(r_mesh["area"]-r_av["larea"])/r_av["larea"] < 1e-2) # check the volume -0.00985875277254 #print (r_mesh["volume"]- r_av["lvolume"])/r_av["lvolume"] assert (np.abs(r_mesh["volume"]- r_av["lvolume"])/r_av["lvolume"] < 2e-2)
def potential_contact_L23(q, **kwargs): """ """ crit_pots = libphoebe.roche_critical_potential(q, 1., 1.) return max(crit_pots['L2'], crit_pots['L3'])
def potential_contact_L1(q, **kwargs): """ """ crit_pots = libphoebe.roche_critical_potential(q, 1., 1.) return crit_pots['L1']