guohanghui commited on
Commit
9ab5912
·
verified ·
1 Parent(s): 11c5a59

Update openmc/mcp_output/mcp_plugin/mcp_service.py

Browse files
openmc/mcp_output/mcp_plugin/mcp_service.py CHANGED
@@ -114,7 +114,10 @@ def create_material(
114
  def create_surface(
115
  surface_type: str,
116
  boundary_type: str = "transmission",
117
- **params
 
 
 
118
  ) -> dict:
119
  """
120
  Create an OpenMC surface.
@@ -122,10 +125,10 @@ def create_surface(
122
  Parameters:
123
  - surface_type: Type of surface (Sphere, ZCylinder, XPlane, YPlane, ZPlane, etc.)
124
  - boundary_type: Boundary condition (transmission, vacuum, reflective, periodic)
125
- - params: Surface-specific parameters:
126
- - For Sphere: x0, y0, z0, r (radius)
127
- - For ZCylinder: x0, y0, r
128
- - For XPlane/YPlane/ZPlane: x0/y0/z0
129
 
130
  Returns:
131
  - dict: Surface information.
@@ -134,30 +137,39 @@ def create_surface(
134
  return {"success": False, "result": None, "error": "OpenMC not available"}
135
 
136
  try:
137
- surface_classes = {
138
- "sphere": openmc.Sphere,
139
- "zcylinder": openmc.ZCylinder,
140
- "xcylinder": openmc.XCylinder,
141
- "ycylinder": openmc.YCylinder,
142
- "xplane": openmc.XPlane,
143
- "yplane": openmc.YPlane,
144
- "zplane": openmc.ZPlane,
145
- "xcone": openmc.XCone,
146
- "ycone": openmc.YCone,
147
- "zcone": openmc.ZCone,
148
- }
149
-
150
  surface_type_lower = surface_type.lower()
151
- if surface_type_lower not in surface_classes:
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
152
  return {
153
  "success": False,
154
  "result": None,
155
- "error": f"Unknown surface type: {surface_type}. Available: {list(surface_classes.keys())}"
156
  }
157
 
158
- surface_class = surface_classes[surface_type_lower]
159
- surface = surface_class(boundary_type=boundary_type, **params)
160
-
161
  return {
162
  "success": True,
163
  "result": {
 
114
  def create_surface(
115
  surface_type: str,
116
  boundary_type: str = "transmission",
117
+ x0: float = 0.0,
118
+ y0: float = 0.0,
119
+ z0: float = 0.0,
120
+ r: float = 1.0
121
  ) -> dict:
122
  """
123
  Create an OpenMC surface.
 
125
  Parameters:
126
  - surface_type: Type of surface (Sphere, ZCylinder, XPlane, YPlane, ZPlane, etc.)
127
  - boundary_type: Boundary condition (transmission, vacuum, reflective, periodic)
128
+ - x0: X coordinate of center (for Sphere, XCylinder) or position (for XPlane)
129
+ - y0: Y coordinate of center (for Sphere, YCylinder) or position (for YPlane)
130
+ - z0: Z coordinate of center (for Sphere, ZCylinder) or position (for ZPlane)
131
+ - r: Radius (for Sphere, Cylinder surfaces)
132
 
133
  Returns:
134
  - dict: Surface information.
 
137
  return {"success": False, "result": None, "error": "OpenMC not available"}
138
 
139
  try:
 
 
 
 
 
 
 
 
 
 
 
 
 
140
  surface_type_lower = surface_type.lower()
141
+ surface = None
142
+ params = {}
143
+
144
+ if surface_type_lower == "sphere":
145
+ surface = openmc.Sphere(x0=x0, y0=y0, z0=z0, r=r, boundary_type=boundary_type)
146
+ params = {"x0": x0, "y0": y0, "z0": z0, "r": r}
147
+ elif surface_type_lower == "zcylinder":
148
+ surface = openmc.ZCylinder(x0=x0, y0=y0, r=r, boundary_type=boundary_type)
149
+ params = {"x0": x0, "y0": y0, "r": r}
150
+ elif surface_type_lower == "xcylinder":
151
+ surface = openmc.XCylinder(y0=y0, z0=z0, r=r, boundary_type=boundary_type)
152
+ params = {"y0": y0, "z0": z0, "r": r}
153
+ elif surface_type_lower == "ycylinder":
154
+ surface = openmc.YCylinder(x0=x0, z0=z0, r=r, boundary_type=boundary_type)
155
+ params = {"x0": x0, "z0": z0, "r": r}
156
+ elif surface_type_lower == "xplane":
157
+ surface = openmc.XPlane(x0=x0, boundary_type=boundary_type)
158
+ params = {"x0": x0}
159
+ elif surface_type_lower == "yplane":
160
+ surface = openmc.YPlane(y0=y0, boundary_type=boundary_type)
161
+ params = {"y0": y0}
162
+ elif surface_type_lower == "zplane":
163
+ surface = openmc.ZPlane(z0=z0, boundary_type=boundary_type)
164
+ params = {"z0": z0}
165
+ else:
166
+ available = ["sphere", "zcylinder", "xcylinder", "ycylinder", "xplane", "yplane", "zplane"]
167
  return {
168
  "success": False,
169
  "result": None,
170
+ "error": f"Unknown surface type: {surface_type}. Available: {available}"
171
  }
172
 
 
 
 
173
  return {
174
  "success": True,
175
  "result": {