diff --git a/src/gsim/palace/models/problems.py b/src/gsim/palace/models/problems.py index 65261376..0ba1e6b4 100644 --- a/src/gsim/palace/models/problems.py +++ b/src/gsim/palace/models/problems.py @@ -322,10 +322,11 @@ def to_palace_config(self) -> dict: "Freq": self.freq / 1e9, "N": self.num_modes, "Save": self.save, - "Target": self.target, "Tol": self.tolerance, "Type": self.solver_type, } + if self.target > 0: # Palace requires Target > 0 when present; 0 means auto + config["Target"] = self.target if ( self.max_size > 0 ): # Even when the default is zero, passing it explicitly makes Palace fail diff --git a/tests/palace/test_boundarymode_models.py b/tests/palace/test_boundarymode_models.py index efc6e027..d346d969 100644 --- a/tests/palace/test_boundarymode_models.py +++ b/tests/palace/test_boundarymode_models.py @@ -53,3 +53,9 @@ def test_to_palace_config(self): assert result["MaxSize"] == 80 assert result["Type"] == "SLEPc" assert "Attributes" not in result + + def test_to_palace_config_omits_auto_target(self): + """target=0 means automatic shift, so Target is left out of the config.""" + result = BoundaryModeConfig(freq=50e9, num_modes=2, save=2).to_palace_config() + assert "Target" not in result + assert "MaxSize" not in result