完善AMESim组件界面与仿真求解稳定性

This commit is contained in:
ljz committed 2026-08-02 00:57:48 +08:00
1 parent e7177ab03e
commit 410ef535e8
34 files changed
+3340 -251

No files matched your search

@@ -0,0 +1,15 @@
import { SYMBOL_ACCENT, SYMBOL_STROKE, SymbolSvg } from "./primitives";
export function AmesimPnpl01Symbol() {
return (
<SymbolSvg domain="pneumatic">
<path d="M2 24h34" stroke={SYMBOL_STROKE} strokeWidth="2" />
<path
d="m35 17 14 14m0-14L35 31"
stroke={SYMBOL_ACCENT}
strokeLinecap="round"
strokeWidth="3"
/>
</SymbolSvg>
);
}
@@ -0,0 +1,217 @@
import {
SYMBOL_ACCENT,
SYMBOL_FILL,
SYMBOL_MUTED,
SYMBOL_STROKE,
SymbolSvg,
} from "./primitives";
const MECHANICAL_LINE_WIDTH = 1.8;
const mechanicalStroke = {
fill: "none",
stroke: SYMBOL_STROKE,
strokeLinecap: "round" as const,
strokeLinejoin: "round" as const,
strokeWidth: MECHANICAL_LINE_WIDTH,
};
function MechanicalSocket({ side }: { side: "left" | "right" }) {
const facingLeft = side === "left";
return (
<g {...mechanicalStroke}>
<path d={facingLeft ? "M2 24h7" : "M55 24h7"} />
<path d={facingLeft ? "M15 19H9v10h6" : "M49 19h6v10h-6"} />
</g>
);
}
function GuideHatching({ y, upward }: { y: number; upward: boolean }) {
const direction = upward ? -1 : 1;
return (
<g stroke={SYMBOL_MUTED} strokeWidth="1">
{[14, 22, 30, 38, 46].map((x) => (
<path
d={`M${x - 3} ${y + direction * 3}L${x + 3} ${y - direction * 3}`}
key={x}
/>
))}
</g>
);
}
export function AmesimF000Symbol() {
return (
<SymbolSvg className="component-symbol-amesim-f000" domain="mechanical">
<path d="M41 24h21" {...mechanicalStroke} />
<rect
fill={SYMBOL_FILL}
height="28"
rx="1"
stroke={SYMBOL_STROKE}
strokeWidth="2.2"
width="18"
x="23"
y="12"
/>
<path d="M27 26h10" stroke={SYMBOL_ACCENT} strokeWidth="2" />
</SymbolSvg>
);
}
export function AmesimForcSymbol() {
return (
<SymbolSvg className="component-symbol-amesim-forc" domain="mechanical">
<g
fill="none"
stroke={SYMBOL_ACCENT}
strokeLinecap="round"
strokeLinejoin="round"
strokeWidth="1.8"
>
<path d="M2 24h15" />
<path d="m11 19 6 5-6 5" />
</g>
<circle
cx="32"
cy="24"
fill={SYMBOL_FILL}
r="12"
stroke={SYMBOL_STROKE}
strokeWidth="2"
/>
<text
dominantBaseline="central"
fill={SYMBOL_STROKE}
fontFamily="Arial, sans-serif"
fontSize="13"
fontWeight="600"
textAnchor="middle"
x="32"
y="24"
>
F
</text>
<path d="M44 24h6M50 18v12M50 18h8M50 30h8M58 18v12M58 24h4" {...mechanicalStroke} />
</SymbolSvg>
);
}
export function AmesimMecmas21Symbol() {
return (
<SymbolSvg className="component-symbol-amesim-mecmas21" domain="mechanical">
<GuideHatching upward y={5} />
<GuideHatching upward={false} y={43} />
<path d="M10 8h44M10 40h44" stroke={SYMBOL_MUTED} strokeWidth="1.3" />
<MechanicalSocket side="left" />
<MechanicalSocket side="right" />
<rect
fill={SYMBOL_FILL}
height="26"
rx="1"
stroke={SYMBOL_STROKE}
strokeWidth="2"
width="34"
x="15"
y="11"
/>
<text
dominantBaseline="central"
fill={SYMBOL_STROKE}
fontFamily="Arial, sans-serif"
fontSize="12"
fontWeight="600"
textAnchor="middle"
x="31"
y="28"
>
M
</text>
<path
d="M22 18h15m-5-4 5 4-5 4"
fill="none"
stroke={SYMBOL_ACCENT}
strokeLinecap="round"
strokeLinejoin="round"
strokeWidth="1.8"
/>
</SymbolSvg>
);
}
export function AmesimLstp00aSymbol() {
return (
<SymbolSvg className="component-symbol-amesim-lstp00a" domain="mechanical">
<path d="M2 24h8M54 24h8" {...mechanicalStroke} />
<g transform="rotate(90 32 24)">
<path d="M32 2v7M32 39v7" {...mechanicalStroke} />
<path d="M27 9V5h10v4M27 39v4h10v-4" {...mechanicalStroke} />
<rect
fill={SYMBOL_FILL}
height="3"
stroke={SYMBOL_STROKE}
strokeWidth="1.6"
width="46"
x="9"
y="10"
/>
<rect
fill={SYMBOL_FILL}
height="3"
stroke={SYMBOL_STROKE}
strokeWidth="1.6"
width="46"
x="9"
y="31"
/>
<rect
fill={SYMBOL_FILL}
height="3"
stroke={SYMBOL_STROKE}
strokeWidth="1.6"
width="46"
x="9"
y="39"
/>
<path
d="M14 13v4c0 2 12 2 12 4s-12 2-12 4 12 2 12 6"
fill="none"
stroke={SYMBOL_ACCENT}
strokeLinecap="round"
strokeLinejoin="round"
strokeWidth="2"
/>
<path d="M36 18v-5M36 18h14v6H36v7M40 22h6" {...mechanicalStroke} />
</g>
</SymbolSvg>
);
}
export function AmesimLmechn1Symbol() {
const leftPortRows = [7, 12, 17, 22, 27, 32, 37, 42];
return (
<SymbolSvg className="component-symbol-amesim-lmechn1" domain="mechanical">
<rect
fill={SYMBOL_FILL}
height="44"
rx="1"
stroke={SYMBOL_STROKE}
strokeWidth="1.8"
width="12"
x="27"
y="2"
/>
{leftPortRows.map((y) => (
<path
d={`M5 ${y}h22`}
key={y}
stroke={SYMBOL_STROKE}
strokeLinecap="round"
strokeWidth="1.4"
/>
))}
<path d="M39 24h20" stroke={SYMBOL_STROKE} strokeWidth="1.8" />
<circle cx="33" cy="24" fill={SYMBOL_ACCENT} r="2.2" />
</SymbolSvg>
);
}
+38
View File
@@ -0,0 +1,38 @@
import { SYMBOL_ACCENT, SYMBOL_FILL, SYMBOL_STROKE, SymbolSvg } from "./primitives";
function MediumSymbol({ label }: { label: "Air" | "He" }) {
return (
<SymbolSvg className="component-symbol-medium-svg" domain="medium">
<circle
cx="32"
cy="24"
fill={SYMBOL_FILL}
r="21"
stroke={SYMBOL_STROKE}
strokeWidth="2"
/>
<text
className="component-symbol-medium-label"
data-symbol-label={label}
dominantBaseline="central"
fill={SYMBOL_ACCENT}
fontFamily="Arial, sans-serif"
fontSize={label === "Air" ? 12 : 16}
fontWeight="500"
textAnchor="middle"
x="32"
y="24"
>
{label}
</text>
</SymbolSvg>
);
}
export function AmesimIdealAirMediumSymbol() {
return <MediumSymbol label="Air" />;
}
export function AmesimHeliumMediumSymbol() {
return <MediumSymbol label="He" />;
}
+233
View File
@@ -0,0 +1,233 @@
import {
SYMBOL_ACCENT,
SYMBOL_FILL,
SYMBOL_MUTED,
SYMBOL_STROKE,
SymbolSvg,
} from "./primitives";
const PNEUMATIC_STROKE_WIDTH = 1.7;
function OrificeBody({
centerY = 25,
leftPortY = centerY,
}: {
centerY?: number;
leftPortY?: number;
}) {
const top = centerY - 10;
const bottom = centerY + 10;
const leftConnector =
leftPortY === centerY
? `M2 ${centerY}h18`
: `M2 ${leftPortY}h14L20 ${centerY}`;
return (
<>
<path
d={`${leftConnector}M44 ${centerY}h18M20 ${centerY}h24`}
stroke={SYMBOL_STROKE}
strokeLinecap="round"
strokeWidth={PNEUMATIC_STROKE_WIDTH}
/>
<path
d={`M20 ${top}c5 6 9 7 12 7s7-1 12-7M20 ${bottom}c5-6 9-7 12-7s7 1 12 7`}
stroke={SYMBOL_STROKE}
strokeLinecap="round"
strokeWidth={PNEUMATIC_STROKE_WIDTH}
/>
</>
);
}
/** Constant-coefficient pneumatic orifice (AMESim PNOR001). */
export function AmesimPnor001Symbol() {
return (
<SymbolSvg className="component-symbol-amesim-pnor001-svg" domain="pneumatic">
<OrificeBody centerY={24} />
</SymbolSvg>
);
}
/** PNVO001 convenience variant whose opening is fixed by a parameter. */
export function AmesimPnvo001FixedSymbol() {
return (
<SymbolSvg
className="component-symbol-amesim-pnvo001-fixed-svg"
domain="pneumatic"
>
<OrificeBody centerY={28} />
<path
d="M43 4 34 20m9-16-2 7-5-3"
stroke={SYMBOL_ACCENT}
strokeLinecap="round"
strokeLinejoin="round"
strokeWidth="1.7"
/>
</SymbolSvg>
);
}
/** Signal-modulated pneumatic orifice (AMESim PNVO001 / pn_morifice). */
export function AmesimPnvo001SignalSymbol() {
return (
<SymbolSvg
className="component-symbol-amesim-pnvo001-signal-svg"
domain="pneumatic"
>
<OrificeBody centerY={25} leftPortY={32} />
<path
d="M2 16h11l21 5m0 0-7-1m7 1-5 5"
stroke={SYMBOL_ACCENT}
strokeLinecap="round"
strokeLinejoin="round"
strokeWidth="1.7"
/>
</SymbolSvg>
);
}
type PipeSection = "C" | "R";
function PipeNetworkBody({ sections }: { sections: readonly PipeSection[] }) {
const left = 9;
const right = 55;
const top = 13;
const bottom = 35;
const sectionWidth = (right - left) / sections.length;
return (
<>
<path
d="M2 24h7M55 24h7"
stroke={SYMBOL_STROKE}
strokeLinecap="round"
strokeWidth={PNEUMATIC_STROKE_WIDTH}
/>
<rect
fill={SYMBOL_FILL}
height={bottom - top}
rx="2"
stroke={SYMBOL_STROKE}
strokeWidth={PNEUMATIC_STROKE_WIDTH}
width={right - left}
x={left}
y={top}
/>
{sections.slice(1).map((_, index) => {
const x = left + sectionWidth * (index + 1);
return (
<path
d={`M${x} ${top + 2}v${bottom - top - 4}`}
key={x}
stroke={SYMBOL_MUTED}
strokeWidth="1.1"
/>
);
})}
{sections.map((section, index) => (
<text
dominantBaseline="central"
fill={section === "R" ? SYMBOL_ACCENT : SYMBOL_MUTED}
fontFamily="Arial, sans-serif"
fontSize="9"
fontWeight="700"
key={`${section}-${index}`}
textAnchor="middle"
x={left + sectionWidth * (index + 0.5)}
y="24"
>
{section}
</text>
))}
</>
);
}
/** Pure pneumatic resistance line (AMESim PNL00R). */
export function AmesimPnl00rSymbol() {
return (
<SymbolSvg className="component-symbol-amesim-pnl00r-svg" domain="pneumatic">
<PipeNetworkBody sections={["R"]} />
</SymbolSvg>
);
}
/** C-R dynamic pneumatic line (AMESim PNL0001). */
export function AmesimPnl0001Symbol() {
return (
<SymbolSvg className="component-symbol-amesim-pnl0001-svg" domain="pneumatic">
<PipeNetworkBody sections={["C", "R"]} />
</SymbolSvg>
);
}
/** R-C-R dynamic pneumatic line (AMESim PNL0002). */
export function AmesimPnl0002Symbol() {
return (
<SymbolSvg className="component-symbol-amesim-pnl0002-svg" domain="pneumatic">
<PipeNetworkBody sections={["R", "C", "R"]} />
</SymbolSvg>
);
}
/** C-R-C dynamic pneumatic line (AMESim PNL0003). */
export function AmesimPnl0003Symbol() {
return (
<SymbolSvg className="component-symbol-amesim-pnl0003-svg" domain="pneumatic">
<PipeNetworkBody sections={["C", "R", "C"]} />
</SymbolSvg>
);
}
function JunctionTerminal({ x, y }: { x: number; y: number }) {
return (
<circle
cx={x}
cy={y}
fill={SYMBOL_FILL}
r="2"
stroke={SYMBOL_STROKE}
strokeWidth="1.3"
/>
);
}
/** Three-port pneumatic junction with one inlet-side and two outlet-side ports. */
export function AmesimPn3Node2Symbol() {
return (
<SymbolSvg className="component-symbol-amesim-pn3node2-svg" domain="pneumatic">
<path
d="M4 24h25M29 24C41 24 42 12 60 12M29 24c12 0 13 12 31 12"
stroke={SYMBOL_STROKE}
strokeLinecap="round"
strokeLinejoin="round"
strokeWidth={PNEUMATIC_STROKE_WIDTH}
/>
<circle cx="29" cy="24" fill={SYMBOL_ACCENT} r="3" />
<JunctionTerminal x={3} y={24} />
<JunctionTerminal x={61} y={12} />
<JunctionTerminal x={61} y={36} />
</SymbolSvg>
);
}
/** Four-port pneumatic junction with one inlet-side and three outlet-side ports. */
export function AmesimP4Node2Symbol() {
return (
<SymbolSvg className="component-symbol-amesim-p4node2-svg" domain="pneumatic">
<path
d="M4 24h24M28 24C40 24 42 8 60 8M28 24h32M28 24c12 0 14 16 32 16"
stroke={SYMBOL_STROKE}
strokeLinecap="round"
strokeLinejoin="round"
strokeWidth={PNEUMATIC_STROKE_WIDTH}
/>
<circle cx="28" cy="24" fill={SYMBOL_ACCENT} r="3" />
<JunctionTerminal x={3} y={24} />
<JunctionTerminal x={61} y={8} />
<JunctionTerminal x={61} y={24} />
<JunctionTerminal x={61} y={40} />
</SymbolSvg>
);
}
@@ -0,0 +1,41 @@
import type { ReactNode } from "react";
export type SymbolDomain =
| "neutral"
| "pneumatic"
| "mechanical"
| "signal"
| "medium";
type SymbolSvgProps = {
children: ReactNode;
className?: string;
domain?: SymbolDomain;
viewBox?: string;
};
export const SYMBOL_STROKE = "var(--component-symbol-stroke, currentColor)";
export const SYMBOL_FILL = "var(--component-symbol-fill, #ffffff)";
export const SYMBOL_ACCENT = "var(--component-symbol-accent, currentColor)";
export const SYMBOL_MUTED = "var(--component-symbol-muted, #64748b)";
export function SymbolSvg({
children,
className,
domain = "neutral",
viewBox = "0 0 64 48",
}: SymbolSvgProps) {
return (
<svg
aria-hidden="true"
className={["component-symbol-svg", className].filter(Boolean).join(" ")}
data-symbol-domain={domain}
fill="none"
focusable="false"
viewBox={viewBox}
xmlns="http://www.w3.org/2000/svg"
>
{children}
</svg>
);
}
+71
View File
@@ -0,0 +1,71 @@
import {
SYMBOL_ACCENT,
SYMBOL_FILL,
SYMBOL_STROKE,
SymbolSvg,
} from "./primitives";
const SIGNAL_LINE_WIDTH = 1.8;
function SignalOutput() {
return (
<g
fill="none"
stroke={SYMBOL_STROKE}
strokeLinecap="round"
strokeLinejoin="round"
strokeWidth={SIGNAL_LINE_WIDTH}
>
<path d="M46 24h14" />
<path d="m54 20 6 4-6 4" />
</g>
);
}
export function AmesimStep0Symbol() {
return (
<SymbolSvg className="component-symbol-amesim-step0" domain="signal">
<circle
cx="27"
cy="24"
fill={SYMBOL_FILL}
r="18"
stroke={SYMBOL_STROKE}
strokeWidth={SIGNAL_LINE_WIDTH}
/>
<path
d="M14 30h8V17h18"
fill="none"
stroke={SYMBOL_ACCENT}
strokeLinecap="square"
strokeLinejoin="miter"
strokeWidth="2.2"
/>
<SignalOutput />
</SymbolSvg>
);
}
export function AmesimUd00Symbol() {
return (
<SymbolSvg className="component-symbol-amesim-ud00" domain="signal">
<circle
cx="27"
cy="24"
fill={SYMBOL_FILL}
r="18"
stroke={SYMBOL_STROKE}
strokeWidth={SIGNAL_LINE_WIDTH}
/>
<path
d="M13 30h5l5-10h5l5-9 5 19h3"
fill="none"
stroke={SYMBOL_ACCENT}
strokeLinecap="round"
strokeLinejoin="round"
strokeWidth="2.2"
/>
<SignalOutput />
</SymbolSvg>
);
}
+69
View File
@@ -0,0 +1,69 @@
import {
SYMBOL_ACCENT,
SYMBOL_FILL,
SYMBOL_STROKE,
SymbolSvg,
} from "./primitives";
function ChamberCore({ variable }: { variable: boolean }) {
return (
<>
<circle
cx="32"
cy="24"
fill={SYMBOL_FILL}
r="13"
stroke={SYMBOL_STROKE}
strokeWidth="2"
/>
<text
dominantBaseline="central"
fill={SYMBOL_ACCENT}
fontFamily="Arial, sans-serif"
fontSize="13"
fontWeight="700"
textAnchor="middle"
x="32"
y="24"
>
Cp
</text>
{variable ? (
<g
fill="none"
stroke={SYMBOL_ACCENT}
strokeLinecap="round"
strokeLinejoin="round"
strokeWidth="1.5"
>
<path d="m20 13-5-5m0 0h4m-4 0v4" />
<path d="m44 13 5-5m0 0h-4m4 0v4" />
<path d="m20 35-5 5m0 0h4m-4 0v-4" />
<path d="m44 35 5 5m0 0h-4m4 0v-4" />
</g>
) : null}
</>
);
}
export function AmesimPnch023Symbol() {
return (
<SymbolSvg domain="pneumatic">
<path d="M2 24h17M45 24h17" stroke={SYMBOL_STROKE} strokeWidth="2" />
<ChamberCore variable={false} />
</SymbolSvg>
);
}
export function AmesimPnch012Symbol() {
return (
<SymbolSvg domain="pneumatic">
<path
d="M2 16h17M2 32h17M45 16h17M45 32h17"
stroke={SYMBOL_STROKE}
strokeWidth="2"
/>
<ChamberCore variable />
</SymbolSvg>
);
}
+8
View File
@@ -0,0 +1,8 @@
import type { ReactNode } from "react";
export type ComponentSymbolPresentation = "framed" | "bare";
export type SymbolDefinition = {
presentation: ComponentSymbolPresentation;
render: () => ReactNode;
};