Felipe
February 28, 2025, 10:38am
1
Hi there,
I’m trying to make a Barton Bandis class in Python, however I can’t compile my code, it always gives me this error:
flac3d>model callback add update_friction_fault python
*** Python error: 'Unused extra parameter 2 (callback) found on command line.\n While processing line 0 of source Python interpreter.'
The problematic part of the code is here:
def __init__(
self,
interface_name: str,
JRC: float = 10.0,
JCS: float = 75000000.0,
phi_r: float = 15.0,
cycles_frequency: int = 50,
friction_max: float = 30.0,
tension_friction: float = 20.0
):
self.interface_name = interface_name
self.JRC = JRC
self.JCS = JCS
self.phi_r = phi_r
self.cycles_frequency = cycles_frequency
self.friction_max = friction_max
self.tension_friction = tension_friction
it.command(f"model callback add update_friction_{interface_name} python")
it.command(f"model callback modify update_friction_{interface_name} cycle {cycles_frequency}")
it.f2py_function_register(f"update_friction_{interface_name}", self.update_friction)
it.print_(f"[BartonBandis] Initialized for interface {interface_name}")
it.print_(f" JRC={JRC}, JCS={JCS}, phi_r={phi_r}°, freq={cycles_frequency} cycles")
How do I fix this? I’ve tried many things with no success. By the way, I’m using FLAC3D v9.0
Thanks in advance,
Felipe
msepu
February 28, 2025, 2:31pm
2
Hello!
I’m not sure if the command "model callback works… i’ve always used fish callback********
1 Like
Felipe
March 3, 2025, 2:42pm
3
I think I’m very close to make this Class Barton Bandis work.
The problem is precisely here I think:
def __init__(self, interface_name: str, JRC: float = 10.0,
JCS: float = 75e6, phi_r: float = 15.0,
friction_max: float = 30.0, tension_friction: float = 20.0,
update_freq: int = 50):
# Find interface
self.interface = None
for contact in it.contact.list():
if contact.name() == interface_name:
self.interface = contact
break
if not self.interface:
raise ValueError(f"Interface '{interface_name}' not found")
self.interface_name = interface_name
self.JRC = JRC
self.JCS = JCS
self.phi_r = phi_r
self.friction_max = friction_max
self.tension_friction = tension_friction
self.update_freq = update_freq
self._register_callback()
BartonBandis._instances[interface_name] = self
print(f"\nInitialized BartonBandis for '{interface_name}'")
def _register_callback(self):
"""FLAC3D callback registration using a module-level function"""
callback_name = f"bb_update_{self.interface_name}"
# Create a callback function with the interface name bound using functools.partial
callback_func = partial(bb_update_callback, interface_name=self.interface_name)
it.model().callback.add(callback_func, type='mechanical', name=callback_name)
it.model().callback.modify(callback_name, cycle=1)
When I invoke the class in my model:
model restore 'insitu.f3sav'
python import Barton_Bandis as bb
python bb.BartonBandis.clear_instances()
python bb.setup_barton_bandis_interfaces(fault_names=['fault', 'fault_chamber1', 'fault_chamber2', 'fault_chamber3', 'fault_corridor', 'fault_g1', 'fault_g2', 'fault_g3', 'fault_chamber_small'])
I get these errors in the Python console:
Success: Cleared all BartonBandis instances
Error: function takes exactly 2 arguments (1 given)
Error: function takes exactly 2 arguments (1 given)
Error: function takes exactly 2 arguments (1 given)
Error: function takes exactly 2 arguments (1 given)
Error: function takes exactly 2 arguments (1 given)
Error: function takes exactly 2 arguments (1 given)
Error: function takes exactly 2 arguments (1 given)
Error: function takes exactly 2 arguments (1 given)
Error: function takes exactly 2 arguments (1 given)
Configured 9 Barton-Bandis interfaces
Thanks!