Hi, when I run cbc.twist on the two file below, I get the following error..

Asked by Scott Richardson

Traceback (most recent call last):
  File "twist2.py", line 38, in <module>
    u = twist.solve()
  File "/usr/local/lib/python2.7/dist-packages/cbc/twist/problem_definitions.py", line 26, in solve
    self.solver = StaticMomentumBalanceSolver(self, self.parameters["solver_parameters"])
  File "/usr/local/lib/python2.7/dist-packages/cbc/twist/solution_algorithms.py", line 40, in __init__
    vector)
  File "/usr/local/lib/python2.7/dist-packages/cbc/common/CBCSolver.py", line 65, in create_dirichlet_conditions
    error("The number of Dirichlet values does not match the number of Dirichlet boundaries.")
  File "/usr/lib/python2.7/dist-packages/dolfin/cpp.py", line 2236, in error
    return _cpp.error(*args)
RuntimeError: *** Error: The number of Dirichlet values does not match the number of Dirichlet boundaries.

file 1: twist1.py ===============================================

from cbc.twist import *

class Twist(StaticHyperelasticity):

     def mesh (self):
  n = 8
  return UnitCube(n, n, n)

     def dirichlet_conditions(self):
  clamp = Expression(("0.0", "0.0", "0.0"))
  twist = Expression(("0.0",
  "y0+(x[1]-y0)*cos(theta)-(x[2]-z0)*sin(theta)-x[1]",
  "z0+(x[1]-y0)*sin(theta)+(x[2]-z0)*cos(theta)-x[2]"))
  twist.y0 = 0.5
  twist.z0 = 0.5
  twist.theta = pi/3
  return[clamp, twist]

     def dirichlet_boundaries(self):
  return ["x[0] == 0.0", "x[0] == 1.0"]

     def material_model(self):
  mu = 3.8461
  lmbda = Expression("x[0]*5.8+(1-x[0])*5.7")
  material = StVenantKirchhoff([mu, lmbda ])
  return material

     def __str__(self):
  return "A cube twisted by 60 degrees"

# Setup and solve problem
twist = Twist()
u = twist.solve()
#plot(u, title="Twisted cube", mode="displacement")

file 2: twist2.py =====================================================

from cbc.twist import *

class Twist(StaticHyperelasticity):

         def mesh(self):
             return UnitCube(8, 8, 8)

         def dirichlet_conditions(self):
             clamp = Expression(("0.0", "0.0", "0.0"))
             twist = Expression(("0.0",
             "y0+(x[1]-y0)*cos(a)-(x[2]-z0)*sin(a)-x[1]",
             "z0+(x[1]-y0)*sin(a)+(x[2]-z0)*cos(a)-x[2]"))
             twist.y0 = 0.5
             twist.z0 = 0.5
             twist.a = pi/3
             return clamp, twist

         def dirichlet_boundaries(self):
             left = "x[0] == 0.0"
             right = "x[0] == 1.0"
             return left, right

         def body_force(self):
             B = Expression(("0.0", "0.0", "0.0"))
             return B

         def material_model(self):
             mu = 3.8461
             lambda_ = 5.7692
             material = StVenantKirchhoff([mu, lambda_])
             return material

         def __str__(self):
             return "Hyperelastic cube twisted 60 degrees"

     # Setup and solve problem
twist = Twist()
u = twist.solve()
plot(u, title="Twisted cube", mode="displacement")

==============================================

Question information

Language:
English Edit question
Status:
Solved
For:
CBC.Solve Edit question
Assignee:
No assignee Edit question
Solved by:
Scott Richardson
Solved:
Last query:
Last reply:
Revision history for this message
Scott Richardson (scott-richardson-personal) said :
#1

The demo problem worked I must have a mistake when I copied it over!