def known_solutions(potential_min, potential_max, csv_path=None):
  """Returns [potential, stationarity, *coords] rows for known solutions."""
  if csv_path is None:
    csv_path = os.path.join(os.path.dirname(__file__),
                            '../equilibria/SO8_SOLUTIONS.csv')
  return [numpy.asarray(row) for row in mu.csv_numdata(csv_path)
          if potential_min <= row[0] <= potential_max]
 def test_known_so8_solutions(self):
   """Asserts numpy stationarity of the known SO(8) solutions."""
   for row in mu.csv_numdata('dim4/so8/equilibria/SO8_SOLUTIONS.csv'):
     table_potential = row[0]
     potential, stationarity = SUGRA.potential_and_stationarity(row[2:])
     self.assertTrue(0.0 <= stationarity <= 1e-15)
     self.assertTrue(numpy.isclose(potential, table_potential, atol=1e-8))
 def test_known_so8c_solutions(self):
   """Asserts numpy stationarity of the known SO(8)c omega=pi/8 solutions."""
   tc_omega = mu.tff64(numpy.pi / 8)
   for row in mu.csv_numdata('dim4/so8/equilibria/SO8C_PI8_SOLUTIONS.csv'):
     table_potential = row[0]
     potential, stationarity = SUGRA.potential_and_stationarity(
         row[2:], t_omega=tc_omega)
     self.assertTrue(0.0 <= stationarity <= 1e-7)
     self.assertTrue(numpy.isclose(potential, table_potential, atol=1e-8))
def demo_show_physics_so7():
  """Text-prints the physics of the known 'SO(7)+' solution."""
  sugra = SO8_SUGRA()
  rows = list(itertools.islice(mu.csv_numdata(
      'dim4/so8/equilibria/SO8_SOLUTIONS.csv'), 10))
  # phys = sugra.get_physics(rows[4][-70:],
  #                          dict(name='some_solution'))  # SU(3)xU(1) N=2
  # phys = sugra.get_physics(rows[8][-70:], dict(name='SO(3)xSO(3) S0880733'))
  phys = sugra.get_physics(rows[1][-70:], dict(name='SO(7)+'))
  print(sugra.show_physics_text(phys))
          verbosity='SF')):
    sol = nn, pot, stat, *params.tolist()
    sols.append(sol)
    print(f'### nn={nn} P={pot:.8f} S={stat:.6g}\n')
    with open(scan_file, 'at') as h_out:
      print(','.join(map(repr, sol)), file=h_out)


if mu.arg_enabled(__name__, 'analyze_u4xr12_scan'):
  # A deeper scan would reveal 24 different critical points.
  # There might be more.
  stationarity_limit = 1e-14
  theta_sugra = gaugings.Dim4SUGRA(
      get_theta_u4xr12(c=1.0),
      gaugeability_atol=1e-10)
  scanned = list(mu.csv_numdata(scan_file))
  analyzed = {}
  for row in scanned:
    num_row = int(row[0])
    if num_row % 10 == 0:
      print(f'Row {num_row}...')
    if row[2] > stationarity_limit:
      continue  # Skip bad data.
    m_grav = theta_sugra.gravitino_masses_from_position(row[-70:])
    key = f'{row[1]:.6f}'
    analyzed.setdefault(key, []).append(
        (num_row, ' '.join(f'{m:+.4f}' for m in m_grav)))
  with open(analyzed_file, 'wt') as h_out:
    h_out.write(pprint.pformat(analyzed, width=120))