Skip to content

Problems in LinearConstraintProjection x_scale #2068

@YigitElma

Description

@YigitElma

If I try to pass in a numpy array to LinearConstraintProjections x_scale, it throws an error.

eq = get("precise_QA")
cons = get_fixed_boundary_constraints(eq)
cons = maybe_add_self_consistency(eq, cons)
con = ObjectiveFunction(cons)
obj = ObjectiveFunction(ForceBalance(eq))

lcp_scale_np = np.ones(eq.dim_x)
lcp_scale_np[eq.x_idx["L_lmn"]] *= 5

lcp_scale_jnp = jnp.ones(eq.dim_x)
lcp_scale_jnp = lcp_scale_jnp.at[eq.x_idx["L_lmn"]].multiply(5)

lcp = LinearConstraintProjection(obj, con, x_scale=lcp_scale_np)
lcp.build(verbose=3)
ValueError: The truth value of an array with more than one element is ambiguous. Use a.any() or a.all()

Same example with lcp_scale_jnp works fine.

Additionally, the user-supplied x_scale is overriden in the line which I think shouldn't happen.

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions