> ## Documentation Index
> Fetch the complete documentation index at: https://docs.fincept.in/llms.txt
> Use this file to discover all available pages before exploring further.

# Simulate Ising Model

> Simulates a 2D Ising model using Metropolis-Hastings Monte Carlo sampling. The Ising model describes interacting binary spins and exhibits phase transitions, making it useful for modeling collective behavior in financial systems, agent-based models, correlation structure, and systemic risk. Returns energy and magnetization of equilibrium configuration.

**Use Cases:**
- Model herd behavior and market sentiment cascades
- Study phase transitions in financial crises
- Analyze correlation breakdown during stress
- Agent-based market simulations
- Systemic risk and contagion modeling

**Formula:** E = -J Σ s_i s_j - h Σ s_i (spins s_i = ±1)

**Credits:** 5 credits per request (Pro Tier) [Tier: ENTERPRISE, Credits: 10]



## OpenAPI

````yaml api-specs/physics.json post /quantlib/physics/ising
openapi: 3.1.0
info:
  title: FinceptQuantLib API - Physics Module
  description: >-
    Physics and Information Theory module for FinceptQuantLib API. Includes
    Shannon/Renyi/Tsallis entropy, KL/JS divergence, mutual information,
    transfer entropy, Fisher information, Boltzmann distribution, Ising model,
    maximum entropy, thermodynamics (free energy, Carnot cycle, van der Waals
    equation), and Maxwell relations. **Pro Tier required. 5 credits per
    request.**
  version: 3.0.0
  contact:
    name: Fincept API Support
    url: https://fincept.in
servers:
  - url: https://api.fincept.in
    description: Fincept API Production Server
security:
  - APIKeyHeader: []
tags:
  - name: quantlib-physics
    description: Physics and Information Theory module for FinceptQuantLib API
    x-displayName: Physics
paths:
  /quantlib/physics/ising:
    post:
      tags:
        - quantlib-physics
      summary: Simulate Ising Model
      description: >-
        Simulates a 2D Ising model using Metropolis-Hastings Monte Carlo
        sampling. The Ising model describes interacting binary spins and
        exhibits phase transitions, making it useful for modeling collective
        behavior in financial systems, agent-based models, correlation
        structure, and systemic risk. Returns energy and magnetization of
        equilibrium configuration.


        **Use Cases:**

        - Model herd behavior and market sentiment cascades

        - Study phase transitions in financial crises

        - Analyze correlation breakdown during stress

        - Agent-based market simulations

        - Systemic risk and contagion modeling


        **Formula:** E = -J Σ s_i s_j - h Σ s_i (spins s_i = ±1)


        **Credits:** 5 credits per request (Pro Tier) [Tier: ENTERPRISE,
        Credits: 10]
      operationId: ising_model
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              properties:
                size:
                  type: integer
                  description: Grid size (creates size × size lattice)
                  default: 10
                  example: 20
                J:
                  type: number
                  description: >-
                    Coupling constant (J>0: ferromagnetic/positive correlation,
                    J<0: antiferromagnetic)
                  default: 1
                  example: 1
                h:
                  type: number
                  description: External field (bias toward +1 or -1 spins)
                  default: 0
                  example: 0
                temperature:
                  type: number
                  description: >-
                    Temperature (T<Tc: ordered phase, T>Tc: disordered phase,
                    Tc≈2.27 for J=1)
                  default: 2
                  example: 2.5
                n_steps:
                  type: integer
                  description: Number of Monte Carlo steps for equilibration
                  default: 1000
                  example: 5000
                seed:
                  type: integer
                  description: Random seed for reproducibility (optional)
                  nullable: true
                  example: 42
            examples:
              ordered_phase:
                summary: Low temperature (ordered, correlated)
                value:
                  size: 20
                  J: 1
                  h: 0
                  temperature: 1.5
                  n_steps: 5000
                  seed: 42
              critical_point:
                summary: Near critical temperature (phase transition)
                value:
                  size: 30
                  J: 1
                  h: 0
                  temperature: 2.27
                  n_steps: 10000
      responses:
        '200':
          description: Ising model simulation completed successfully
          content:
            application/json:
              schema:
                type: object
                properties:
                  success:
                    type: boolean
                    example: true
                  data:
                    type: object
                    properties:
                      energy:
                        type: number
                        description: Total energy of equilibrium configuration
                        example: -756
                      magnetization:
                        type: number
                        description: >-
                          Net magnetization (between -1 and +1, measures
                          alignment)
                        example: 0.842
                      size:
                        type: integer
                        description: Grid size used
                        example: 20
                      temperature:
                        type: number
                        description: Temperature parameter
                        example: 1.5
        '401':
          $ref: '#/components/responses/UnauthorizedError'
        '402':
          $ref: '#/components/responses/InsufficientCreditsError'
        '422':
          $ref: '#/components/responses/ValidationError'
components:
  responses:
    UnauthorizedError:
      description: Authentication information is missing or invalid
      content:
        application/json:
          schema:
            type: object
            properties:
              detail:
                type: string
                example: Invalid API key
    InsufficientCreditsError:
      description: Insufficient API credits
      content:
        application/json:
          schema:
            type: object
            properties:
              detail:
                type: string
                example: Insufficient credits. This endpoint requires 5 credits.
    ValidationError:
      description: Request validation error
      content:
        application/json:
          schema:
            type: object
            properties:
              detail:
                type: array
                items:
                  type: object
                  properties:
                    loc:
                      type: array
                      items:
                        type: string
                    msg:
                      type: string
                    type:
                      type: string
  securitySchemes:
    APIKeyHeader:
      type: apiKey
      in: header
      name: X-API-Key
      description: >-
        API key for authentication. Get your key at
        https://api.fincept.in/auth/register

````