Skip to content

Commit

Permalink
Create separate CrossSectionParameters definition
Browse files Browse the repository at this point in the history
  • Loading branch information
daanboer committed Jun 5, 2024
1 parent dac73df commit e34864c
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 4 deletions.
6 changes: 2 additions & 4 deletions packages/schema/src/process/cross-section/cross-section.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,14 @@
import { z, ZodType } from "zod";
import { ProcessInfoBase } from "../process-info-base.js";
import { CrossSectionData } from "./data-types.js";
import { CrossSectionParameters } from "./parameters.js";

export const CrossSectionInfo = <ReferenceType extends z.ZodTypeAny>(
ReferenceType: ReferenceType,
) =>
ProcessInfoBase("CrossSection", CrossSectionData, ReferenceType).merge(
z.object({
parameters: z.object({
massRatio: z.number().positive().optional(),
statisticalWeightRatio: z.number().positive().optional(),
}).optional(),
parameters: CrossSectionParameters.optional(),
// TODO: Should this be nonnegative, i.e. how do we treat reverse processes?
threshold: z.number(),
}),
Expand Down
12 changes: 12 additions & 0 deletions packages/schema/src/process/cross-section/parameters.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
// SPDX-FileCopyrightText: LXCat team
//
// SPDX-License-Identifier: Apache-2.0

import { number, object, TypeOf } from "zod";

export const CrossSectionParameters = object({
massRatio: number().positive().optional(),
statisticalWeightRatio: number().positive().optional(),
});

export type CrossSectionParameters = TypeOf<typeof CrossSectionParameters>;
1 change: 1 addition & 0 deletions packages/schema/src/process/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
// SPDX-License-Identifier: Apache-2.0

export { CrossSectionInfo } from "./cross-section/cross-section.js";
export { CrossSectionParameters } from "./cross-section/parameters.js";
export { EditedProcess } from "./edited-process.js";
export { NewProcess } from "./new-process.js";
export { ProcessInfo } from "./process-info.js";
Expand Down

0 comments on commit e34864c

Please sign in to comment.