Exemplo n.º 1
0
  def compute_single_parent_3mode_eq(self, t=0.0, default=1e-20, tcurrent="x"):
    """
    computes the 3mode equilibrium state at t by choosing the G0-G1 triple that minimizes Ethr. Ignores all modes with genNo >1
    for modes that do not participate in the 3mode equilib, the real and imaginary parts are set to rand*default, with rand chosen separately for the real and imag parts

    if there are no couplings between G0-G1, we return the linear equilibrium state 
    """
    network = self.network
    gens, coups = network.gens()

    if not len(coups[0]): # no couplings from parents to next generation -> only one generation
      return self.compute_lin_eq(t=t, default=default)

    from nmode_state import threeMode_equilib # we import this here because it avoids conflicts when importing the module as a whole

    freqs = {}
    for modeNo, O in zip(gens[0], self.compute_linear_freqs(gens[0])): # compute linear frequencies and assign them
      freqs[modeNo] = O

    Ethr = np.infty
    for o,i,j,k in coups[0]: # these are couplings with G0 as parent (o) and G1 as children (i,j)
      Oo = freqs[o]
      wi, yi, _ = network.wyU[i]
      wj, yj, _ = network.wyU[j]
      ethr = compute_Ethr(Oo, wi, wj, yi, yj, k)
      if ethr < Ethr: # choose tuple with lowest Ethr
        Ethr = ethr
        best_tuple = (o,i,j,k)

    ### for best tuple
    (o,i,j), (Ao, Ai, Aj), ((so, co), (si, ci), (sj, cj)), (do, di, dj) = threeMode_equilib(best_tuple, freqs[best_tuple[0]], network) # get amplitudes, phases and detunings appropriate for tcurrent == "q"

    ### check whether the daughters are non-zero
    if (Ai==0) and (Aj==0):
      return self.compute_lin_eq(t=t, default=default, tcurrent=tcurrent)

    ### instantiate IC vector
    q = np.random.rand(2*len(network))*default # the vast majority are set to rand*default

    ### fill in best triple
    if tcurrent == "q":
      p = (wo-do)*t
      cp = np.cos(p)
      sp = np.sin(p)
      q[2*o:2*o+2] = Ao*np.array([cp*co + sp*so, -sp*co + cp*so])

      p = (wi-di)*t
      cp = np.cos(p)
      sp = np.sin(p)
      q[2*i:2*i+2] = Ai*np.array([cp*ci + sp*si, -sp*ci + cp*si])

      p = (wj-dj)*t
      cp = np.cos(p)
      sp = np.sin(p)
      q[2*j:2*j+2] = Aj*np.array([cp*cj + sp*sj, -sp*cj + cp*sj])

    elif tcurrent == "x":
      p = do*t
      cp = np.cos(p)
      sp = np.sin(p)
      q[2*o:2*o+2] = Ao*np.array([cp*co - sp*so, sp*co + cp*so])

      p = di*t
      cp = np.cos(p)
      sp = np.sin(p)
      q[2*i:2*i+2] = Ai*np.array([cp*ci - sp*si, sp*ci + cp*si])

      p = dj*t
      cp = np.cos(p)
      sp = np.sin(p)
      q[2*j:2*j+2] = Aj*np.array([cp*cj - sp*sj, sp*cj + cp*sj])
    else:
      raise ValueError, "unknown tcurrent = %s"%tcurrent

    return q
Exemplo n.º 2
0
  if opts.verbose: print "computing the most unstable pairings using observed frequencies"
  freqs = []
  for f in freq_maxs:
    if len(f) == 0:
      freqs.append( 0 )
    else:
      freqs.append( f[0][0]*Oorb )
  Ethrs = nm_s.Ethrs(freqs, network)

  if opts.verbose: print "computing expected amplitudes from best pairings"
  Amps = []
  for modeNo in range(len(network)):
    try:
      m,i,j,kmij, Ethr = Ethrs[modeNo][0]
      Amps.append( nm_s.threeMode_equilib((m,i,j,kmij), freqs[m], network, verbose=opts.verbose) ) # assumes "m" is the parent mode
    except IndexError:
      Amps.append( "none" )

####################################################################################################
#
#
#                                   report data!
#
#
####################################################################################################
if opts.stefilename:
  if opts.verbose: print "writing summary to "+opts.stefilename
  stefile = open(opts.stefilename, "w")
else:
  stefile = sys.stdout