OpenMPCD
DumbbellUtilities.py
1 import numpy
2 import sys
3 
4 def getLagrangianMultiplicatorRatioFromWeissenbergNumber(Wi):
5  if Wi == 0:
6  return 1
7 
8  coefficients = [1, -1, 0, -Wi * Wi / 6.0] #see Kowalik and Winkler's paper
9 
10  roots = numpy.roots(coefficients)
11 
12  if len(roots) != 3:
13  raise RuntimeError("Unexpected number of roots in " + sys._getframe().f_code.co_name)
14 
15  if not numpy.array_equal(numpy.isreal(roots), [True, False, False]):
16  raise RuntimeError("Unexpected types of roots in " + sys._getframe().f_code.co_name)
17 
18  return roots[0].real