# Weld-neck flange

Single forged weld-neck flange: tapered hub from the B16.5 / B16.47 hub diameter down to the pipe OD, B16.25 37.5° weld bevel with root land, bore matched to the pipe schedule and real drilled bolt holes. Raised face with a serrated finish, flat face, or ring-type joint with the B16.5 octagonal groove for the class. Optional butt-welded pipe stub; the rim carries a stamped marking.

**Standards:** ASME B16.5, ASME B16.47 Series A, ASME B16.25, ASME B16.20, MSS SP-25

## Installation

```bash
npx -y https://decktwin.com/cli/deck-twin-0.2.2.tgz add weld-neck-flange
```

Copies `piping/weld-neck-flange.tsx`, any helper files it imports and the shared `lib/` into `src/components/deck-twin/`. Needs `three`, `@react-three/fiber` and `@react-three/drei`.

## Usage

```tsx
import { Canvas } from '@react-three/fiber'
import { OrbitControls } from '@react-three/drei'
import { Stage } from './components/deck-twin/lib/stage'
import { WeldNeckFlange } from './components/deck-twin/piping/weld-neck-flange'

export default function Scene() {
  return (
    <Canvas shadows camera={{ position: [8, 5, 9], fov: 35 }}>
      <Stage>
        <WeldNeckFlange />
      </Stage>
      <OrbitControls makeDefault />
    </Canvas>
  )
}
```

## Props

| Prop | Type | Default | Range |
| --- | --- | --- | --- |
| `nps` | `number (NPS, in)` | `6` |  |
| `rating` | `150 \| 300 \| 600 \| 900 \| 1500 \| 2500` | `300` |  |
| `facing` | `"RF" \| "FF" \| "RTJ"` | `"RF"` |  |
| `schedule` | `"10" \| "20" \| "40" \| "STD" \| "80" \| "XS" \| "160" \| "XXS" \| "10S" \| "40S" \| "80S"` | `"40"` |  |
| `stub` | `number (m)` | `0` | 0 – 1 |
| `tag` | `string` | `""` |  |
| `...group` | position, rotation, scale… |  |  |

## Ports

Flange faces in the component's local frame, metres. Origin: pipe centreline, flow along X.

| Id | Label | Position | Direction | Size | Class |
| --- | --- | --- | --- | --- | --- |
| `A` | Flange face | 0.000, 0.000, 0.000 | -1, 0, 0 | 6" | 300 |

## P&ID

In section: a flange disc with a long tapered hub narrowing to the pipe wall and a butt weld at the hub end. On P&IDs just a short bar across the line; on isometrics a bar with a weld dot.

tag WN · ASME B16.5 flange types drawn in half-section (GA / isometric detail convention); on P&IDs every flange is a short bar

The flange type comes from the piping class, not the P&ID. The long taper identifies weld-neck; slip-on and socket-weld have short hubs; lap-joint has a loose ring on a stub end.

Piping class / flange bill of materials (ASME B16.5 / B16.47) fields and the props they set:

| Field | Prop |
| --- | --- |
| Nominal size | `nps` |
| Pressure class | `rating` |
| Facing | `facing` |
| Bore (schedule) | `schedule` |
| Tag number | `tag` |

## Typical suppliers

All Metals & Forge Group. The geometry is generic and sized from public standards. It is not vendor CAD.

## Source

`piping/weld-neck-flange.tsx`. This is the component file only: it imports shared code, so install it with the command above rather than pasting it alone. https://decktwin.com/r/weld-neck-flange.json has every file.

```tsx
// Weld-neck flange: ASME B16.5 / B16.47 Series A forged WN flange with tapered hub, B16.25 bevelled weld end, RF / FF / RTJ facing and drilled bolt holes.
import type { Kit } from '../lib/kit'
import { KitMesh, useKit, type GroupProps } from '../lib/mesh'
import { port, type Port } from '../lib/ports'
import { pipeOD, pipeWall, type Rating, type Schedule } from '../lib/standards'
import { buttWeld, facingHeight, looseFlange, marking, pipeStub, type Facing } from './_flanges'

export interface WeldNeckFlangeProps {
  /** nominal pipe size, inches */
  nps?: number
  rating?: Rating
  facing?: Facing
  /** pipe schedule matched by the bore */
  schedule?: Schedule
  /** pipe butt-welded to the weld end, m (0 shows the bevel) */
  stub?: number
  /** stamped marking, empty for the standard marking */
  tag?: string
}

export const defaults = { nps: 6, rating: 300 as Rating, facing: 'RF' as Facing, schedule: '40' as Schedule, stub: 0, tag: '' }

// Port A is the gasket face at the origin, pointing -X; the hub runs along +X.
export function ports(p: WeldNeckFlangeProps = {}): Port[] {
  const { nps, rating } = { ...defaults, ...p }
  return [port('A', 'Flange face', [0, 0, 0], [-1, 0, 0], nps, rating)]
}

export function WeldNeckFlange({ nps = defaults.nps, rating = defaults.rating, facing = defaults.facing, schedule = defaults.schedule, stub = defaults.stub, tag = defaults.tag, ...group }: WeldNeckFlangeProps & GroupProps) {
  const data = useKit((k) => build(k, nps, rating, facing, schedule, Math.max(0, stub), tag), [nps, rating, facing, schedule, stub, tag])
  return (
    <group {...group}>
      <KitMesh data={data} />
    </group>
  )
}

export default WeldNeckFlange

function build(k: Kit, nps: number, rating: Rating, facing: Facing, schedule: Schedule, stub: number, tag: string) {
  const h = facingHeight(facing, nps, rating)
  const i = looseFlange(k, [h, 0, 0], [-1, 0, 0], { kind: 'WN', nps, rating, facing, schedule, marking: tag || marking('WN', nps, rating, facing, `SCH ${schedule}`) })
  if (stub > 0) {
    const x = h + i.Y
    pipeStub(k, [x, 0, 0], [1, 0, 0], stub, nps, schedule, 'open', 'bevel')
    buttWeld(k, [x, 0, 0], [1, 0, 0], pipeOD(nps) / 2, pipeWall(nps, schedule))
  }
}
```
