diff --git a/.axxtermcolors b/.axxtermcolors index 61cd27c..49709ec 100644 --- a/.axxtermcolors +++ b/.axxtermcolors @@ -17,6 +17,17 @@ function not_shell_code() { fg=#ABCDEF # master/main branch overrides + bg.escli-preset-engine-configs=#124F56 bg!engine-sim-cli.claude=#46a866 fg!engine-sim-cli.claude=#000000 + + # master/main branch overrides + bg!engine-sim-cli.preset=#558844 + bg#preset-engine-config=#668866 + fg!engine-sim-cli.preset=#dddddd + + # master/main branch overrides + bg!engine-sim-bridge=#222231 + fg!engine-sim-bridge=#000000 + } \ No newline at end of file diff --git a/.github/ARCH-005-ios-app.md b/.github/ARCH-005-ios-app.md index 7a720f7..2d229c8 100644 --- a/.github/ARCH-005-ios-app.md +++ b/.github/ARCH-005-ios-app.md @@ -139,4 +139,97 @@ Building an iOS application using the engine-sim-bridge library for real-time en --- +--- + +### 5. Build System and CMake Integration + +**Decision:** Implement iOS build infrastructure with CMake static library and Xcode project +- **Rationale:** Two-stage build enables iOS static library generation while maintaining Xcode project for SwiftUI app development +- **Status:** IMPLEMENTED (CMakeLists.txt, ios.toolchain.cmake, escli-ios/Makefile) +- **Implementation Details:** + - **CMakeLists.txt**: iOS early-return to skip CLI targets, static library generation + - **ios.toolchain.cmake**: iOS cross-compilation toolchain for arm64/iPhoneOS and simulator + - **escli-ios/Makefile**: Two-click build system (ios-lib, ios, xcode targets) + - **Static Library**: CMake builds libengine-sim-bridge.a for iOS platform + - **Xcode Integration**: Xcode project links static library to iOS app + - **Build Status**: Zero errors, all 4 test suites pass (smoke, integration, unit, telemetry) + +**Build Infrastructure Components:** +- **CMake Configuration**: iOS conditional compilation, TARGET_OS_IPHONE guards +- **Toolchain**: Support for iPhoneOS (arm64) and iOS Simulator (x86_64/arm64) +- **Makefile Targets**: + - `make ios-lib`: Build static library for iOS platform + - `make ios`: Build iOS SwiftUI app + - `make xcode`: Open Xcode project for development +- **Two-Stage Build**: CMake → static library → Xcode → iOS app + +**Test Results:** +- All 4 test suites pass (smoke, integration, unit, telemetry) +- Zero build errors +- iOS platform fully functional + +--- + +### 6. Mock Input Provider for Testing + +**Decision:** Implement mock input provider for deterministic shutdown testing +- **Rationale:** Enables production-like shutdown behavior without sleeps or CPU spinning +- **Status:** IMPLEMENTED (test/mocks/MockInputProvider.h, test/mocks/MockSimulator.h) +- **Implementation Details:** + - **MockInputProvider**: Test double for IInputProvider interface + - **Shutdown Signaling**: `shouldContinue=false` in EngineInput struct + - **MockSimulator Integration**: `signalShutdown()` method uses input provider + - **Clean Shutdown**: No sleeps or CPU spinning, immediate termination + - **Production-like Behavior**: Mimics real system shutdown mechanism + +**Testing Infrastructure:** +- Deterministic input control for integration tests +- Clean shutdown signaling without relying on `ISimulator::stop()` directly +- Consistent with production simulation loop architecture + +--- + +--- + +**Current Status:** +- ✅ All major components implemented and committed +- ✅ iOS platform fully functional with engine simulation +- ✅ Build system working (zero errors, all tests pass) +- ✅ Production-ready static library for iOS +- ✅ Complete SwiftUI app with all required controls + +**Implemented Components:** +- **AudioBufferDescriptor** → Platform-agnostic audio buffer (Simple struct) +- **AVAudioEngineHardwareProvider** → iOS adapter using AVAudioEngine+AVAudioSourceNode +- **iOS SwiftUI App** → Complete MVVM app with throttle, ignition, starter controls +- **Build System** → CMake static lib, Xcode integration, two-click build +- **TDD Tests** → 15 GTest tests, all test suites pass +- **Mock Input Provider** → Production-like shutdown mechanism + +**Build Results:** +- Zero compilation errors +- All 4 test suites pass (smoke, integration, unit, telemetry) +- iOS platform fully functional +- Static library production-ready for iOS + +**User Requirements Met:** +- ✅ Single-view iOS app with engine simulation controls +- ✅ Throttle slider (0-100%) +- ✅ Ignition toggle +- ✅ Starter motor button +- ✅ Audio output through device speakers (AVAudioEngine) +- ✅ Real-time RPM/load/exhaust display +- ✅ Uses engine-sim-bridge library via ObjC++ wrapper + +**Technical Achievements:** +- Platform-agnostic audio buffer design enables iOS/macOS cross-platform support +- KISS principle applied (AVAudioEngine over RemoteIO) +- MVVM pattern provides clean separation of concerns +- TDD approach ensures quality with comprehensive test coverage +- Build system enables two-click deployment for iOS development + +**Deferred Work:** +- IAudioBuffer → IAudioRenderer rename (low priority, user requirement: selectable engines with real sounds) +- Pre-compiled engine configs for iOS (no Piranha runtime needed) + *This document will be updated as architectural decisions are made during iOS app development.* diff --git a/.gitignore b/.gitignore index 11cfa22..488489f 100644 --- a/.gitignore +++ b/.gitignore @@ -19,11 +19,6 @@ engine-sim-cli .DS_Store Thumbs.db -# Temporary files -*.bak -*.new -*~ - # Root-level library files (belong in build/) *.dylib *.a @@ -32,20 +27,24 @@ Thumbs.db *.log logs/* -# Test outputs (but keep sound library wav files) -*.wav -!es/sound-library/**/*.wav -test_*.mr +# Test outputs Testing/ verification_output/ *.dat +# Temporary files +*.bak +*.new +*~ .cache/ results.xml # Preset compiler temporary wrapper script (regenerated each run) -_escli_preset_wrapper.mr -escli-ios/EngineSimApp/EngineSimApp.xcodeproj/project.xcworkspace/xcuserdata/danielsinclair.xcuserdatad/UserInterfaceState.xcuserstate escli-ios/EngineSimApp/EngineSimApp.xcodeproj/project.xcworkspace/xcuserdata/ escli-ios/EngineSimApp/EngineSimApp.xcodeproj/xcuserdata/ .claude/scheduled_tasks.lock + +# es/ is a transient copy — rebuilt by 'make sync-es' +# Canonical source: engine-sim-bridge/es/ +es/ +_escli_preset_wrapper.mr diff --git a/CMakeLists.txt b/CMakeLists.txt index d2f5962..a4ffb7a 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -17,6 +17,7 @@ FetchContent_Declare( FetchContent_MakeAvailable(cli11) # Add engine-sim-bridge submodule +set(BUILD_PRESET_ENGINE_TESTS ON CACHE BOOL "Enable preset engine tests in CLI build" FORCE) add_subdirectory(engine-sim-bridge ${CMAKE_BINARY_DIR}/engine-sim-bridge ) # Platform-specific audio libraries @@ -107,6 +108,22 @@ if(BUILD_TESTS) add_subdirectory(test) + # Register bridge tests with CTest when building as a superproject. + # The bridge skips add_test() when CMAKE_SOURCE_DIR != CMAKE_CURRENT_SOURCE_DIR, + # so we register them here instead. + if(TARGET bridge_unit_tests) + add_test(NAME bridge_unit_tests COMMAND bridge_unit_tests --gtest_color=yes) + endif() + if(TARGET preset_engine_tests) + include(GoogleTest) + gtest_discover_tests(preset_engine_tests + DISCOVERY_MODE PRE_TEST + ) + endif() + if(TARGET preset_isomorphism_tests) + add_test(NAME preset_isomorphism_tests COMMAND preset_isomorphism_tests --gtest_color=yes) + endif() + add_custom_target(run_tests DEPENDS engine-sim-cli smoke_tests bridge_unit_tests COMMAND ${CMAKE_COMMAND} -E echo "=== Bridge Unit Tests ===========================================" diff --git a/Makefile b/Makefile index 6e3168d..291f9b0 100644 --- a/Makefile +++ b/Makefile @@ -3,32 +3,79 @@ # # IMPORTANT: Always use 'make' from project root, never run 'cmake' directly. # Running 'cmake -S . -B .' will overwrite this Makefile and break the build. +# +# Build cascade: make → cmake → compile → presets → sync-es +# Test cascade: make test → CLI smoke tests + bridge unit tests + preset tests BUILD_DIR ?= build BUILD_TYPE ?= Release CTEST_JOBS ?= $(shell sysctl -n hw.ncpu 2>/dev/null || echo 4) +BUILD_PARALLEL_LEVEL ?= $(shell sysctl -n hw.ncpu 2>/dev/null || echo 4) +CTEST_VERBOSE ?= 0 +CTEST_UI_FLAGS := $(if $(filter 1,$(CTEST_VERBOSE)),-V,--progress) SUBMODULE_STAMP = $(BUILD_DIR)/.submodule-stamp -# Default to parallel build using available CPU cores -MAKEFLAGS += -j$(shell sysctl -n hw.ncpu 2>/dev/null || echo 4) +CMAKE_BUILD_PARALLEL_FLAG := $(if $(strip $(BUILD_PARALLEL_LEVEL)),--parallel $(BUILD_PARALLEL_LEVEL),) -.PHONY: all clean scrub test submodules check-cmake check-platform check-submodule remove-orphans force-rebuild +.PHONY: all clean scrub test test-fast test-quick testquick submodules check-cmake check-platform check-submodule remove-orphans \ + force-rebuild sync-es copy-es-mr copy-es-json presets bridge-presets \ + run run-json help build-cross clean-cross -all: check-platform check-cmake $(BUILD_DIR)/Makefile - @cd $(BUILD_DIR) && $(MAKE) +# ============================================================================ +# all: Full build cascade — configure, compile, build presets, sync es/ +# +# Ordering is sequential via dependencies: +# 1. submodules — init recursive submodules +# 2. $(BUILD_DIR)/CMakeCache.txt — cmake configure +# 3. check-platform — verify macOS, then compile everything +# 4. bridge-presets — compile .mr → .json (needs preset_compiler from step 3) +# 5. sync-es — copy bridge es/ + preset/ → CLI es/ +# ============================================================================ +all: check-platform bridge-presets sync-es -check-platform: +check-platform: check-cmake submodules check-submodule $(BUILD_DIR)/CMakeCache.txt @if [ "$$(uname)" != "Darwin" ]; then \ echo ""; \ echo "ERROR: engine-sim-cli only supports macOS (CoreAudio/AudioUnit)."; \ - echo " Linux and Windows are not supported — no audio hardware provider exists."; \ - echo " Planned next platforms: ESP32, Android."; \ - echo " See README.md for the platform support roadmap."; \ - echo ""; \ exit 1; \ fi + +@cmake --build $(BUILD_DIR) $(CMAKE_BUILD_PARALLEL_FLAG) + +# Build presets in bridge (depends on check-platform so compiler exists) +bridge-presets: check-platform + +@$(MAKE) -C engine-sim-bridge presets + +# --------------------------------------------------------------------------- +# es/ convenience copy — full mirror from bridge +# +# The bridge/es/ directory is the source of truth for all .mr scripts and +# supporting files. The bridge Makefile's CANDIDATE_ENGINES controls which +# get compiled to JSON. This target just mirrors the full directory. +# --------------------------------------------------------------------------- +BRIDGE_ES := engine-sim-bridge/es +BRIDGE_PRESET := engine-sim-bridge/preset +CLI_ES := es + +copy-es-mr: + @echo "Syncing es/ from bridge..." + @mkdir -p $(CLI_ES) + @rsync -a --exclude='.git' $(BRIDGE_ES)/ $(CLI_ES)/ + +copy-es-json: bridge-presets + @if [ -d $(BRIDGE_PRESET) ] && ls $(BRIDGE_PRESET)/*.json >/dev/null 2>&1; then \ + echo "Syncing JSON presets..."; \ + cp $(BRIDGE_PRESET)/*.json $(CLI_ES)/; \ + else \ + echo "No presets built yet — run 'make presets' first."; \ + fi + +sync-es: copy-es-mr copy-es-json + +presets: bridge-presets -# Check if submodule changed - if so, force rebuild +# --------------------------------------------------------------------------- +# Submodule and CMake configuration +# --------------------------------------------------------------------------- check-submodule: submodules @CURRENT_SUBMODULE=$$(git submodule status engine-sim-bridge | awk '{print $$1}'); \ STAMPED_SUBMODULE=$$(cat $(SUBMODULE_STAMP) 2>/dev/null); \ @@ -40,51 +87,245 @@ check-submodule: submodules echo "$$CURRENT_SUBMODULE" > $(SUBMODULE_STAMP); \ fi -# Remove orphaned binaries and symlinks from root and other unexpected locations +check-cmake: + @if [ -f CMakeCache.txt ] && ! grep -q "CMAKE_BUILD_TYPE:STRING=Release" CMakeCache.txt; then \ + echo "ERROR: Root CMakeCache.txt exists with wrong BUILD_TYPE. This happens when running 'cmake -S . -B .' directly."; \ + echo "Please run 'git checkout Makefile' and then use 'make' instead."; \ + exit 1; \ + fi + +submodules: + @if [ ! -f engine-sim-bridge/CMakeLists.txt ]; then \ + echo "Initializing submodules..."; \ + git submodule update --init --recursive; \ + fi + +$(BUILD_DIR)/CMakeCache.txt: check-submodule + @mkdir -p $(BUILD_DIR) + @cd $(BUILD_DIR) && cmake -DCMAKE_BUILD_TYPE=$(BUILD_TYPE) .. + +# --------------------------------------------------------------------------- +# Clean targets — cascade to bridge +# --------------------------------------------------------------------------- remove-orphans: @rm -f *.dylib libenginesim*.dylib @find . -name "*.dylib*" -type l -delete 2>/dev/null || true - @find . -name "CMakeCache.txt" -not -path "./$(BUILD_DIR)/*" -delete 2>/dev/null || true @rm -f $(SUBMODULE_STAMP) + @find . -path ./$(BUILD_DIR) -prune -o -name "CMakeCache.txt" -type f -print -delete 2>/dev/null || true + @find . -path ./$(BUILD_DIR) -prune -o -name "CMakeFiles" -type d -print -exec rm -rf {} + 2>/dev/null || true + @find . -path ./$(BUILD_DIR) -prune -o -name "cmake_install.cmake" -type f -print -delete 2>/dev/null || true + @find . -path ./$(BUILD_DIR) -prune -o -name "CTestTestfile.cmake" -type f -print -delete 2>/dev/null || true + @find . -path ./$(BUILD_DIR) -prune -o -name "*_include.cmake" -type f -print -delete 2>/dev/null || true + @find . -path ./$(BUILD_DIR) -prune -o -name "*.a" -type f -print -delete 2>/dev/null || true + @find . -path ./$(BUILD_DIR) -prune -o -name "_deps" -type d -print -exec rm -rf {} + 2>/dev/null || true -# Clean build artifacts (keeps CMakeCache.txt for fast rebuild) clean: remove-orphans + +@$(MAKE) -C engine-sim-bridge clean 2>/dev/null || true @if [ -d $(BUILD_DIR) ]; then \ - $(MAKE) -C $(BUILD_DIR) clean 2>/dev/null || true; \ + cmake --build $(BUILD_DIR) --target clean >/dev/null 2>&1 || true; \ fi - @if [ -d $(BUILD_DIR)/engine-sim-bridge ]; then \ - $(MAKE) -C $(BUILD_DIR)/engine-sim-bridge clean 2>/dev/null || true; \ - fi - @$(MAKE) -C engine-sim-bridge clean 2>/dev/null || true + @rm -rf $(CLI_ES) -# Full clean - removes everything including build directories (superset of clean) scrub: clean @echo "Scrubbing all build artifacts..." - @$(MAKE) -C engine-sim-bridge scrub 2>/dev/null || true - @rm -rf $(BUILD_DIR) + +@$(MAKE) -C engine-sim-bridge scrub 2>/dev/null || true + @rm -rf $(BUILD_DIR) $(CLI_ES) @$(MAKE) remove-orphans @echo "Build artifacts scrubbed. Run 'make' to rebuild." -check-cmake: - @if [ -f CMakeCache.txt ] && ! grep -q "CMAKE_BUILD_TYPE:STRING=Release" CMakeCache.txt; then \ - echo "ERROR: Root CMakeCache.txt exists with wrong BUILD_TYPE. This happens when running 'cmake -S . -B .' directly."; \ - echo "Please run 'git checkout Makefile' and then use 'make' instead."; \ +# --------------------------------------------------------------------------- +# Test — runs all test suites via CTest +# --------------------------------------------------------------------------- +test: $(BUILD_DIR)/CMakeCache.txt + +@total_start=$$(date +%s); \ + bridge_elapsed=0; \ + cli_elapsed=0; \ + echo "=== [engine-sim-cli] Stage 1/2: bridge tests ==="; \ + bridge_start=$$(date +%s); \ + if $(MAKE) -C engine-sim-bridge test; then \ + bridge_end=$$(date +%s); \ + bridge_elapsed=$$((bridge_end - bridge_start)); \ + echo "=== [engine-sim-cli] Stage 1/2: bridge tests PASSED ($${bridge_elapsed}s) ==="; \ + else \ + bridge_end=$$(date +%s); \ + bridge_elapsed=$$((bridge_end - bridge_start)); \ + echo "=== [engine-sim-cli] Stage 1/2: bridge tests FAILED ($${bridge_elapsed}s) ==="; \ + total_end=$$(date +%s); \ + total_elapsed=$$((total_end - total_start)); \ + echo "=== [engine-sim-cli] TIME: bridge=$${bridge_elapsed}s cli=SKIPPED total=$${total_elapsed}s ==="; \ + printf '\033[0;31m=== [engine-sim-cli] RESULT: TESTS FAILED ===\033[0m\n'; \ + exit 1; \ + fi; \ + echo "=== [engine-sim-cli] Stage 2/2: cli/unit/integration tests ==="; \ + cli_start=$$(date +%s); \ + if cmake --build $(BUILD_DIR) $(CMAKE_BUILD_PARALLEL_FLAG) --target engine-sim-cli smoke_tests bridge_unit_tests unit_tests telemetry_isp_tests integration_tests preset_engine_tests; then \ + :; \ + else \ + cli_end=$$(date +%s); \ + cli_elapsed=$$((cli_end - cli_start)); \ + total_end=$$(date +%s); \ + total_elapsed=$$((total_end - total_start)); \ + echo "=== [engine-sim-cli] Stage 2/2: cli/unit/integration build FAILED ($${cli_elapsed}s) ==="; \ + echo "=== [engine-sim-cli] TIME: bridge=$${bridge_elapsed}s cli=$${cli_elapsed}s total=$${total_elapsed}s ==="; \ + printf '\033[0;31m=== [engine-sim-cli] RESULT: TESTS FAILED ===\033[0m\n'; \ + exit 1; \ + fi; \ + if (cd $(BUILD_DIR) && ctest $(CTEST_UI_FLAGS) --output-on-failure --output-log ../test.log -j$(CTEST_JOBS)); then \ + cli_end=$$(date +%s); \ + cli_elapsed=$$((cli_end - cli_start)); \ + echo "=== [engine-sim-cli] Stage 2/2: cli/unit/integration tests PASSED ($${cli_elapsed}s) ==="; \ + total_end=$$(date +%s); \ + total_elapsed=$$((total_end - total_start)); \ + echo "=== [engine-sim-cli] TIME: bridge=$${bridge_elapsed}s cli=$${cli_elapsed}s total=$${total_elapsed}s ==="; \ + echo "=== [engine-sim-cli] SUMMARY: PASS (full) ==="; \ + printf '\033[0;32m=== [engine-sim-cli] RESULT: ALL TESTS PASSED ===\033[0m\n'; \ + else \ + cli_end=$$(date +%s); \ + cli_elapsed=$$((cli_end - cli_start)); \ + echo "=== [engine-sim-cli] Stage 2/2: cli/unit/integration tests FAILED ($${cli_elapsed}s) ==="; \ + total_end=$$(date +%s); \ + total_elapsed=$$((total_end - total_start)); \ + echo "=== [engine-sim-cli] TIME: bridge=$${bridge_elapsed}s cli=$${cli_elapsed}s total=$${total_elapsed}s ==="; \ + echo "=== [engine-sim-cli] SUMMARY: FAIL (full) ==="; \ + printf '\033[0;31m=== [engine-sim-cli] RESULT: TESTS FAILED ===\033[0m\n'; \ exit 1; \ fi -submodules: - @if [ ! -f engine-sim-bridge/CMakeLists.txt ]; then \ - echo "Initializing submodules..."; \ - git submodule update --init --recursive; \ +# Fast test path: keep default `make test` full coverage, but allow +# developer inner-loop skips for known heavy bridge groups. +test-fast: $(BUILD_DIR)/CMakeCache.txt + +@total_start=$$(date +%s); \ + bridge_elapsed=0; \ + cli_elapsed=0; \ + echo "=== [engine-sim-cli] Fast mode: bridge test-fast + full cli/unit/integration ==="; \ + bridge_start=$$(date +%s); \ + if $(MAKE) -C engine-sim-bridge test-fast; then \ + bridge_end=$$(date +%s); \ + bridge_elapsed=$$((bridge_end - bridge_start)); \ + echo "=== [engine-sim-cli] Bridge fast suite PASSED ($${bridge_elapsed}s) ==="; \ + else \ + bridge_end=$$(date +%s); \ + bridge_elapsed=$$((bridge_end - bridge_start)); \ + echo "=== [engine-sim-cli] Bridge fast suite FAILED ($${bridge_elapsed}s) ==="; \ + total_end=$$(date +%s); \ + total_elapsed=$$((total_end - total_start)); \ + echo "=== [engine-sim-cli] TIME: bridge-fast=$${bridge_elapsed}s cli=SKIPPED total=$${total_elapsed}s ==="; \ + printf '\033[0;31m=== [engine-sim-cli] RESULT: TESTS FAILED ===\033[0m\n'; \ + exit 1; \ + fi; \ + cli_start=$$(date +%s); \ + if cmake --build $(BUILD_DIR) $(CMAKE_BUILD_PARALLEL_FLAG) --target engine-sim-cli smoke_tests bridge_unit_tests unit_tests telemetry_isp_tests integration_tests preset_engine_tests; then \ + :; \ + else \ + cli_end=$$(date +%s); \ + cli_elapsed=$$((cli_end - cli_start)); \ + total_end=$$(date +%s); \ + total_elapsed=$$((total_end - total_start)); \ + echo "=== [engine-sim-cli] Fast mode cli/unit/integration build FAILED ($${cli_elapsed}s) ==="; \ + echo "=== [engine-sim-cli] TIME: bridge-fast=$${bridge_elapsed}s cli=$${cli_elapsed}s total=$${total_elapsed}s ==="; \ + printf '\033[0;31m=== [engine-sim-cli] RESULT: TESTS FAILED ===\033[0m\n'; \ + exit 1; \ + fi; \ + if (cd $(BUILD_DIR) && ctest $(CTEST_UI_FLAGS) --output-on-failure --output-log ../test.log -j$(CTEST_JOBS)); then \ + cli_end=$$(date +%s); \ + cli_elapsed=$$((cli_end - cli_start)); \ + total_end=$$(date +%s); \ + total_elapsed=$$((total_end - total_start)); \ + echo "=== [engine-sim-cli] TIME: bridge-fast=$${bridge_elapsed}s cli=$${cli_elapsed}s total=$${total_elapsed}s ==="; \ + echo "=== [engine-sim-cli] SUMMARY: PASS (fast) ==="; \ + printf '\033[0;32m=== [engine-sim-cli] RESULT: FAST TESTS PASSED ===\033[0m\n'; \ + else \ + cli_end=$$(date +%s); \ + cli_elapsed=$$((cli_end - cli_start)); \ + total_end=$$(date +%s); \ + total_elapsed=$$((total_end - total_start)); \ + echo "=== [engine-sim-cli] TIME: bridge-fast=$${bridge_elapsed}s cli=$${cli_elapsed}s total=$${total_elapsed}s ==="; \ + echo "=== [engine-sim-cli] SUMMARY: FAIL (fast) ==="; \ + printf '\033[0;31m=== [engine-sim-cli] RESULT: TESTS FAILED ===\033[0m\n'; \ + exit 1; \ fi -$(BUILD_DIR)/Makefile: check-submodule - @mkdir -p $(BUILD_DIR) - @cd $(BUILD_DIR) && cmake -DCMAKE_BUILD_TYPE=$(BUILD_TYPE) .. +# Quick mode: minimal bridge-only infra checks for tight edit/run loops. +test-quick: $(BUILD_DIR)/CMakeCache.txt + @echo "=== [engine-sim-cli] Quick mode: bridge test-quick only ===" + +@if $(MAKE) -C engine-sim-bridge test-quick; then \ + echo "=== [engine-sim-cli] SUMMARY: PASS (quick) ==="; \ + printf '\033[0;32m=== [engine-sim-cli] RESULT: QUICK TESTS PASSED ===\033[0m\n'; \ + else \ + echo "=== [engine-sim-cli] SUMMARY: FAIL (quick) ==="; \ + printf '\033[0;31m=== [engine-sim-cli] RESULT: TESTS FAILED ===\033[0m\n'; \ + exit 1; \ + fi -test: $(BUILD_DIR)/Makefile - @cd $(BUILD_DIR) && $(MAKE) engine-sim-cli smoke_tests bridge_unit_tests unit_tests telemetry_isp_tests integration_tests - @cd $(BUILD_DIR) && $(MAKE) test ARGS="-V --output-on-failure -j$(CTEST_JOBS)" 2>&1 | tee test.log +testquick: test-quick + +# Explicit long-running tier: bridge golden-audio regressions. +test-deep: $(BUILD_DIR)/CMakeCache.txt + @echo "=== [engine-sim-cli] Deep mode: bridge preset golden-audio regressions ===" + +@if $(MAKE) -C engine-sim-bridge test-deep; then \ + echo "=== [engine-sim-cli] SUMMARY: PASS (deep) ==="; \ + printf '\033[0;32m=== [engine-sim-cli] RESULT: DEEP TESTS PASSED ===\033[0m\n'; \ + else \ + echo "=== [engine-sim-cli] SUMMARY: FAIL (deep) ==="; \ + printf '\033[0;31m=== [engine-sim-cli] RESULT: TESTS FAILED ===\033[0m\n'; \ + exit 1; \ + fi +testdeep: test-deep + @cd $(BUILD_DIR) && $(MAKE) engine-sim-cli smoke_tests bridge_unit_tests preset_engine_tests preset_isomorphism_tests + @cd $(BUILD_DIR) && ctest -V --output-on-failure -j$(CTEST_JOBS) 2>&1 | tee ../test.log + +# --------------------------------------------------------------------------- +# Convenience targets +# --------------------------------------------------------------------------- run: all - ./build/engine-sim-cli --interactive --play --script es/ferrari_f136.mr \ No newline at end of file + ./build/engine-sim-cli --interactive --play --script es/ferrari_f136.mr + +run-json: all + ./build/engine-sim-cli --interactive --play --script es/v8_gm_ls.json + +help: + @echo "engine-sim-cli Makefile" + @echo "" + @echo "Targets:" + @echo " make - Build everything (configure → compile → presets → sync)" + @echo " make test - Build and run all tests (full)" + @echo " make test-deep - Run bridge preset golden-audio regressions" + @echo " make test-fast - Run fast mode (skips 6 heavy bridge groups)" + @echo " make test-quick/testquick - Run bridge quick-only checks" + @echo " make presets - Compile .mr wrappers to JSON presets" + @echo " make clean - Clean build artifacts (fast rebuild)" + @echo " make scrub - Remove entire build directory (full clean)" + @echo " make run - Build and run CLI with .mr script" + @echo " make run-json - Build and run CLI with JSON preset" + @echo " make help - Show this help" + +# --------------------------------------------------------------------------- +# Cross-compilation (caller sets PLATFORM, e.g. OS64, SIMULATOR64) +# Not iOS-aware — just accepts a platform variable for the CMake toolchain. +# --------------------------------------------------------------------------- +ifdef PLATFORM +CROSS_BUILD_DIR := build-$(PLATFORM) +CROSS_TOOLCHAIN := ios.toolchain.cmake +endif + +build-cross: submodules +ifndef PLATFORM + $(error PLATFORM is required. Usage: make build-cross PLATFORM=OS64) +endif + @mkdir -p $(CROSS_BUILD_DIR) + @cd $(CROSS_BUILD_DIR) && cmake \ + -DCMAKE_TOOLCHAIN_FILE=$(CROSS_TOOLCHAIN) \ + -DPLATFORM=$(PLATFORM) \ + -DDEPLOYMENT_TARGET=16.0 \ + -DBUILD_TESTS=OFF \ + -DBUILD_BRIDGE_TESTS=OFF \ + -DCMAKE_BUILD_TYPE=$(BUILD_TYPE) .. + @$(MAKE) -C $(CROSS_BUILD_DIR) engine-sim-bridge -j$(shell sysctl -n hw.ncpu 2>/dev/null || echo 4) + +clean-cross: +ifdef PLATFORM + @rm -rf $(CROSS_BUILD_DIR) +else + @rm -rf build-OS64 build-SIMULATOR64 +endif diff --git a/docs/FIX_PRESET_ENGINE_TESTS.md b/docs/FIX_PRESET_ENGINE_TESTS.md new file mode 100644 index 0000000..9db1430 --- /dev/null +++ b/docs/FIX_PRESET_ENGINE_TESTS.md @@ -0,0 +1,161 @@ +# Plan: Fix Preset Engine Tests (Silent Audio / Near-Zero RPM) + +## Context + +4 of 14 preset engine tests fail: the 2 `PresetAudioIdleTest` and 2 `PresetThrottleTest` variants. +Both Honda and Subaru presets load correctly but produce near-zero RPM (~0.0002) and completely +silent audio output. The engine doesn't start. + +**This is NOT an engine-sim bug.** The CLI works perfectly with Piranha scripts. The issue is +entirely in `PresetEngineFactory.cpp` (our bridge code) which reconstructs engines from JSON. + +## Timeline: When It Was Working vs Broken + +### escli.refac7 (main repo) +- `96a5183` - Latest: iOS app wired to load presets +- `05d5783` - Updated bridge submodule with preset factories +- Everything before `05d5783` was working (CLI only, no preset tests existed) + +### engine-sim-bridge (submodule) +- `16b900a` - **Latest**: Fixed ignition timing, added default exhaust outlet flow rate +- `9e9dd20` - First commit: added PresetEngineFactory + PresetEngineTests + +**The preset tests were NEVER green.** They were introduced in `9e9dd20` and have been +iterated on (`f8eefc1`, `bddf4f3`, `16b900a`) but the 4 audio/throttle tests have always +failed. The 10 infrastructure/creation/shutdown tests pass. + +### engine-sim (nested submodule) +- `859aa4f` - Latest: added `renderAudioOnDemand()` and combustion chamber init in `loadSimulation()` +- This is the third-party engine-sim library - working fine with Piranha/CLI + +## Root Cause Analysis + +The CLI/Piranha path works because the Piranha script interpreter sets up the engine +in the correct order using `engine_node.h::generate()`: +1. Creates crankshafts, cylinder banks, pistons, rods, heads +2. Connects rod assemblies +3. Generates ignition module +4. Initializes combustion chambers +5. Then `loadSimulation()` calls `placeAndInitialize()` which places pistons physically + and re-initializes `m_system` with correct volume + +The PresetEngineFactory does the SAME sequence (steps 1-4 in `loadFromString()`), +and `loadSimulation()` does step 5. So the initialization order is NOT the issue. + +**The actual problem is likely in the JSON data or missing defaults.** Key areas to investigate: + +### 1. Crankshaft `rodJournals` array +In `PresetEngineFactory.cpp:199`: `csParams.rodJournals = journalCount` counts from JSON +but `Crankshaft::initialize()` uses `rodJournals` to allocate journal arrays. The JSON +has `"rodJournals": [{"angle": 0}]` but the factory reads the array only for angles, not +for count. The count comes from `journalCount = journals.isArray() ? journals.size() : 0`. +This looks correct for Honda (1 journal). + +### 2. Starter motor direction +`piston_engine_simulator.cpp:180`: `m_rotationSpeed = -m_engine->getStarterSpeed()`. +Honda's starterSpeed is 52.36 rad/s. Negative means CW. The starter constraint +sets `limits[0][0] = -m_maxTorque` when `m_rotationSpeed < 0`, which means it can only +apply torque in the negative theta direction. This should work. + +### 3. Throttle state +Test calls `setSpeedControl(1.0)` which maps to `engine->setSpeedControl(1.0)`. +This goes through `DirectThrottleLinkage` which sets `m_throttlePosition = 1 - 1 = 0` +which means throttle plate OPEN. The intake's `getThrottlePlatePosition()` returns +`m_idleThrottlePlatePosition * m_throttle` = `0.993 * 0 = 0`, so `flowAttenuation = cos(0) = 1`. +Air should flow freely. This looks correct. + +### 4. The `while(simulateStep())` loop +The test correctly uses `while (simulator_->simulateStep()) {}` to exhaust all substeps. + +### 5. Combustion check - `ignite()` prerequisites +Looking at `combustion_chamber.cpp:176`: +- Needs `m_system.mix().p_fuel != 0` - requires fuel in the mix +- Needs equivalence ratio between 0.5 and 1.9 +- The intake must have provided fuel-air mixture + +**Hypothesis: The intake gas system isn't providing the right fuel-air mix.** The intake +calls `m_system.flow()` which flows gas from atmosphere to plenum. The fuel-air mix is +constructed in `Intake::process()` based on `m_molecularAfr`. Looking at the JSON: +`"molecularAfr": 12.5`. The factory sets `fParams.molecularAfr = fuelJson["molecularAfr"].numberOr(14.7)`. +This is 12.5 from JSON. But `Fuel::initialize()` stores this. The combustion check uses +`m_fuel->getMolecularAfr()`. + +The real question: **is the intake even flowing?** The intake's `InputFlowK` is derived +from `runnerFlowRate` (0.00637) when no `inputFlowK` is in JSON. That should be non-zero. + +### 6. Most likely root cause: `CombustionChamber::flow()` access to uninitialized data + +Looking at `combustion_chamber.cpp:257-305`: The `flow()` method accesses: +- `m_head->getIntake(cylinderIndex)` → returns Intake* +- `m_head->getExhaustSystem(cylinderIndex)` → returns ExhaustSystem* + +These are wired in `PresetEngineFactory.cpp:434-445`. For Honda (single bank, single cylinder), +`head->setAllIntakes(engine->getIntake(0))` and `head->setExhaustSystem(0, engine->getExhaustSystem(0))`. + +**But the flow rate calculations depend on:** +- `m_manifoldToRunnerFlowRate` = `intake->getRunnerFlowRate()` (0.00637 from JSON) +- `m_primaryToCollectorFlowRate` = `exhaust->getPrimaryFlowRate()` (0.00637 from JSON) +- `m_intakeFlowRate` = `m_head->intakeFlowRate(cylinderIndex)` - depends on camshaft/valve +- `m_exhaustFlowRate` = `m_head->exhaustFlowRate(cylinderIndex)` - depends on camshaft/valve + +The camshaft lobe profile IS in the JSON. The valve lift depends on camshaft rotation +which depends on crankshaft rotation. At near-zero RPM, valve lift is essentially +determined by the cam's base position. + +### 7. SIMULATION FREQUENCY MISMATCH +**THIS IS THE SMOKING GUN.** Look at the JSON: +```json +"simulationFrequency": 40000 +``` + +The factory sets `params.initialSimulationFrequency = engineJson["simulationFrequency"].numberOr(10000)`. +But in the test harness (`PresetEngineTests.cpp:105`): +```cpp +pistonSim->setSimulationFrequency(10000); +``` + +And in `PresetEngineFactory.cpp:163`: +```cpp +params.initialSimulationFrequency = engineJson["simulationFrequency"].numberOr(10000); +``` + +The test overrides to 10000 but the JSON says 40000. This alone shouldn't cause zero RPM, +but it means the simulation timestep is different. + +**MORE CRITICAL:** The test calls `startFrame(1.0 / 60.0)` which is a 16.67ms frame. +At 10000 Hz sim frequency, that's ~167 substeps per frame. At 40000 Hz, it would be ~667. +The starter motor at 52 rad/s should spin the engine regardless of sim frequency. + +## Recommended Fix Approach + +**Step 1: Diagnostic comparison test** (delegated to agent) + +Add a temporary diagnostic test to `PresetEngineTests.cpp` that loads Honda via BOTH +Piranha (if available) and PresetFactory, runs one frame, and prints: +- Crankshaft `v_theta` (angular velocity) +- Chamber pressure, mix (p_fuel, p_o2, p_inert) +- Intake flow, exhaust flow +- `getVolume()` on combustion chamber (before and after placeAndInitialize) + +**Step 2: Fix the root cause** (delegated to agent, after diagnosis) + +Based on diagnostic results, fix `PresetEngineFactory.cpp` or `PresetEngineTests.cpp`. + +Likely candidates: +- Missing/wrong parameter causing no combustion +- Simulation frequency mismatch (JSON says 40000, test overrides to 10000) +- Crankshaft not spinning because constraint solver isn't getting enough torque + +**Step 3: Verify all 14 tests pass** + +## Key Files +- `engine-sim-bridge/src/simulator/PresetEngineFactory.cpp` - JSON engine deserializer +- `engine-sim-bridge/test/PresetEngineTests.cpp` - Failing tests +- `engine-sim-bridge/engine-sim/src/piston_engine_simulator.cpp` - loadSimulation/placeAndInitialize +- `engine-sim-bridge/engine-sim/src/combustion_chamber.cpp` - ignite/flow/update +- `engine-sim-bridge/engine-sim/scripting/include/engine_node.h` - Piranha reference path + +## Verification +- `cmake --build build-test --target preset_engine_tests` +- `./build-test/preset_engine_tests` +- All 14 tests pass diff --git a/docs/PRESET_ENGINE_ISOMORPHIC_SCRIPT.md b/docs/PRESET_ENGINE_ISOMORPHIC_SCRIPT.md new file mode 100644 index 0000000..56ff7e1 --- /dev/null +++ b/docs/PRESET_ENGINE_ISOMORPHIC_SCRIPT.md @@ -0,0 +1,110 @@ +# Preset Engine: Isomorphic .mr/.JSON via --script + +## Goal + +Compile `.mr` engine scripts to JSON at build time. CLI accepts both formats +through `--script` — auto-detects by file extension. No hand-coded engine configs. +JSON presets work on iOS/ESP32 without Piranha. + +## Architecture + +``` +Build time: .mr scripts --> preset_compiler --> .json files +Runtime: --script foo.mr -> Piranha compilation (desktop) + --script foo.json -> JSON preset load (any platform) +``` + +Factory routes by file extension in `SimulatorFactory::create()` — no separate +flags, no enum changes. + +## Design Rationale + +The original plan had C++ codegen from .mr scripts with a separate `--preset` flag. +Replaced with JSON because: + +- Hand-coded C++ engines drifted from .mr script values (GM LS crackled) +- The JSON pipeline (`preset_compiler` -> `PresetEngineFactory`) already existed and passed 16/16 tests +- One `--script` flag accepting both formats is simpler than two flags +- JSON allows dynamic loading without binary rebuild + +### On isomorphism + +`.mr` is syntactically imperative (sequential initialization calls) but functionally +declarative for engine setup (no branching, no user input during configuration). +The `preset_compiler` runs Piranha, captures the resulting engine-sim object state, +and serializes it to JSON. This is compilation (imperative -> data), not transpilation. +Round-trip `.mr -> JSON -> .mr` is not possible because the JSON captures +post-execution state, not the procedural instructions. + +What we guarantee: +- **Deterministic compilation**: same .mr always produces the same JSON +- **Behavioral equivalence**: both paths produce identical audio/physics output + (verified by Group 6 golden file tests, RMS tolerance < 1%) + +## Status + +### Phase 1: Fix existing preset tests — DONE +- ConvolutionFilter null-deref fix (SimulatorInitHelpers) +- Intake air mixture initialization +- Flow function unit mismatch +- 16/16 JSON pipeline tests pass + +### Phase 2: Public API getters in engine-sim — DONE +- 29 read-only accessors added to engine-sim submodule + +### Phase 3: JSON preset compiler — DONE +- `engine-sim-preset-compiler` tool generates .json from .mr +- `PresetEngineFactory::loadFromFile()` loads JSON at runtime +- Verified: Honda (1 cyl), Subaru (4 cyl), GM LS (8 cyl) + +### Phase 4: Isomorphic --script — DONE +- Extension-based routing in `SimulatorFactory.cpp` (.json vs .mr) +- `SimulatorType` enum reverted to SineWave + PistonEngine +- Hand-coded engine classes removed (PresetSimulator, HondaTrx520, etc.) +- EnginePresetsHelper namespace retained (shared helpers) +- 28/28 preset tests pass +- End-to-end verified: `--script gm_ls.json` loads and runs without Piranha + +### Phase 5: Build integration — TODO +- [ ] Makefile `presets` target to auto-generate .json from .mr scripts +- [ ] Generate JSON for all engines in `engine-sim/assets/engines/` +- [ ] iOS build: include JSON presets, exclude Piranha target + +## Files Modified + +### SimulatorFactory.cpp — extension routing +- `endsWith(scriptPath, ".json")` routes to `PresetEngineFactory::loadFromFile()` +- Else: Piranha compilation (existing path, unchanged) + +### EnginePresets.cpp/h — gutted +- Removed: PresetSimulator, HondaTrx520Simulator, SubaruEj25Simulator, GmLsSimulator +- Removed: EnginePresets::createPreset(), getAvailablePresets() +- Retained: EnginePresetsHelper namespace (shared helpers used by PresetEngineFactory) + +### CLI files — restored to pre-preset state +- `CLIconfig.h`: no presetId field +- `CLIconfig.cpp`: no --preset flag +- `CLIMain.cpp`: no PresetEngine routing + +### PresetEngineTests.cpp — updated +- Removed Group 8 (hardcoded preset registry tests) +- Group 9 updated: uses JSON fixture paths with SimulatorType::PistonEngine +- 28/28 tests pass + +## Build Commands + +```bash +make # Build everything +make test # Run smoke + unit tests + +# JSON preset (no Piranha needed at runtime): +./build/engine-sim-cli --script path/to/engine.json --duration 5 + +# .mr script (Piranha compilation at runtime): +./build/engine-sim-cli --script es/ferrari_f136.mr --duration 5 + +# Generate JSON from .mr: +./build/engine-sim-bridge/engine-sim-preset-compiler \ + assets/engines/atg-video-2/07_gm_ls.mr output.json \ + /path/to/engine-sim-root +``` diff --git a/docs/VIRTUAL_ICE_TWIN_ARCHITECTURE.md b/docs/VIRTUAL_ICE_TWIN_ARCHITECTURE.md new file mode 100644 index 0000000..d08d208 --- /dev/null +++ b/docs/VIRTUAL_ICE_TWIN_ARCHITECTURE.md @@ -0,0 +1,566 @@ +# VirtualICE Twin Architecture Plan + +## Context + +The goal: make a real Tesla EV produce realistic ICE vehicle sounds by mapping real OBD2 telemetry through a "digital twin" into engine-sim's physics-based sound engine. When you press the accelerator in a Tesla, the twin determines what an AMG C63 (or any .mr-defined vehicle) would be doing at that same road speed and throttle, feeds those conditions to engine-sim, and physics produces authentic sound. + +The problem: EV and ICE drivetrains are fundamentally different. There's no 1:1 RPM mapping. A Tesla motor runs to 15,000+ RPM; road speed depends on gear ratio, not motor speed. The twin must compute which gear an automatic ICE transmission would select, apply appropriate throttle, and let engine-sim's physics engine determine the RPM and resulting sound. + +--- + +## Phase 0 Spike Results (Evidence Collected) + +### DynoTrackingSpike — PASS (dyno tracks RPM perfectly, but WRONG abstraction) +Real I6 engine with dyno hold=true. Mean RPM error = 0.0. Dyno can precisely hold target RPM. +- **However**: Dyno is a MEASUREMENT tool (sweep/hold), not a driving simulator. +- Dyno bypasses vehicle physics by directly controlling crankshaft angular velocity. + +### PhysicsDrivenDriving — PASS (validated approach) +Ferrari F136 engine loaded via .mr script. Gear engaged via `changeGear()`, clutch locked via `setClutchPressure(1.0)`. +- RPM emerges naturally from engine torque vs vehicle inertia + drag through gear ratio +- Transmission encodes vehicle mass as effective rotational inertia: `I = m_car * (tire_radius / (diff_ratio * gear_ratio))^2` +- VehicleDragConstraint applies aero drag + rolling resistance automatically +- **This is how AngeTheGreat's original GUI does driving simulation** — NOT via dyno. + +### Dyno Brake Mode — NOT VIABLE for gradual load +- `hold=false`, `m_rotationSpeed=0`: Kills engine at startup (velocity-dependent damping too aggressive) +- `hold=false`, `m_rotationSpeed=700` (idle): Cliff behavior — load 1-20% = 6400 RPM, 25%+ = stuck at idle +- Binary, not gradual — constraint solver saturates the cap too quickly + +### AudioSweepSpike — PASS (pipeline validation) +Audio pipeline works end-to-end. Real engine audio confirmed with Ferrari .mr script. + +### ClutchParameterSweep — PASS (runs but hand-built engine doesn't combust) +Hand-built C++ initialization produces 0 RPM — no combustion. .mr scripts through Piranha work perfectly. + +### Key Decisions Validated +1. **Physics-driven approach is correct** — `changeGear()` + `setClutchPressure(1.0)` + throttle → RPM emerges +2. **Dyno is NOT for driving simulation** — AngeTheGreat's GUI uses dyno for sweep/hold TESTING only +3. **Vehicle + Transmission + VehicleDragConstraint provide realistic load** — no external torque needed +4. **RPM is strictly an OUTPUT** — never set RPM directly; set the conditions (throttle, gear, clutch) that produce it + +--- + +## Key Finding: ForceGenerator Integration Point + +The physics specialist traced through engine-sim's source code and identified the clean injection mechanism: + +**`ForceGenerator::apply(SystemState* system)`** — called by `processForces()` before constraint solving. Writes to `system->t[body_index] += torque`. + +This is the **intended extension point** in the SCS rigid body framework. It interacts correctly with all constraints (clutch, drag, etc.) because forces are applied before the constraint solver runs. + +Two physics approaches are designed, sharing the same twin/gearbox layer: + +### Approach A+ (Recommended): Full Vehicle + SpeedTrackingForce +Use engine-sim's complete vehicle model (Transmission + Vehicle + VehicleDragConstraint). Add a `SpeedTrackingForce` ForceGenerator on the vehicle mass body that gently corrects virtual speed toward real EV speed (P-controller, clamped). RPM emerges from physics. + +- **Pros**: Authentic physics, natural engine braking, realistic load response +- **Cons**: Needs drift correction, startup speed initialization +- **Confidence**: High — physics specialist traced through source code, not speculative + +### Approach B (Fallback): FixedLoadConstraint on Crankshaft +Replace vehicle model with a custom SCS constraint applying fixed braking torque. Computes target RPM from road speed + gear ratio, uses PD controller to derive load torque. + +- **Pros**: Precise RPM tracking, no vehicle model complexity +- **Cons**: Bypasses vehicle physics, loses natural engine braking sound +- **When**: Only if Approach A+ shows unacceptable speed drift + +Both approaches share the same `VirtualIceTwin`, `AutomaticGearbox`, `IceVehicleProfile`, and `VirtualIceInputProvider`. Only the physics injection layer differs. + +--- + +## EV Telemetry Availability (from web research) + +### Tesla-specific data sources + +| Source | Rate | Fields | Feasibility | +|--------|------|--------|-------------| +| REST API (owner-api) | ~0.5 Hz | speed, power, shift_state | Easy but too slow for sound | +| Streaming API | ~2 Hz | speed, power, shift_state, soc | Usable with interpolation | +| CAN bus (drivetrain) | 50-100 Hz | motor RPM, throttle %, vehicle speed, brake | Best quality, needs CAN adapter | + +### Minimum viable telemetry for Phase 1 +- `throttleFraction` (EV pedal position, 0-1) +- `speedKmh` (road speed) +- `isValid` flag + +These three fields are available even at the low-fidelity tier (REST/Streaming API). CAN bus gives 50-100 Hz for high-fidelity. + +### Recommended strategy +- **MVP (demo)**: Streaming API at 2 Hz, interpolate to 60 Hz in adapter +- **Production**: CAN bus at 50-100 Hz via CAN adapter ($30-100 hardware) + +--- + +## ZF Automatic Transmission Data (for AutomaticGearbox) + +### ZF 8HP45 gear ratios (reference profile) + +| Gear | Ratio | Step | +|------|-------|------| +| 1st | 4.714 | - | +| 2nd | 3.143 | 1.50:1 | +| 3rd | 2.106 | 1.49:1 | +| 4th | 1.667 | 1.26:1 | +| 5th | 1.285 | 1.30:1 | +| 6th | 1.000 | 1.29:1 | +| 7th | 0.839 | 1.19:1 | +| 8th | 0.667 | 1.26:1 | + +### Shift map thresholds (illustrative, km/h) + +| Throttle | 1→2 | 2→3 | 3→4 | 4→5 | 5→6 | 6→7 | 7→8 | +|----------|-----|-----|-----|-----|-----|-----|-----| +| 10% | 12 | 22 | 32 | 42 | 52 | 62 | 72 | +| 50% | 25 | 40 | 55 | 72 | 88 | 105 | 125 | +| 100% | 45 | 70 | 95 | 120 | 148 | 178 | 210 | + +Shift time: ~0.2 seconds (ZF 8HP family). Hysteresis: downshift thresholds ~85% of upshift thresholds (15% speed gap prevents hunting). + +--- + +## Architecture Overview + +``` +┌─────────────────────────────────────────────────────────────────┐ +│ iOS App (integration point — depends on both libraries) │ +│ │ +│ VehicleSimWrapper.mm EngineSimWrapper.mm │ +│ │ │ │ +│ VehicleSimulator ──► VehicleSimAdapter ◄── IOSRunner │ +│ (vehicle-sim C++) (new adapter) (engine-sim-bridge C++) │ +│ │ │ │ │ +│ VehicleSignal UpstreamSignal BridgeSimulator │ +│ (10Hz BLE) (interpolated 60Hz) (ISimulator impl) │ +│ │ │ │ +│ VirtualIceInputProvider │ │ +│ (IInputProvider impl) │ │ +│ │ │ │ +│ VirtualIceTwin │ │ +│ (mapping model) │ │ +│ ┌──────┴───────┐ │ │ +│ │ AutoGearbox │ │ │ +│ │ ShiftCurves │ │ │ +│ │ ThrottleSmo │ │ │ +│ └──────┬───────┘ │ │ +│ │ throttle/gear/clutch │ +│ ▼ ▼ │ +│ ┌──────────────────────────┐ │ +│ │ engine-sim (physics) │ │ +│ │ Engine + Transmission + │ │ +│ │ Vehicle + VehicleDrag │ │ +│ │ Dyno DISABLED for driving│ │ +│ └──────────┬───────────────┘ │ +│ │ │ +│ RPM = f(throttle, gear, mass, drag) │ +│ │ │ +│ Audio Output │ +└─────────────────────────────────────────────────────────────────┘ +``` + +--- + +## Core Design Decision: Physics-Driven RPM (Validated) + +**RPM is strictly an OUTPUT of the physics engine.** Feed throttle + gear + clutch pressure into engine-sim's existing physics pipeline. RPM emerges naturally from the interaction of engine torque, vehicle inertia, and drag. + +### How engine-sim's physics produces RPM from inputs: +1. `changeGear(gear)` — sets effective vehicle inertia at crankshaft: `I = m_car * (tire_radius / (diff_ratio * gear_ratio))^2`. Lower gears = larger effective inertia = harder to accelerate. +2. `setClutchPressure(1.0)` — locks engine to drivetrain via ClutchConstraint (transmits up to maxClutchTorque) +3. `setThrottle(fraction)` — engine produces torque based on throttle position +4. `VehicleDragConstraint` — applies aero drag + rolling resistance as virtual torque (increases with speed^2) +5. RPM emerges from: engine torque vs (vehicle mass through gear ratio) + drag + +This is exactly how AngeTheGreat's original GUI does driving simulation. The dyno is NOT involved — it's a separate measurement tool for sweep/hold testing. + +### What the twin feeds engine-sim: +- **Throttle position** (from EV pedal, smoothed) +- **Gear selection** (computed by automatic gearbox from road speed + throttle) +- **Clutch pressure** (1.0 = locked, brief disengage during shifts) + +### What the twin does NOT set: +- RPM (output, never input) +- Dyno target speed (dyno stays disabled for driving) +- Crankshaft velocity + +--- + +## Gap Analysis: What Exists vs What's Missing + +### What engine-sim provides (zero modification needed) + +| Capability | Evidence | +|---|---| +| Full combustion physics (throttle -> RPM) | `CombustionChamber`, `GasSystem`, exhaust pipeline | +| Manual transmission with gear changes | `Transmission::changeGear()` — sets effective vehicle inertia | +| Clutch engagement/disengagement | `Transmission::setClutchPressure()` — locks engine to drivetrain | +| Vehicle inertia model (point mass via virtual rotating body) | `Vehicle`, `m_vehicleMass` RigidBody with `I = m * (tire/ratio)^2` | +| Aerodynamic drag + rolling resistance | `VehicleDragConstraint` — aero drag proportional to speed^2 | +| Starter motor for cranking | `StarterMotor` class | +| Ignition module | `IgnitionModule::m_enabled` | +| .mr script engine definitions | 236+ scripts, vehicle/transmission/engine parameters | +| Audio synthesis pipeline | `Synthesizer`, `writeToSynthesizer()` | +| Dynamometer (dyno sweep/hold testing) | `Dynamometer` — measurement tool, NOT for driving simulation | + +### What engine-sim needs (small accessor additions on our fork) + +~10 lines in `simulator.h` — no behavioral changes, no new classes: + +```cpp +// Transmission control (already partially public) +// changeGear() and setClutchPressure() are already callable + +// Vehicle state getters (needed for diagnostics) +double getVehicleAngularVelocity() const; +``` + +### Transmission getter gap (on our fork) + +Missing getters needed for automatic gearbox: +- `getGearRatios()` — array of gear ratios +- `getGearCount()` — number of forward gears +- `getMaxClutchTorque()` — clutch torque capacity + +These are pure accessors. The Piranha .mr parser already extracts these values during script loading. + +### What's entirely missing (new bridge code) + +| Component | Responsibility | Est. Lines | +|---|---|---| +| `VirtualIceTwin` | Core mapping model: state machine, gearbox, throttle smoothing | ~200 | +| `VirtualIceInputProvider` | `IInputProvider` impl, holds twin instance, applies outputs | ~100 | +| `IceVehicleProfile` | Gear ratios, diff, tire, shift points, redline, idle (from .mr) | ~80 | +| `AutomaticGearbox` | Shift curves, hysteresis, kickdown detection | ~150 | +| `UpstreamSignal` | Normalized EV telemetry struct (0-1 range) | ~20 | +| `VehicleSimAdapter` | iOS adapter: VehicleSignal → UpstreamSignal + interpolation | ~100 | +| ISimulator extension | `setGear()`, `setClutchPressure()`, `getEngineRpm()` virtual methods | ~30 | +| Tests | TDD for all new components | ~400 | + +**Total new code: ~1000 lines C++, all in the bridge layer except the ~15-line accessor additions to engine-sim.** + +--- + +## EV-to-ICE Mapping Model + +### Twin Input (from vehicle-sim or CAN bus) + +```cpp +struct UpstreamSignal { + double throttleFraction = 0.0; // 0.0 - 1.0 + double speedKmh = 0.0; + double accelerationG = 0.0; + double brakeFraction = 0.0; + uint64_t timestampUtcMs = 0; + bool isValid = false; +}; +``` + +### Twin Output (to engine-sim) + +```cpp +struct TwinOutput { + double throttle; // 0-1 (smoothed from EV throttle) + int gear; // Selected gear index + double clutchPressure; // 0-1 (1.0 = locked in MVP) + bool starterMotor; + bool ignition; +}; +``` + +### Automatic Gearbox Algorithm + +Shift curves parameterized by throttle: + +``` +upshiftRPM(throttle) = idleRpm + (redlineRpm - idleRpm) * (0.45 + 0.55 * throttle) +downshiftRPM(throttle) = idleRpm + (redlineRpm - idleRpm) * (0.25 + 0.20 * throttle) +``` + +- Light throttle (0.1): upshift ~2500, downshift ~1500 +- Full throttle (1.0): upshift ~6700, downshift ~3000 +- Hysteresis gap prevents gear hunting +- Kickdown: throttle delta > 0.4 triggers immediate downshift + +### RPM Computation (diagnostic/gear-selection only) + +``` +RPM = (speedMs / (2π × tireRadius)) × gearRatio × diffRatio × 60 +``` + +Used to determine shift points and for display. NOT fed to engine-sim — physics computes actual RPM. + +### Throttle Smoothing + +EVs have instant response. Apply low-pass filter: +``` +filteredThrottle += (rawThrottle - filteredThrottle) * (1 - exp(-dt / TAU)) +``` +TAU = 50ms. Prevents the ICE sound from feeling unnaturally sharp. + +### State Machine + +``` +OFF → (first telemetry) → CRANKING → (RPM > 550) → IDLE +IDLE ↔ RUNNING (throttle > 5%) +RUNNING ↔ SHIFTING (gear change triggered) +RUNNING → IDLE (speed → 0, throttle → 0) +Any → OFF (no telemetry for N seconds) +``` + +| State | Throttle | Clutch | RPM | +|---|---|---|---| +| OFF | 0 | disengaged | 0 | +| CRANKING | 0 | 0.3 | starter ~200 | +| IDLE | 0.05 | 0.5 | ~700-800 | +| RUNNING | mapped | 1.0 (locked) | physics-driven | +| SHIFTING | held | ramped 0→1 | natural flare | + +--- + +## Integration Boundary: vehicle-sim → bridge + +### Key constraint +vehicle-sim's PRODUCT_VISION prohibits build dependency on engine-sim. Both compile independently. + +### Data flow +- Bridge owns `UpstreamSignal` (not shared from vehicle-sim) +- iOS app is the integration point — depends on both libraries +- `VehicleSimAdapter` (in iOS app target) maps `VehicleSignal` → `UpstreamSignal` +- Threading: vehicle-sim writes at 10Hz, bridge reads at 60Hz, adapter interpolates + +### Lifecycle +- Bridge starts first (plays idle audio immediately) +- vehicle-sim connects when BLE is ready +- On disconnect: bridge ramps to idle, no audio artifacts +- On reconnect: ramps back up + +### ESP32 target +- No vehicle-sim. `CANInputProvider` reads CAN frames → `UpstreamSignal` +- Bridge is source-agnostic + +--- + +## Implementation Phases + +### Phase 1: Core Twin (MVP — end-to-end pipeline) + +**Goal**: Prove the physics-driven approach produces authentic sound from EV telemetry. + +Components to build: +1. `UpstreamSignal` struct (`bridge/include/io/UpstreamSignal.h`) +2. `IceVehicleProfile` struct (`bridge/include/twin/IceVehicleProfile.h`) +3. `AutomaticGearbox` class (`bridge/src/twin/AutomaticGearbox.cpp`) +4. `VirtualIceTwin` class — state machine + throttle smoothing (`bridge/src/twin/VirtualIceTwin.cpp`) +5. `VirtualIceInputProvider` — `IInputProvider` impl (`bridge/src/input/VirtualIceInputProvider.cpp`) +6. ISimulator extension — `setGear()`, `setClutchPressure()`, `getEngineRpm()` (`bridge/include/simulator/ISimulator.h`) +7. Engine-sim accessor additions (~15 lines in `simulator.h`) + +**Acceptance criteria:** +- Given a recorded EV telemetry file (throttle ramp 0→100, speed ramp 0→100km/h), the twin selects gears correctly (1→2→3→4→5→6) +- Engine RPM tracks road speed within 10% (physics-driven, not dyno) +- Audio output sounds like an ICE vehicle accelerating through gears +- All new code has TDD test coverage (see Testing section) +- SOLID/DRY critic sign-off before commit + +**MVP scope excludes**: torque converter slip, cranking sequence, kickdown, acceleration-informed throttle, dyno fallback. + +### Phase 2: Polish + iOS Integration + +**Goal**: Connect vehicle-sim demo data to the twin on iPhone. + +Components: +1. `VehicleSimAdapter` (iOS app target) +2. 10Hz→60Hz interpolation +3. Stale data handling (ramp to idle) +4. iOS UI for vehicle profile selection + +**Acceptance criteria:** +- vehicle-sim demo data drives engine-sim audio through the twin +- No audio artifacts on BLE connect/disconnect +- Profile selection loads different .mr scripts + +### Phase 3: Automatic Transmission in engine-sim (optional upstream contribution) + +**Goal**: Add proper `AutomaticTransmission` + `TorqueConverter` to engine-sim. + +Components (all in engine-sim): +1. `TorqueConverter` — new SCS constraint (fluid coupling between two bodies) +2. `AutomaticTransmission` — new class parallel to `Transmission` +3. Shift scheduling as part of `AutomaticTransmission::update()` + +**Why defer**: Phase 1's bridge-level gearbox works by calling `changeGear()` externally. Proper automatic transmission in engine-sim is cleaner (physics-timestep shift scheduling) but is a larger change that benefits from Phase 1 validating the approach first. + +**Acceptance criteria:** +- `AutomaticTransmission` follows same `initialize(Parameters)` pattern as `Transmission` +- Shift scheduling runs at physics timestep (10kHz), not bridge timestep (60Hz) +- Torque converter produces realistic slip behavior at launch +- Pre-generated C++ support (no .mr parser dependency) + +### Phase 4: Pre-generation + Mobile Targets — DONE + +**Goal**: Strip .mr parser for iPhone/ESP32; load engines as JSON presets. + +**What was built** (see `docs/PRESET_ENGINE_ISOMORPHIC_SCRIPT.md`): +- `engine-sim-preset-compiler` compiles `.mr` → `.json` at build time +- `PresetEngineFactory::loadFromFile()` loads JSON at runtime (no Piranha) +- `--script foo.json` works via isomorphic extension routing in SimulatorFactory +- 28/28 preset tests pass, end-to-end audio verified + +**Impact on twin**: The twin can load any engine as JSON on iOS. `PresetLoadResult` +returns `Engine*`, `Vehicle*`, `Transmission*` — the twin feeds throttle/gear/clutch +through the physics pipeline. No Piranha, no hand-coded configs. + +--- + +## Testing Strategy (TDD) + +### Red/Green/Refactor discipline +Every component is test-driven. RED phase tests MUST compile. Tests assert correct business behavior, not implementation details. + +### Test categories + +**Unit tests (pure logic, no engine-sim dependency):** + +| Test Suite | Validates | +|---|---| +| `AutomaticGearboxTest` | Shift up/down decisions, hysteresis, kickdown, edge cases (redline, standstill) | +| `VirtualIceTwinTest` | State machine transitions (OFF→CRANKING→IDLE→RUNNING→SHIFTING→IDLE) | +| `ThrottleSmootherTest` | Exponential filter behavior, step response, steady-state accuracy | +| `IceVehicleProfileTest` | Profile loading, parameter validation | +| `UpstreamSignalTest` | Normalization (0-100 → 0-1), staleness detection | + +**Integration tests (with engine-sim, no audio hardware):** + +| Test Suite | Validates | +|---|---| +| `TwinPhysicsIntegrationTest` | Feed synthetic telemetry → twin → engine-sim → verify RPM tracks within tolerance | +| `GearChangeAudioTest` | Verify audio buffer contains audible difference between gears | +| `StartupSequenceTest` | Cranking → catch → idle produces correct RPM progression | + +**Acceptance tests (end-to-end with mock telemetry):** + +| Test Suite | Validates | +|---|---| +| `AccelerationScenarioTest` | Full throttle 0→100km/h: gears shift correctly, RPM behaves naturally | +| `DecelerationScenarioTest` | Lift off at 100km/h: engine braking sounds, downshifts occur | +| `StandstillScenarioTest` | 0 km/h with throttle: idle behavior, no RPM runaway | +| `DisconnectScenarioTest` | BLE disconnect mid-drive: ramp to idle gracefully | + +### Test data +- Synthetic telemetry files (CSV): acceleration run, highway cruise, city driving, standstill +- No dependency on live BLE hardware +- No dependency on live audio hardware (mock the audio callback) + +### Acceptance criteria for "done" +1. All unit + integration tests pass +2. SOLID compliance: each class has single responsibility, open for extension, depends on abstractions +3. DRY: no duplicated gear ratio logic, no duplicated throttle mapping +4. Test coverage ≥ 90% on new code (happy path + reasonable edge cases) +5. SOLID/DRY critic agent has reviewed and approved (see Quality Gate below) + +--- + +## Quality Gate: SOLID/DRY Critic + +Before any code is committed, a dedicated **architecture critic agent** must review and approve. The critic enforces: + +- **SRP**: Each class has one reason to change. `VirtualIceTwin` maps telemetry to engine commands. `AutomaticGearbox` selects gears. `VirtualIceInputProvider` adapts to the simulation loop. No god classes. +- **OCP**: New vehicle profiles or gearbox algorithms are added by creating new types, not modifying existing ones. +- **LSP**: Any `IInputProvider` implementation works in the simulation loop without special-casing. +- **ISP**: `ISimulator` extensions are in a separate `ITwinControl` interface if they're twin-specific (keep base `ISimulator` clean for keyboard/sine use cases). +- **DIP**: Twin depends on `UpstreamSignal` (abstraction), not `VehicleSignal` (vehicle-sim concrete type). Bridge depends on `IInputProvider`, not concrete providers. +- **DRY**: Gear ratios live in `IceVehicleProfile` only. Speed-to-RPM formula is in one place. No copy-paste between test and production code. +- **No over-engineering**: No `TorqueConverter` until Phase 3. No shift mode enums until needed. No factory patterns for single implementations. + +The critic MUST explicitly sign off in the commit workflow. If the critic rejects, the issue must be fixed before proceeding. + +--- + +## Key Files Referenced + +### Existing (to extend, not modify behaviorally) +- `engine-sim/include/simulator.h` — add ~15 lines of accessors +- `engine-sim-bridge/include/simulator/ISimulator.h` — add twin control virtuals +- `engine-sim-bridge/include/io/IInputProvider.h` — unchanged (twin uses it) +- `engine-sim-bridge/src/simulator/BridgeSimulator.cpp` — implement new virtuals + +### New (bridge layer) +- `engine-sim-bridge/include/io/UpstreamSignal.h` +- `engine-sim-bridge/include/twin/IceVehicleProfile.h` +- `engine-sim-bridge/include/twin/TwinOutput.h` +- `engine-sim-bridge/include/twin/VirtualIceTwin.h` +- `engine-sim-bridge/include/twin/AutomaticGearbox.h` +- `engine-sim-bridge/include/physics/SpeedTrackingForce.h` (Approach A+) +- `engine-sim-bridge/include/physics/FixedLoadConstraint.h` (Approach B) +- `engine-sim-bridge/src/twin/IceVehicleProfile.cpp` +- `engine-sim-bridge/src/twin/VirtualIceTwin.cpp` +- `engine-sim-bridge/src/twin/AutomaticGearbox.cpp` +- `engine-sim-bridge/src/input/VirtualIceInputProvider.cpp` +- `engine-sim-bridge/src/physics/SpeedTrackingForce.cpp` +- `engine-sim-bridge/src/physics/FixedLoadConstraint.cpp` +- `engine-sim-bridge/test/twin/AutomaticGearboxTest.cpp` +- `engine-sim-bridge/test/twin/VirtualIceTwinTest.cpp` +- `engine-sim-bridge/test/twin/IceVehicleProfileTest.cpp` +- `engine-sim-bridge/test/integration/TwinPhysicsIntegrationTest.cpp` + +### Existing docs to extend (not create orphans) +- `docs/BRIDGE_INTEGRATION_ARCHITECTURE.md` — update Phase 3 TODO with this plan's detail + +### Research artifacts (persistent reports in memory/) +- `memory/physics-specialist-analysis.md` — ForceGenerator integration point, constraint solver analysis, Approach A+/B design +- `memory/solution-architecture-proposal.md` — Full component interfaces, file organization, implementation order, SOLID compliance +- `memory/web-research-report.md` — EV telemetry availability, ZF transmission shift data, AVAS regulations, sound synthesis approaches +- `memory/architecture-decisions.md` — Key architectural decisions, Phase 0 spike results, CLI control mappings + +--- + +## Open Questions for User + +1. **RESOLVED — ISimulator vs ITwinControl**: Phase 1 extends `EngineInput` with `gearAbsolute`, `clutchPressure`, and `vehicleSpeedTargetKmh` fields. Consistent with existing `gearDelta`/`dynoTorqueScale` pattern. ITwinControl deferred until a second twin-type provider emerges. + +2. **RESOLVED — Physics-driven as primary**: Approach A+ (full vehicle + SpeedTrackingForce) is primary. Approach B (FixedLoadConstraint) is the documented fallback if speed drift is unacceptable. + +3. **RESOLVED — Torque converter not needed for MVP**: ZF lockup clutch engages early (often 2nd gear+). Launch slip approximated via clutch pressure ramping. Full fluid coupling model deferred to Phase 3. + +4. **Vehicle profile source**: MVP hardcodes 2-3 profiles (GM LS, Ferrari F136, Honda TRX520) as C++ constants. .mr script parsing for profile extraction is Phase 2+. + +5. **RESOLVED — Telemetry source**: vehicle-sim submodule (not Tesla API). Road speed, motor torque, throttle position etc. come from vehicle-sim at adequate rate. Out of scope for this repo to solve — vehicle-sim is the data provider. + +6. **RESOLVED — SpeedTrackingForce tuning**: Out of scope for this repo. vehicle-sim provides real road speed and motor torque which the twin consumes. Speed drift correction (if needed) happens when we have real data flowing. + +--- + +## Remaining Open Questions + +### Q1: .mr script compatibility — scripts without main() crash engine-sim + +**Problem**: Most downloadable .mr files (e.g. from AngeTheGreat's repository) crash with a segfault when loaded via `--script` because they reference `main.mr` which expects a full GUI environment. Our adapted scripts (ferrari_f136, C63_M156, merlin) work because we removed the `main.mr` dependency and call `main()` directly. + +**Impact**: Limits which vehicles can be simulated without manual .mr editing. C63 AMG is a high-priority target for the twin. + +**What's needed to answer**: Investigate what `main.mr` does (likely sets up GUI, default theme, sound settings) and determine the minimum stub needed to make arbitrary .mr scripts loadable headlessly. Likely a bridge-specific `main.mr` stub that provides the same setup without GUI dependencies. + +### Q2: Automatic gearbox shift curve validation + +**Problem**: The plan specifies shift curves parameterized by throttle, but the thresholds (upshiftBaseFraction, upshiftThrottleCoeff) haven't been validated against real ZF behavior. + +**Impact**: Wrong shift points produce unrealistic sound — shifting too early sounds sluggish, too late sounds aggressive. + +**What's needed to answer**: Compare the algorithm's shift decisions against published ZF shift maps at various throttle/speed combinations. Can be done with unit tests comparing against the web research data (ZF 8HP45 shift table in km/h per throttle position). + +### Q3: SpeedTrackingForce — is it needed at all? + +**Problem**: Approach A+ includes a drift correction ForceGenerator, but we won't know if drift is significant until the pipeline runs end-to-end with real telemetry. + +**Impact**: If drift is <2%, the ForceGenerator adds unnecessary complexity and potential audio artifacts. + +**What's needed to answer**: Build the Phase 1 pipeline with SpeedTrackingForce disabled. Measure virtual vs real speed divergence over a test scenario. Enable only if drift exceeds 5%. + +### Q4: RESOLVED — Vehicle profile parameterization from .mr scripts + +**Problem**: IceVehicleProfile needs gear ratios, diff ratio, tire radius, mass, idle/redline RPM. + +**Resolution**: JSON presets capture all engine/vehicle/transmission parameters during +Piranha compilation. `PresetLoadResult` provides fully-initialized objects with all +data accessible via the 29 Phase 2 getters. The `preset_compiler` runs at build time, +so runtime doesn't need Piranha or new accessors. diff --git a/docs/archive/PRESET_ENGINE_PLAN.md b/docs/archive/PRESET_ENGINE_PLAN.md new file mode 100644 index 0000000..03d0845 --- /dev/null +++ b/docs/archive/PRESET_ENGINE_PLAN.md @@ -0,0 +1,105 @@ +# Preset Engine: Build-Time .mr → C++ Compilation + +## Goal + +Compile `.mr` engine definition scripts into static C++ preset classes at build time. +Desktop: Piranha runtime + presets. iOS/ESP32: presets only, zero Piranha. + +## Status Tracker + +### Phase 1: Fix existing preset tests — DONE +- [x] ConvolutionFilter null-deref fix (SimulatorInitHelpers) +- [x] Intake air mixture initialization (21% O2, 79% N2) +- [x] Flow function unit mismatch (filter radius 0 → 50 thou) +- [x] Throttle inversion (DirectThrottleLinkage semantics) +- [x] Simulation frequency mismatch (10000 vs 40000) +- [x] Piranha crash in SimulatorFactory (scope guard for compiler) +- [x] **Result: 16/16 tests pass, 2 golden skipped** + +### Phase 2: Public API getters in engine-sim — DONE +- [x] Function: getSampleCount, getX, getY, getFilterRadius, getInputScale, getOutputScale +- [x] Transmission: getGearCount, getGearRatio, getMaxClutchTorque +- [x] Intake: getVolume, getInputFlowK, getIdleFlowK, getIdleThrottlePlatePosition +- [x] CylinderHead: getIntakePortFlow, getExhaustPortFlow +- [x] ExhaustSystem: getOutletFlowRate +- [x] Camshaft: getLobeCount +- [x] IgnitionModule: getTimingCurve, getRevLimit, getLimiterDuration, getCylinderCount, getFiringOrder +- **29 lines total, all additive, no logic changes to 3rd party code** + +### Phase 3: .mr → C++ codegen tool — DONE +- [x] `tools/preset_codegen.cpp` — builds and runs +- [x] Reads actual values from Piranha-compiled engine (not hardcoded) +- [x] Emits: engine params, crankshafts, exhaust, intake, cylinder banks, camshafts, + port flows, fuel, ignition timing/firing order, combustion chambers, vehicle, transmission +- [x] Air mixture initialization in generated code +- [x] Per-cylinder intake/exhaust wiring (reads from compiled engine, not counts) +- [x] Bank-indexed variable names (no collisions on multi-bank engines) +- [x] CMakeLists.txt: `engine-sim-preset-codegen` target +- **Verified: Honda (1 cyl), Subaru (4 cyl V-flat), Ferrari F136 (8 cyl V8) all compile and run** + +### Phase 4: Wire presets into CLI — NOT STARTED +- [ ] Add `PresetEngine` to `SimulatorType` enum +- [ ] Register codegen output classes in bridge (preset registry) +- [ ] `SimulatorFactory::create()` handles PresetEngine type (no Piranha) +- [ ] CLI `--preset ferrari_f136` flag +- [ ] Header display: `Script:` (cyan) vs `Preset:` (purple) +- [ ] Conditional compilation: iOS builds get presets only, no Piranha + +### Phase 5: CMake bulk generation — NOT STARTED +- [ ] `generate_preset()` CMake function for custom commands +- [ ] Auto-generate from all `.mr` scripts in engine-sim/assets/engines/ +- [ ] Generated `.cpp` files added to bridge library sources +- [ ] iOS build: include generated presets, exclude Piranha target + +## Files Changed (uncommitted) + +### engine-sim (3rd party submodule) — minimal getters only +``` +include/camshaft.h +1 +include/cylinder_head.h +3 +include/exhaust_system.h +1 +include/function.h +7 +include/ignition_module.h +6 +include/intake.h +4 +include/transmission.h +3 +src/ignition_module.cpp +4 +``` + +### engine-sim-bridge (our code) +``` +.gitignore build artifact patterns +CMakeLists.txt preset-codegen target +include/simulator/SimulatorInitHelpers.h convolution filter helper +include/simulator/EnginePresetsHelper.h NEW — shared DRY helpers +src/simulator/SimulatorInitHelpers.cpp convolution filter impl +src/simulator/EnginePresets.cpp air mix, filter radius fixes +src/simulator/PresetEngineFactory.cpp DRY refactor, correctness fixes +src/simulator/SimulatorFactory.cpp Piranha crash fix +src/simulator/EnginePresetsHelper.h NEW — shared helper header +tools/preset_codegen.cpp NEW — .mr → C++ codegen +test/PresetEngineTests.cpp test fixes (16/16 pass) +``` + +## What's Left for Phase 4 (CLI Integration) + +The codegen tool produces standalone C++ classes with `static Simulator* create()`. +The CLI needs a way to select and instantiate these without Piranha. + +1. **Preset registry** — map of name → factory function +2. **SimulatorFactory** — new `PresetEngine` branch that looks up from registry +3. **CLI flag** — `--preset ferrari_f136` selects from registry +4. **Display** — label as "Preset:" (purple) vs "Script:" (cyan) +5. **Conditional build** — `#ifdef ATG_ENGINE_SIM_PIRANHA_ENABLED` gates script path + +## Build Commands + +```bash +# Full build from root (only way to build) +make + +# Tests +make test + +# Run CLI with Piranha script +./build/engine-sim-cli --interactive --play --script es/ferrari_f136.mr +``` diff --git a/engine-sim-bridge b/engine-sim-bridge index bcdedc7..67c4272 160000 --- a/engine-sim-bridge +++ b/engine-sim-bridge @@ -1 +1 @@ -Subproject commit bcdedc7b4df1722c45990bd37176a2b60d2bf871 +Subproject commit 67c42722009ad1fe43e5717e8d3c48c3a9b053cf diff --git a/es/08_ferrari_f136_v8.mr b/es/08_ferrari_f136_v8.mr deleted file mode 100644 index 781b70a..0000000 --- a/es/08_ferrari_f136_v8.mr +++ /dev/null @@ -1,451 +0,0 @@ -import "engine_sim.mr" - -units units() -constants constants() -impulse_response_library ir_lib() -label cycle(2 * 360 * units.deg) - -private node wires { - output wire1: ignition_wire(); - output wire2: ignition_wire(); - output wire3: ignition_wire(); - output wire4: ignition_wire(); - output wire5: ignition_wire(); - output wire6: ignition_wire(); - output wire7: ignition_wire(); - output wire8: ignition_wire(); -} - -private node f136_head { - input intake_camshaft; - input exhaust_camshaft; - input chamber_volume: 90 * units.cc; - input intake_runner_volume: 149.6 * units.cc; - input intake_runner_cross_section_area: 2.2 * units.inch * 2.2 * units.inch; - input exhaust_runner_volume: 50.0 * units.cc; - input exhaust_runner_cross_section_area: 1.75 * units.inch * 1.75 * units.inch; - - input flow_attenuation: 1.0; - input lift_scale: 1.0; - input flip_display: false; - alias output __out: head; - - function intake_flow(50 * units.thou) - intake_flow - .add_flow_sample(0 * lift_scale, 0 * flow_attenuation) - .add_flow_sample(50 * lift_scale, 58 * flow_attenuation) - .add_flow_sample(100 * lift_scale, 103 * flow_attenuation) - .add_flow_sample(150 * lift_scale, 156 * flow_attenuation) - .add_flow_sample(200 * lift_scale, 214 * flow_attenuation) - .add_flow_sample(250 * lift_scale, 249 * flow_attenuation) - .add_flow_sample(300 * lift_scale, 268 * flow_attenuation) - .add_flow_sample(350 * lift_scale, 280 * flow_attenuation) - .add_flow_sample(400 * lift_scale, 280 * flow_attenuation) - .add_flow_sample(450 * lift_scale, 281 * flow_attenuation) - - function exhaust_flow(50 * units.thou) - exhaust_flow - .add_flow_sample(0 * lift_scale, 0 * flow_attenuation) - .add_flow_sample(50 * lift_scale, 37 * flow_attenuation) - .add_flow_sample(100 * lift_scale, 72 * flow_attenuation) - .add_flow_sample(150 * lift_scale, 113 * flow_attenuation) - .add_flow_sample(200 * lift_scale, 160 * flow_attenuation) - .add_flow_sample(250 * lift_scale, 196 * flow_attenuation) - .add_flow_sample(300 * lift_scale, 222 * flow_attenuation) - .add_flow_sample(350 * lift_scale, 235 * flow_attenuation) - .add_flow_sample(400 * lift_scale, 245 * flow_attenuation) - .add_flow_sample(450 * lift_scale, 246 * flow_attenuation) - - generic_cylinder_head head( - chamber_volume: chamber_volume, - intake_runner_volume: intake_runner_volume, - intake_runner_cross_section_area: intake_runner_cross_section_area, - exhaust_runner_volume: exhaust_runner_volume, - exhaust_runner_cross_section_area: exhaust_runner_cross_section_area, - - intake_port_flow: intake_flow, - exhaust_port_flow: exhaust_flow, - valvetrain: standard_valvetrain( - intake_camshaft: intake_camshaft, - exhaust_camshaft: exhaust_camshaft - ), - flip_display: flip_display - ) -} - -private node f136_camshaft { - input lobe_profile; - input intake_lobe_profile: lobe_profile; - input exhaust_lobe_profile: lobe_profile; - input lobe_separation: 114 * units.deg; - input intake_lobe_center: lobe_separation; - input exhaust_lobe_center: lobe_separation; - input advance: 0 * units.deg; - input base_radius: 0.5 * units.inch; - - output intake_cam_0: _intake_cam_0; - output exhaust_cam_0: _exhaust_cam_0; - - output intake_cam_1: _intake_cam_1; - output exhaust_cam_1: _exhaust_cam_1; - - camshaft_parameters params ( - advance: advance, - base_radius: base_radius - ) - - camshaft _intake_cam_0(params, lobe_profile: intake_lobe_profile) - camshaft _exhaust_cam_0(params, lobe_profile: exhaust_lobe_profile) - camshaft _intake_cam_1(params, lobe_profile: intake_lobe_profile) - camshaft _exhaust_cam_1(params, lobe_profile: exhaust_lobe_profile) - - label rot(90 * units.deg) - label rot360(360 * units.deg) - - // 1 5 3 7 4 8 2 6 - _exhaust_cam_0 - .add_lobe(rot360 - exhaust_lobe_center + 0 * rot) // 1 - .add_lobe(rot360 - exhaust_lobe_center + 6 * rot) // 2 - .add_lobe(rot360 - exhaust_lobe_center + 2 * rot) // 3 - .add_lobe(rot360 - exhaust_lobe_center + 4 * rot) // 4 - _intake_cam_0 - .add_lobe(rot360 + intake_lobe_center + 0 * rot) // 1 - .add_lobe(rot360 + intake_lobe_center + 6 * rot) // 2 - .add_lobe(rot360 + intake_lobe_center + 2 * rot) // 3 - .add_lobe(rot360 + intake_lobe_center + 4 * rot) // 4 - - _exhaust_cam_1 - .add_lobe(rot360 - exhaust_lobe_center + 1 * rot) // 5 - .add_lobe(rot360 - exhaust_lobe_center + 7 * rot) // 6 - .add_lobe(rot360 - exhaust_lobe_center + 3 * rot) // 7 - .add_lobe(rot360 - exhaust_lobe_center + 5 * rot) // 8 - _intake_cam_1 - .add_lobe(rot360 + intake_lobe_center + 1 * rot) // 5 - .add_lobe(rot360 + intake_lobe_center + 7 * rot) // 6 - .add_lobe(rot360 + intake_lobe_center + 3 * rot) // 7 - .add_lobe(rot360 + intake_lobe_center + 5 * rot) // 8 -} - -private node turbulence_to_flame_speed_ratio { - alias output __out: - function(5.0) - .add_sample(0.0, 3.0) - .add_sample(5.0, 1.5 * 5.0) - .add_sample(10.0, 1.75 * 10.0) - .add_sample(15.0, 2.0 * 15.0) - .add_sample(20.0, 2.0 * 20.0) - .add_sample(25.0, 2.0 * 25.0) - .add_sample(30.0, 2.0 * 30.0) - .add_sample(35.0, 2.0 * 35.0) - .add_sample(40.0, 2.0 * 40.0) - .add_sample(45.0, 2.0 * 45.0); -} - -public node f136_v8 { - alias output __out: engine; - - engine engine( - name: "Ferrari F136", - starter_torque: 200 * units.lb_ft, - starter_speed: 200 * units.rpm, - redline: 9000 * units.rpm, - throttle_gamma: 2.0, - fuel: fuel( - max_burning_efficiency: 1.0, - turbulence_to_flame_speed_ratio: turbulence_to_flame_speed_ratio() - ), - hf_gain: 0.01, - noise: 1.0, - jitter: 0.15, - simulation_frequency: 10000 - ) - - wires wires() - - label stroke(81 * units.mm) - label bore(94 * units.mm) - label rod_length(160 * units.mm) - label rod_mass(50 * units.g) - label compression_height(1.0 * units.inch) - label crank_mass(60 * units.lb) - label flywheel_mass(30 * units.lb) - label flywheel_radius(8 * units.inch) - - label crank_moment( - 1.5 * disk_moment_of_inertia(mass: crank_mass, radius: stroke) - ) - label flywheel_moment( - disk_moment_of_inertia(mass: flywheel_mass, radius: flywheel_radius) - ) - label other_moment( // Moment from cams, pulleys, etc [estimated] - disk_moment_of_inertia(mass: 1 * units.kg, radius: 1.0 * units.cm) - ) - - label v_angle(90 * units.deg) - crankshaft c0( - throw: stroke / 2, - flywheel_mass: flywheel_mass, - mass: crank_mass, - friction_torque: 20.0 * units.lb_ft, - moment_of_inertia: - crank_moment + flywheel_moment + other_moment, - position_x: 0.0, - position_y: 0.0, - tdc: 90 * units.deg + (v_angle / 2.0) - ) - - // 1 5 3 7 4 8 2 6 - rod_journal rj0(angle: 0 * units.deg) - rod_journal rj1(angle: 180 * units.deg) - rod_journal rj2(angle: 180 * units.deg) - rod_journal rj3(angle: 0 * units.deg) - c0 - .add_rod_journal(rj0) - .add_rod_journal(rj1) - .add_rod_journal(rj2) - .add_rod_journal(rj3) - - piston_parameters piston_params( - // 414 - piston mass, 152 - pin weight - mass: (100) * units.g, - compression_height: compression_height, - wrist_pin_position: 0.0, - displacement: 0.0 - ) - - connecting_rod_parameters cr_params( - mass: rod_mass, - moment_of_inertia: rod_moment_of_inertia( - mass: rod_mass, - length: rod_length - ), - center_of_mass: 0.0, - length: rod_length - ) - - intake intake( - plenum_volume: 1.325 * units.L, - plenum_cross_section_area: 20.0 * units.cm2, - intake_flow_rate: k_carb(700.0), - runner_flow_rate: k_carb(100.0), - runner_length: 12.0 * units.inch, - idle_flow_rate: k_carb(0.0), - idle_throttle_plate_position: 0.995, - velocity_decay: 0.5 - ) - - exhaust_system_parameters es_params( - outlet_flow_rate: k_carb(1000.0), - primary_tube_length: 29.0 * units.inch, - primary_flow_rate: k_carb(600.0), - velocity_decay: 0.5 - ) - - exhaust_system exhaust0( - es_params, - audio_volume: 2.0 * 0.1, - length: 100 * units.inch, - impulse_response: ir_lib.mild_exhaust_0_reverb - - ) - exhaust_system exhaust1( - es_params, - audio_volume: 2.0 * 0.09, - length: 100 * units.inch, - impulse_response: ir_lib.mild_exhaust_0_reverb - ) - - cylinder_bank_parameters bank_params( - bore: bore, - deck_height: stroke / 2 + rod_length + compression_height - ) - - label spacing(5 * units.inch) - - cylinder_bank b0(bank_params, angle: v_angle / 2.0) - cylinder_bank b1(bank_params, angle: -v_angle / 2.0) - b0 - .add_cylinder( - piston: piston(piston_params, blowby: k_28inH2O(0.0)), - connecting_rod: connecting_rod(cr_params), - rod_journal: rj0, - intake: intake, - exhaust_system: exhaust0, - ignition_wire: wires.wire1, - sound_attenuation: 0.9, - primary_length: 2 * units.cm - ) - .add_cylinder( - piston: piston(piston_params, blowby: k_28inH2O(0.0)), - connecting_rod: connecting_rod(cr_params), - rod_journal: rj1, - intake: intake, - exhaust_system: exhaust0, - ignition_wire: wires.wire2, - sound_attenuation: 0.8, - primary_length: 1 * units.cm - ) - .add_cylinder( - piston: piston(piston_params, blowby: k_28inH2O(0.0)), - connecting_rod: connecting_rod(cr_params), - rod_journal: rj2, - intake: intake, - exhaust_system: exhaust0, - ignition_wire: wires.wire3, - sound_attenuation: 1.1, - primary_length: 3 * units.cm - ) - .add_cylinder( - piston: piston(piston_params, blowby: k_28inH2O(0.0)), - connecting_rod: connecting_rod(cr_params), - rod_journal: rj3, - intake: intake, - exhaust_system: exhaust0, - ignition_wire: wires.wire4, - sound_attenuation: 1.0, - primary_length: 5 * units.cm - ) - .set_cylinder_head( - f136_head( - intake_camshaft: camshaft.intake_cam_0, - exhaust_camshaft: camshaft.exhaust_cam_0, - flip_display: true, - flow_attenuation: 1.0) - ) - b1 - .add_cylinder( - piston: piston(piston_params, blowby: k_28inH2O(0.0)), - connecting_rod: connecting_rod(cr_params), - rod_journal: rj0, - intake: intake, - exhaust_system: exhaust1, - ignition_wire: wires.wire5, - sound_attenuation: 1.0, - primary_length: 1 * units.cm - ) - .add_cylinder( - piston: piston(piston_params, blowby: k_28inH2O(0.0)), - connecting_rod: connecting_rod(cr_params), - rod_journal: rj1, - intake: intake, - exhaust_system: exhaust1, - ignition_wire: wires.wire6, - sound_attenuation: 0.8, - primary_length: 5 * units.cm - ) - .add_cylinder( - piston: piston(piston_params, blowby: k_28inH2O(0.0)), - connecting_rod: connecting_rod(cr_params), - rod_journal: rj2, - intake: intake, - exhaust_system: exhaust1, - ignition_wire: wires.wire7, - sound_attenuation: 0.9, - primary_length: 7 * units.cm - ) - .add_cylinder( - piston: piston(piston_params, blowby: k_28inH2O(0.0)), - connecting_rod: connecting_rod(cr_params), - rod_journal: rj3, - intake: intake, - exhaust_system: exhaust1, - ignition_wire: wires.wire8, - sound_attenuation: 0.7, - primary_length: 0 * units.cm - ) - .set_cylinder_head( - f136_head( - intake_camshaft: camshaft.intake_cam_1, - exhaust_camshaft: camshaft.exhaust_cam_1, - flow_attenuation: 1.0) - ) - - engine - .add_cylinder_bank(b0) - .add_cylinder_bank(b1) - - engine.add_crankshaft(c0) - - harmonic_cam_lobe intake_lobe( - duration_at_50_thou: 230 * units.deg, - gamma: 0.9, - lift: 551 * units.thou, - steps: 256 - ) - - harmonic_cam_lobe exhaust_lobe( - duration_at_50_thou: 230 * units.deg, - gamma: 0.9, - lift: 551 * units.thou, - steps: 256 - ) - - f136_camshaft camshaft( - lobe_profile: "N/A", - - intake_lobe_profile: intake_lobe, - exhaust_lobe_profile: exhaust_lobe, - intake_lobe_center: 116 * units.deg, - exhaust_lobe_center: 116 * units.deg, - base_radius: 1.0 * units.inch - ) - - function timing_curve(1000 * units.rpm) - timing_curve - .add_sample(0000 * units.rpm, 12 * units.deg) - .add_sample(1000 * units.rpm, 12 * units.deg) - .add_sample(2000 * units.rpm, 20 * units.deg) - .add_sample(3000 * units.rpm, 30 * units.deg) - .add_sample(4000 * units.rpm, 40 * units.deg) - .add_sample(5000 * units.rpm, 40 * units.deg) - .add_sample(6000 * units.rpm, 40 * units.deg) - .add_sample(7000 * units.rpm, 40 * units.deg) - .add_sample(8000 * units.rpm, 40 * units.deg) - - ignition_module ignition_module( - timing_curve: timing_curve, - rev_limit: 9300 * units.rpm, - limiter_duration: 0.1) - ignition_module - .connect_wire(wires.wire1, 0 * 90 * units.deg) - .connect_wire(wires.wire5, 1 * 90 * units.deg) - .connect_wire(wires.wire3, 2 * 90 * units.deg) - .connect_wire(wires.wire7, 3 * 90 * units.deg) - .connect_wire(wires.wire4, 4 * 90 * units.deg) - .connect_wire(wires.wire8, 5 * 90 * units.deg) - .connect_wire(wires.wire2, 6 * 90 * units.deg) - .connect_wire(wires.wire6, 7 * 90 * units.deg) - - engine.add_ignition_module(ignition_module) -} - -private node mustang_vehicle { - alias output __out: - vehicle( - mass: 1614 * units.kg, - drag_coefficient: 0.3, - cross_sectional_area: (72 * units.inch) * (50 * units.inch), - diff_ratio: 3.42, - tire_radius: 10 * units.inch, - rolling_resistance: 200 * units.N - ); -} - -private node mustang_transmission { - alias output __out: - transmission( - max_clutch_torque: 500 * units.lb_ft - ) - .add_gear(3.23) - .add_gear(2.19) - .add_gear(1.61) - .add_gear(1.23) - .add_gear(0.97) - .add_gear(0.8); -} - -public node main { - set_engine(f136_v8()) - set_vehicle(mustang_vehicle()) - set_transmission(mustang_transmission()) -} diff --git a/es/11_merlin_v12.mr b/es/11_merlin_v12.mr deleted file mode 100644 index 46b5cfc..0000000 --- a/es/11_merlin_v12.mr +++ /dev/null @@ -1,479 +0,0 @@ -import "engine_sim.mr" - -units units() -constants constants() -impulse_response_library ir_lib() -label cycle(2 * 360 * units.deg) - -private node wires { - output wire1a: ignition_wire(); - output wire2a: ignition_wire(); - output wire3a: ignition_wire(); - output wire4a: ignition_wire(); - output wire5a: ignition_wire(); - output wire6a: ignition_wire(); - output wire1b: ignition_wire(); - output wire2b: ignition_wire(); - output wire3b: ignition_wire(); - output wire4b: ignition_wire(); - output wire5b: ignition_wire(); - output wire6b: ignition_wire(); -} - -private node v12_60_head { - input intake_camshaft; - input exhaust_camshaft; - input chamber_volume: 450 * units.cc; - input intake_runner_volume: 149.6 * units.cc; - input intake_runner_cross_section_area: 2.0 * units.inch * 2.0 * units.inch; - input exhaust_runner_volume: 50.0 * units.cc; - input exhaust_runner_cross_section_area: 5.0 * units.inch * 3.0 * units.inch; - - input flow_attenuation: 1.0; - input lift_scale: 1.0; - input flip_display: false; - alias output __out: head; - - function intake_flow(50 * units.thou) - intake_flow - .add_flow_sample(0 * lift_scale, 0 * flow_attenuation) - .add_flow_sample(50 * lift_scale, 58 * flow_attenuation) - .add_flow_sample(100 * lift_scale, 103 * flow_attenuation) - .add_flow_sample(150 * lift_scale, 156 * flow_attenuation) - .add_flow_sample(200 * lift_scale, 214 * flow_attenuation) - .add_flow_sample(250 * lift_scale, 249 * flow_attenuation) - .add_flow_sample(300 * lift_scale, 268 * flow_attenuation) - .add_flow_sample(350 * lift_scale, 280 * flow_attenuation) - .add_flow_sample(400 * lift_scale, 280 * flow_attenuation) - .add_flow_sample(450 * lift_scale, 281 * flow_attenuation) - - function exhaust_flow(50 * units.thou) - exhaust_flow - .add_flow_sample(0 * lift_scale, 0 * flow_attenuation) - .add_flow_sample(50 * lift_scale, 37 * flow_attenuation) - .add_flow_sample(100 * lift_scale, 72 * flow_attenuation) - .add_flow_sample(150 * lift_scale, 113 * flow_attenuation) - .add_flow_sample(200 * lift_scale, 160 * flow_attenuation) - .add_flow_sample(250 * lift_scale, 196 * flow_attenuation) - .add_flow_sample(300 * lift_scale, 222 * flow_attenuation) - .add_flow_sample(350 * lift_scale, 235 * flow_attenuation) - .add_flow_sample(400 * lift_scale, 245 * flow_attenuation) - .add_flow_sample(450 * lift_scale, 246 * flow_attenuation) - - generic_cylinder_head head( - chamber_volume: chamber_volume, - intake_runner_volume: intake_runner_volume, - intake_runner_cross_section_area: intake_runner_cross_section_area, - exhaust_runner_volume: exhaust_runner_volume, - exhaust_runner_cross_section_area: exhaust_runner_cross_section_area, - - intake_port_flow: intake_flow, - exhaust_port_flow: exhaust_flow, - valvetrain: standard_valvetrain( - intake_camshaft: intake_camshaft, - exhaust_camshaft: exhaust_camshaft - ), - flip_display: flip_display - ) -} - -private node v12_60_camshaft { - input lobe_profile; - input intake_lobe_profile: lobe_profile; - input exhaust_lobe_profile: lobe_profile; - input lobe_separation: 114 * units.deg; - input intake_lobe_center: lobe_separation; - input exhaust_lobe_center: lobe_separation; - input advance: 0 * units.deg; - input base_radius: 0.5 * units.inch; - - output intake_cam_0: _intake_cam_0; - output exhaust_cam_0: _exhaust_cam_0; - - output intake_cam_1: _intake_cam_1; - output exhaust_cam_1: _exhaust_cam_1; - - camshaft_parameters params ( - advance: advance, - base_radius: base_radius - ) - - camshaft _intake_cam_0(params, lobe_profile: intake_lobe_profile) - camshaft _exhaust_cam_0(params, lobe_profile: exhaust_lobe_profile) - camshaft _intake_cam_1(params, lobe_profile: intake_lobe_profile) - camshaft _exhaust_cam_1(params, lobe_profile: exhaust_lobe_profile) - - label rot180(180 * units.deg) - label rot360(360 * units.deg) - - // 1a 6b 4a 3b 2a 5b 6a 1b 3a 4b 5a 2b - _exhaust_cam_0 - .add_lobe(rot360 - exhaust_lobe_center + 0 * units.deg) - .add_lobe(rot360 - exhaust_lobe_center + 240 * units.deg) - .add_lobe(rot360 - exhaust_lobe_center + 480 * units.deg) - .add_lobe(rot360 - exhaust_lobe_center + 120 * units.deg) - .add_lobe(rot360 - exhaust_lobe_center + 600 * units.deg) - .add_lobe(rot360 - exhaust_lobe_center + 360 * units.deg) - _intake_cam_0 - .add_lobe(rot360 + intake_lobe_center + 0 * units.deg) - .add_lobe(rot360 + intake_lobe_center + 240 * units.deg) - .add_lobe(rot360 + intake_lobe_center + 480 * units.deg) - .add_lobe(rot360 + intake_lobe_center + 120 * units.deg) - .add_lobe(rot360 + intake_lobe_center + 600 * units.deg) - .add_lobe(rot360 + intake_lobe_center + 360 * units.deg) - - _exhaust_cam_1 - .add_lobe(rot360 - exhaust_lobe_center + (360 + 60) * units.deg) - .add_lobe(rot360 - exhaust_lobe_center + (600 + 60) * units.deg) - .add_lobe(rot360 - exhaust_lobe_center + (120 + 60) * units.deg) - .add_lobe(rot360 - exhaust_lobe_center + (480 + 60) * units.deg) - .add_lobe(rot360 - exhaust_lobe_center + (240 + 60) * units.deg) - .add_lobe(rot360 - exhaust_lobe_center + (0 + 60) * units.deg) - _intake_cam_1 - .add_lobe(rot360 + intake_lobe_center + (360 + 60) * units.deg) - .add_lobe(rot360 + intake_lobe_center + (600 + 60) * units.deg) - .add_lobe(rot360 + intake_lobe_center + (120 + 60) * units.deg) - .add_lobe(rot360 + intake_lobe_center + (480 + 60) * units.deg) - .add_lobe(rot360 + intake_lobe_center + (240 + 60) * units.deg) - .add_lobe(rot360 + intake_lobe_center + (0 + 60) * units.deg) -} - -public node merlin_v12 { - alias output __out: engine; - - engine engine( - name: "Merlin V-1650-9 [V12] (NA)", - starter_torque: 190 * units.lb_ft, - starter_speed: 200 * units.rpm, - redline: 3000 * units.rpm, - fuel: fuel( - max_turbulence_effect: 10.0, - max_dilution_effect: 5.0, - burning_efficiency_randomness: 0.1, - max_burning_efficiency: 1.0 - ), - throttle_gamma: 2.0, - simulation_frequency: 7000, - hf_gain: 0.004, - noise: 0.35, - jitter: 0.229 - ) - - wires wires() - - label stroke(6 * units.inch) - label bore(5.4 * units.inch) - label rod_length(14 * units.inch) - label rod_mass(2000 * units.g) - label compression_height(1.0 * units.inch) - label crank_mass(400 * units.lb) - label flywheel_mass(200 * units.lb) - label flywheel_radius(12 * units.inch) - - label crank_moment( - disk_moment_of_inertia(mass: crank_mass, radius: stroke) - ) - label flywheel_moment( - disk_moment_of_inertia(mass: flywheel_mass, radius: flywheel_radius) - ) - label other_moment( // Moment from cams, pulleys, etc [estimated] - disk_moment_of_inertia(mass: 1 * units.kg, radius: 1.0 * units.cm) - ) - - crankshaft c0( - throw: stroke / 2, - flywheel_mass: flywheel_mass, - mass: crank_mass, - friction_torque: 50.0 * units.lb_ft, - moment_of_inertia: - crank_moment + flywheel_moment + other_moment, - position_x: 0.0, - position_y: 0.0, - tdc: (90 + 30) * units.deg - ) - - rod_journal rj0(angle: 0 * units.deg) - rod_journal rj1(angle: 240 * units.deg) - rod_journal rj2(angle: 120 * units.deg) - rod_journal rj3(angle: 120 * units.deg) - rod_journal rj4(angle: 240 * units.deg) - rod_journal rj5(angle: 0 * units.deg) - c0 - .add_rod_journal(rj0) - .add_rod_journal(rj1) - .add_rod_journal(rj2) - .add_rod_journal(rj3) - .add_rod_journal(rj4) - .add_rod_journal(rj5) - - piston_parameters piston_params( - mass: (1000) * units.g, - compression_height: compression_height, - wrist_pin_position: 0.0, - displacement: 0.0 - ) - - connecting_rod_parameters cr_params( - mass: rod_mass, - moment_of_inertia: rod_moment_of_inertia( - mass: rod_mass, - length: rod_length - ), - center_of_mass: 0.0, - length: rod_length - ) - - intake intake( - plenum_volume: 1.325 * units.L, - plenum_cross_section_area: 20.0 * units.cm2, - intake_flow_rate: k_carb(1400.0), - runner_flow_rate: k_carb(200.0), - runner_length: 16.0 * units.inch, - idle_flow_rate: k_carb(0.0), - idle_throttle_plate_position: 0.99, - velocity_decay: 0.5 - ) - - exhaust_system_parameters es_params( - outlet_flow_rate: k_carb(2000.0), - primary_tube_length: 50.0 * units.inch, - primary_flow_rate: k_carb(400.0), - velocity_decay: 1.0 - ) - - exhaust_system exhaust0( - es_params, - length: 30 * units.inch, - audio_volume: 1.0 * 0.5, - impulse_response: ir_lib.minimal_muffling_01 - ) - exhaust_system exhaust1( - es_params, - length: 70 * units.inch, - audio_volume: 1.0 * 0.5, - impulse_response: ir_lib.minimal_muffling_01 - ) - - cylinder_bank_parameters bank_params( - bore: bore, - deck_height: stroke / 2 + rod_length + compression_height - ) - - label spacing(6 * units.inch) - - cylinder_bank b0(bank_params, angle: (60 / 2.0) * units.deg) - cylinder_bank b1(bank_params, angle: -(60 / 2.0) * units.deg) - b0 - .add_cylinder( - piston: piston(piston_params, blowby: k_28inH2O(0.7)), - connecting_rod: connecting_rod(cr_params), - rod_journal: rj0, - intake: intake, - exhaust_system: exhaust1, - ignition_wire: wires.wire1a, - sound_attenuation: 0.9, - primary_length: spacing * 6 - ) - .add_cylinder( - piston: piston(piston_params, blowby: k_28inH2O(0.1)), - connecting_rod: connecting_rod(cr_params), - rod_journal: rj1, - intake: intake, - exhaust_system: exhaust1, - ignition_wire: wires.wire2a, - sound_attenuation: 1.0, - primary_length: spacing * 5 - ) - .add_cylinder( - piston: piston(piston_params, blowby: k_28inH2O(0.4)), - connecting_rod: connecting_rod(cr_params), - rod_journal: rj2, - intake: intake, - exhaust_system: exhaust1, - ignition_wire: wires.wire3a, - sound_attenuation: 1.5, - primary_length: spacing * 4 - ) - .add_cylinder( - piston: piston(piston_params, blowby: k_28inH2O(0.3)), - connecting_rod: connecting_rod(cr_params), - rod_journal: rj3, - intake: intake, - exhaust_system: exhaust1, - ignition_wire: wires.wire4a, - sound_attenuation: 0.9, - primary_length: spacing * 3 - ) - .add_cylinder( - piston: piston(piston_params, blowby: k_28inH2O(0.2)), - connecting_rod: connecting_rod(cr_params), - rod_journal: rj4, - intake: intake, - exhaust_system: exhaust1, - ignition_wire: wires.wire5a, - sound_attenuation: 0.8, - primary_length: spacing * 2 - ) - .add_cylinder( - piston: piston(piston_params, blowby: k_28inH2O(0.1)), - connecting_rod: connecting_rod(cr_params), - rod_journal: rj5, - intake: intake, - exhaust_system: exhaust1, - ignition_wire: wires.wire6a, - sound_attenuation: 1.0, - primary_length: spacing * 1 - ) - .set_cylinder_head( - v12_60_head( - intake_camshaft: camshaft.intake_cam_0, - exhaust_camshaft: camshaft.exhaust_cam_0, - flip_display: true, - flow_attenuation: 1.0) - ) - b1 - .add_cylinder( - piston: piston(piston_params, blowby: k_28inH2O(0.5)), - connecting_rod: connecting_rod(cr_params), - rod_journal: rj0, - intake: intake, - exhaust_system: exhaust0, - ignition_wire: wires.wire1b, - sound_attenuation: 0.9, - primary_length: spacing * 6 - ) - .add_cylinder( - piston: piston(piston_params, blowby: k_28inH2O(0.2)), - connecting_rod: connecting_rod(cr_params), - rod_journal: rj1, - intake: intake, - exhaust_system: exhaust0, - ignition_wire: wires.wire2b, - sound_attenuation: 1.1, - primary_length: spacing * 5 - ) - .add_cylinder( - piston: piston(piston_params, blowby: k_28inH2O(0.1)), - connecting_rod: connecting_rod(cr_params), - rod_journal: rj2, - intake: intake, - exhaust_system: exhaust0, - ignition_wire: wires.wire3b, - primary_length: spacing * 4 - ) - .add_cylinder( - piston: piston(piston_params, blowby: k_28inH2O(0.3)), - connecting_rod: connecting_rod(cr_params), - rod_journal: rj3, - intake: intake, - exhaust_system: exhaust0, - ignition_wire: wires.wire4b, - sound_attenuation: 1.1, - primary_length: spacing * 3 - ) - .add_cylinder( - piston: piston(piston_params, blowby: k_28inH2O(0.2)), - connecting_rod: connecting_rod(cr_params), - rod_journal: rj4, - intake: intake, - exhaust_system: exhaust0, - ignition_wire: wires.wire5b, - sound_attenuation: 0.7, - primary_length: spacing * 2 - ) - .add_cylinder( - piston: piston(piston_params, blowby: k_28inH2O(0.1)), - connecting_rod: connecting_rod(cr_params), - rod_journal: rj5, - intake: intake, - exhaust_system: exhaust0, - ignition_wire: wires.wire6b, - primary_length: spacing * 1 - ) - .set_cylinder_head( - v12_60_head( - intake_camshaft: camshaft.intake_cam_1, - exhaust_camshaft: camshaft.exhaust_cam_1, - flow_attenuation: 1.0) - ) - - engine - .add_cylinder_bank(b0) - .add_cylinder_bank(b1) - - engine.add_crankshaft(c0) - - harmonic_cam_lobe intake_lobe( - duration_at_50_thou: 242 * units.deg, - gamma: 0.8, - lift: 15.95 * units.mm, - steps: 100 - ) - - harmonic_cam_lobe exhaust_lobe( - duration_at_50_thou: 246 * units.deg, - gamma: 0.8, - lift: 590 * units.thou, - steps: 100 - ) - - v12_60_camshaft camshaft( - lobe_profile: "N/A", - - intake_lobe_profile: intake_lobe, - exhaust_lobe_profile: exhaust_lobe, - intake_lobe_center: 100.5 * units.deg, - exhaust_lobe_center: 120 * units.deg, - base_radius: 1.0 * units.inch - ) - - function timing_curve(4000 * units.rpm) - timing_curve - .add_sample(0000 * units.rpm, 12 * units.deg) - .add_sample(4000 * units.rpm, 50 * units.deg) - - ignition_module ignition_module( - timing_curve: timing_curve, - rev_limit: 3500 * units.rpm, - limiter_duration: 0.05) - ignition_module - .connect_wire(wires.wire1a, (0) * units.deg) - .connect_wire(wires.wire6b, (0 + 60) * units.deg) - .connect_wire(wires.wire4a, (120) * units.deg) - .connect_wire(wires.wire3b, (120 + 60) * units.deg) - .connect_wire(wires.wire2a, (240) * units.deg) - .connect_wire(wires.wire5b, (240 + 60) * units.deg) - .connect_wire(wires.wire6a, (360) * units.deg) - .connect_wire(wires.wire1b, (360 + 60) * units.deg) - .connect_wire(wires.wire3a, (480) * units.deg) - .connect_wire(wires.wire4b, (480 + 60) * units.deg) - .connect_wire(wires.wire5a, (600) * units.deg) - .connect_wire(wires.wire2b, (600 + 60) * units.deg) - - engine.add_ignition_module(ignition_module) -} - -label car_mass(2700 * units.lb) -private node random_car { - alias output __out: - vehicle( - mass: car_mass, - drag_coefficient: 0.3, - cross_sectional_area: (72 * units.inch) * (56 * units.inch), - diff_ratio: 3.9, - tire_radius: 10 * units.inch, - rolling_resistance: 10000 - ); -} - -private node random_transmission { - alias output __out: - transmission( - max_clutch_torque: 2000 * units.lb_ft - ) - .add_gear(0.01); -} - -set_engine(merlin_v12()) -set_vehicle(random_car()) -set_transmission(random_transmission()) diff --git a/es/2jz.mr b/es/2jz.mr deleted file mode 100644 index 2f3f616..0000000 --- a/es/2jz.mr +++ /dev/null @@ -1,6 +0,0 @@ -import "engine_sim.mr" -import "themes/default.mr" -import "engines/atg-video-2/03_2jz.mr" - -use_default_theme() -main() diff --git a/es/C63.mr b/es/C63.mr deleted file mode 100644 index ea0cea2..0000000 --- a/es/C63.mr +++ /dev/null @@ -1,9 +0,0 @@ -import "engine_sim.mr" -import "themes/default.mr" -import "engines/dacxl/M156.mr" - -use_default_theme() - -set_engine(M156()) -set_transmission(amg_transmission()) -set_vehicle(amg_vehicle()) diff --git a/es/C63_M156.mr b/es/C63_M156.mr deleted file mode 100644 index 7476c8a..0000000 --- a/es/C63_M156.mr +++ /dev/null @@ -1,456 +0,0 @@ -import "engine_sim.mr" - -units units() -constants constants() -impulse_response_library ir_lib() - -label cycle(2 * 360 * units.deg) -label cylcycle(720/8.0*units.deg) -label cycle90(90 * units.deg) - - -private node amg_distributor { - input wires; - input timing_curve; - input rev_limit: 7250 * units.rpm; - input limiter_duration: 0.05; - alias output __out: - ignition_module(timing_curve: timing_curve, rev_limit: rev_limit, limiter_duration: limiter_duration) - .connect_wire(wires.wire1, 0) - .connect_wire(wires.wire5, 1 * cycle90) - .connect_wire(wires.wire4, 2 * cycle90) - .connect_wire(wires.wire8, 3 * cycle90) - .connect_wire(wires.wire6, 4 * cycle90) - .connect_wire(wires.wire3, 5 * cycle90) - .connect_wire(wires.wire7, 6 * cycle90) - .connect_wire(wires.wire2, 7 * cycle90) - ; -} - -//1 - 5 - 4 - 8 - 6 - 3 - 7 - 2 M156 - -private node wires { - output wire1: ignition_wire(); - output wire2: ignition_wire(); - output wire3: ignition_wire(); - output wire4: ignition_wire(); - output wire5: ignition_wire(); - output wire6: ignition_wire(); - output wire7: ignition_wire(); - output wire8: ignition_wire(); -} - -private node add_sym_sample { - input angle; - input lift; - input this; - alias output __out: this; - - this.add_sample(angle * units.deg, lift * units.thou) - this.add_sample(-angle * units.deg, lift * units.thou) -} - -private node amg_lobe_profile_int { - alias output __out: - harmonic_cam_lobe( - duration_at_50_thou: 264 * units.deg, //288 - gamma: 3, - lift: 11 * units.mm, //14.5 - steps: 100 - ); -} - -private node amg_lobe_profile_exh { - alias output __out: - harmonic_cam_lobe( - duration_at_50_thou: 264 * units.deg, //280 - gamma: 3, - lift: 9.8 * units.mm, //14.5 - steps: 100 - ); -} - -private node camshaft_builder { - input lobe_profile: amg_lobe_profile_int(); - input ex_lobe_profile: amg_lobe_profile_exh(); - input intake_lobe_profile: lobe_profile; - input exhaust_lobe_profile: ex_lobe_profile; - input lobe_separation: 112.0 * units.deg; - input intake_lobe_center: lobe_separation; - input exhaust_lobe_center: 112.0 * units.deg; - input advance: 0.0 * units.deg; - input base_radius: 0.6 * units.inch; - - output intake_cam_0: _intake_cam_0; - output intake_cam_1: _intake_cam_1; - output exhaust_cam_0: _exhaust_cam_0; - output exhaust_cam_1: _exhaust_cam_1; - - camshaft_parameters params( - advance: advance, - base_radius: base_radius - ) - - camshaft _intake_cam_0(params, lobe_profile: intake_lobe_profile) - camshaft _intake_cam_1(params, lobe_profile: intake_lobe_profile) - camshaft _exhaust_cam_0(params, lobe_profile: exhaust_lobe_profile) - camshaft _exhaust_cam_1(params, lobe_profile: exhaust_lobe_profile) - - - label rot60(60 * units.deg) - label rot90(90 * units.deg) - label rot120(120 * units.deg) - label rot135(135 * units.deg) - label rot180(180 * units.deg) - label rot360(360 * units.deg) - label rot(90 * units.deg) - - // 1-5-3-7-4-8-2-6 - // 4 8 - // 3 7 - // 2 6 - // 1 5 - // 1 - 5 - 4 - 8 - 6 - 3 - 7 - 2 M156 - - _intake_cam_0 - .add_lobe(rot360 + intake_lobe_center + 0 * rot) // 1 - .add_lobe(rot360 + intake_lobe_center + 6 * rot) // 2 - .add_lobe(rot360 + intake_lobe_center + 5 * rot) // 3 - .add_lobe(rot360 + intake_lobe_center + 2 * rot) // 4 - - _intake_cam_1 - .add_lobe(rot360 + intake_lobe_center + 1 * rot) // 5 - .add_lobe(rot360 + intake_lobe_center + 4 * rot) // 6 - .add_lobe(rot360 + intake_lobe_center + 6 * rot) // 7 - .add_lobe(rot360 + intake_lobe_center + 3 * rot) // 8 - - _exhaust_cam_0 - .add_lobe(rot360 - exhaust_lobe_center + 0 * rot) // 1 - .add_lobe(rot360 - exhaust_lobe_center + 6 * rot) // 2 - .add_lobe(rot360 - exhaust_lobe_center + 5 * rot) // 3 - .add_lobe(rot360 - exhaust_lobe_center + 2 * rot) // 4 - - _exhaust_cam_1 - .add_lobe(rot360 - exhaust_lobe_center + 1 * rot) // 5 - .add_lobe(rot360 - exhaust_lobe_center + 4 * rot) // 6 - .add_lobe(rot360 - exhaust_lobe_center + 6 * rot) // 7 - .add_lobe(rot360 - exhaust_lobe_center + 3 * rot) // 8 -} - -private node add_flow_sample { - input lift; - input flow; - input this; - alias output __out: this; - - this.add_sample(lift * units.mm, k_28inH2O(flow)) -} - -private node amg_head { - input intake_camshaft; - input exhaust_camshaft; - input chamber_volume: 28.23 * units.cc; - input intake_runner_volume: 600.0 * units.cc; - input intake_runner_cross_section_area: 100.0 * units.cm2; - input exhaust_runner_volume: 600.0 * units.cc; - input exhaust_runner_cross_section_area: 100.0 * units.cm2; - input flip_display: false; - - input flow_attenuation: 1.0; - input lift_scale: 1.0; - alias output __out: head; - - function intake_flow(1 * units.mm) - intake_flow - .add_flow_sample(0 * lift_scale, 0 * flow_attenuation) - .add_flow_sample(1 * lift_scale, 40 * flow_attenuation) - .add_flow_sample(2 * lift_scale, 100 * flow_attenuation) - .add_flow_sample(3 * lift_scale, 168 * flow_attenuation) - .add_flow_sample(4 * lift_scale, 196 * flow_attenuation) - .add_flow_sample(5 * lift_scale, 228 * flow_attenuation) - .add_flow_sample(6 * lift_scale, 254 * flow_attenuation) - .add_flow_sample(7 * lift_scale, 274 * flow_attenuation) - .add_flow_sample(8 * lift_scale, 285 * flow_attenuation) - .add_flow_sample(9 * lift_scale, 314 * flow_attenuation) - .add_flow_sample(10 * lift_scale, 330 * flow_attenuation) - .add_flow_sample(11 * lift_scale, 343 * flow_attenuation) - .add_flow_sample(12 * lift_scale, 355 * flow_attenuation) - .add_flow_sample(13 * lift_scale, 359 * flow_attenuation) - .add_flow_sample(14 * lift_scale, 360 * flow_attenuation) - - function exhaust_flow(1 * units.mm) - exhaust_flow - .add_flow_sample(0 * lift_scale, 0 * flow_attenuation) - .add_flow_sample(1 * lift_scale, 42 * flow_attenuation) - .add_flow_sample(2 * lift_scale, 110 * flow_attenuation) - .add_flow_sample(3 * lift_scale, 140 * flow_attenuation) - .add_flow_sample(4 * lift_scale, 170 * flow_attenuation) - .add_flow_sample(5 * lift_scale, 194 * flow_attenuation) - .add_flow_sample(6 * lift_scale, 228 * flow_attenuation) - .add_flow_sample(7 * lift_scale, 237 * flow_attenuation) - .add_flow_sample(8 * lift_scale, 253 * flow_attenuation) - .add_flow_sample(9 * lift_scale, 288 * flow_attenuation) - .add_flow_sample(10 * lift_scale, 292 * flow_attenuation) - .add_flow_sample(11 * lift_scale, 317 * flow_attenuation) - .add_flow_sample(12 * lift_scale, 323 * flow_attenuation) - .add_flow_sample(13 * lift_scale, 331 * flow_attenuation) - .add_flow_sample(14 * lift_scale, 342 * flow_attenuation) - - - cylinder_head head( - chamber_volume: chamber_volume, - intake_runner_volume: intake_runner_volume, - intake_runner_cross_section_area: intake_runner_cross_section_area, - exhaust_runner_volume: exhaust_runner_volume, - exhaust_runner_cross_section_area: exhaust_runner_cross_section_area, - - intake_port_flow: intake_flow, - exhaust_port_flow: exhaust_flow, - intake_camshaft: intake_camshaft, - exhaust_camshaft: exhaust_camshaft, - flip_display: flip_display - ) -} - -public node amg_vehicle { - input mass: (1730 + 80) * units.kg; - input diff_ratio: 2.82; - input tire_radius: 12.7 * units.inch; - - alias output __out: vehicle; - - vehicle vehicle( - mass: mass, - diff_ratio: diff_ratio, - tire_radius: tire_radius - ) -} - -public node amg_transmission { - input max_clutch_torque: 680 * units.lb_ft; - alias output __out: - transmission(max_clutch_torque) - .add_gear(4.38) - .add_gear(2.86) - .add_gear(1.92) - .add_gear(1.37) - .add_gear(1.0) - .add_gear(0.82) - .add_gear(0.73); -} - - -public node M156 { - alias output __out: engine; - - engine engine( - name: "Mercedes-AMG M156 (C 63 W204)", - starter_torque: 200 * units.lb_ft, - starter_speed: 1400 * units.rpm, - redline: 7250 * units.rpm, - fuel: fuel( - max_turbulence_effect: 8.0, - burning_efficiency_randomness: 0.1, - max_burning_efficiency: 1.25 - ) - ) - - wires wires() - - crankshaft c0( - throw: 94.6 * units.mm / 2, - flywheel_mass: 11.7934 * units.kg, - mass: 23.2 * units.kg, - friction_torque: 10.0 * units.lb_ft, - moment_of_inertia: 0.22986844776863666 * 0.9, - position_x: 0.0, - position_y: 0.0, - tdc: 45.0 * units.deg - ) - - rod_journal rj0(angle: 90.0*units.deg) - rod_journal rj1(angle: 0.0*units.deg) - rod_journal rj2(angle: 180.0*units.deg) - rod_journal rj3(angle: 270.0*units.deg) - -// 4 8 -// 3 7 -// 2 6 -// 1 5 -//1 - 5 - 4 - 8 - 6 - 3 - 7 - 2 M156 - - - c0 - .add_rod_journal(rj0) - .add_rod_journal(rj1) - .add_rod_journal(rj2) - .add_rod_journal(rj3) - - piston_parameters piston_params( - mass: 420 * units.g, - //blowby: k_28inH2O(0.1), - compression_height: 24.0 * units.mm, - wrist_pin_position: 0.0, - displacement: 0.0 - ) - - connecting_rod_parameters cr_params( - mass: 408.0 * units.g, - moment_of_inertia: 0.0015884918028487504, - center_of_mass: 0.0, - length: 144.0 * units.mm - ) - - cylinder_bank_parameters bank_params( - bore: 102.2 * units.mm, - deck_height: 225.0 * units.mm //225 - ) - - intake intake( - plenum_volume: 80.0 * units.L, - plenum_cross_section_area: 120.0 * units.cm2, - intake_flow_rate: k_carb(5000.0), - idle_flow_rate: k_carb(0.002), - idle_throttle_plate_position: 0.99878, - throttle_gamma: 1.0 - ) - - exhaust_system_parameters es_params( - outlet_flow_rate: k_carb(8000.0), - primary_tube_length: 18.0 * units.inch, - primary_flow_rate: k_carb(1800.0), - velocity_decay: 0.6, //0.5 - volume: 600.0 * units.L - ) - - exhaust_system_parameters es_params2( - outlet_flow_rate: k_carb(8000.0), - primary_tube_length: 18.0 * units.inch, - primary_flow_rate: k_carb(1800.0), - velocity_decay: 0.6, //0.5 - volume: 600.0 * units.L - ) - - - exhaust_system exhaust0(es_params, audio_volume: 0.5, impulse_response: ir_lib.default_0) - exhaust_system exhaust1(es_params, audio_volume: 1.0, impulse_response: ir_lib.default_0) - - cylinder_bank b0(bank_params, angle: 45 * units.deg) - b0 - .add_cylinder( - piston: piston(piston_params, blowby: k_28inH2O(0.1)), - connecting_rod: connecting_rod(cr_params), - rod_journal: rj0, - intake: intake, - exhaust_system: exhaust0, - ignition_wire: wires.wire1 - ) - .add_cylinder( - piston: piston(piston_params, blowby: k_28inH2O(0.1)), - connecting_rod: connecting_rod(cr_params), - rod_journal: rj1, - intake: intake, - exhaust_system: exhaust0, - ignition_wire: wires.wire2 - ) - .add_cylinder( - piston: piston(piston_params, blowby: k_28inH2O(0.1)), - connecting_rod: connecting_rod(cr_params), - rod_journal: rj2, - intake: intake, - exhaust_system: exhaust0, - ignition_wire: wires.wire3 - ) - .add_cylinder( - piston: piston(piston_params, blowby: k_28inH2O(0.1)), - connecting_rod: connecting_rod(cr_params), - rod_journal: rj3, - intake: intake, - exhaust_system: exhaust0, - ignition_wire: wires.wire4 - ) - - cylinder_bank b1(bank_params, angle: -45 * units.deg) - b1 - .add_cylinder( - piston: piston(piston_params, blowby: k_28inH2O(0.1)), - connecting_rod: connecting_rod(cr_params), - rod_journal: rj0, - intake: intake, - exhaust_system: exhaust1, - ignition_wire: wires.wire5 - ) - .add_cylinder( - piston: piston(piston_params, blowby: k_28inH2O(0.1)), - connecting_rod: connecting_rod(cr_params), - rod_journal: rj1, - intake: intake, - exhaust_system: exhaust1, - ignition_wire: wires.wire6 - ) - .add_cylinder( - piston: piston(piston_params, blowby: k_28inH2O(0.1)), - connecting_rod: connecting_rod(cr_params), - rod_journal: rj2, - intake: intake, - exhaust_system: exhaust1, - ignition_wire: wires.wire7 - ) - .add_cylinder( - piston: piston(piston_params, blowby: k_28inH2O(0.1)), - connecting_rod: connecting_rod(cr_params), - rod_journal: rj3, - intake: intake, - exhaust_system: exhaust1, - ignition_wire: wires.wire8 - ) - - - engine - .add_cylinder_bank(b0) - .add_cylinder_bank(b1) - - engine.add_crankshaft(c0) - - - camshaft_builder camshaft( - lobe_profile: amg_lobe_profile_int(), - ex_lobe_profile: amg_lobe_profile_exh() - ) - - b0.set_cylinder_head ( - amg_head( - intake_camshaft: camshaft.intake_cam_0, - exhaust_camshaft: camshaft.exhaust_cam_0 - ) - ) - - b1.set_cylinder_head ( - amg_head( - intake_camshaft: camshaft.intake_cam_1, - exhaust_camshaft: camshaft.exhaust_cam_1, - flip_display:true - ) - ) - - function timing_curve(1000 * units.rpm) - timing_curve - .add_sample(0000 * units.rpm, 15 * units.deg) - .add_sample(1000 * units.rpm, 28 * units.deg) - .add_sample(2000 * units.rpm, 35 * units.deg) - .add_sample(3000 * units.rpm, 35 * units.deg) - .add_sample(4000 * units.rpm, 40 * units.deg) - .add_sample(5000 * units.rpm, 40 * units.deg) - .add_sample(6000 * units.rpm, 40 * units.deg) - .add_sample(7000 * units.rpm, 40 * units.deg) - .add_sample(8000 * units.rpm, 40 * units.deg) - .add_sample(9000 * units.rpm, 40 * units.deg) - - engine.add_ignition_module( - amg_distributor( - wires: wires, - timing_curve: timing_curve, - rev_limit: 7250 * units.rpm, - limiter_duration: 0.05 - )) -} diff --git a/es/C63_M156_V2.mr b/es/C63_M156_V2.mr deleted file mode 100644 index 504e4f7..0000000 --- a/es/C63_M156_V2.mr +++ /dev/null @@ -1,500 +0,0 @@ -import "engine_sim.mr" - -// V2 Update with corrected values and useable in 0.1.14a - -units units() -constants constants() -impulse_response_library ir_lib() - -label cycle(2 * 360 * units.deg) -label cylcycle(720/8.0*units.deg) -label cycle90(90 * units.deg) - - -private node amg_distributor { - input wires; - input timing_curve; - input rev_limit: 7250 * units.rpm; - input limiter_duration: 0.05; - alias output __out: - ignition_module(timing_curve: timing_curve, rev_limit: rev_limit, limiter_duration: limiter_duration) - .connect_wire(wires.wire1, 0) - .connect_wire(wires.wire5, 1 * cycle90) - .connect_wire(wires.wire4, 2 * cycle90) - .connect_wire(wires.wire8, 3 * cycle90) - .connect_wire(wires.wire6, 4 * cycle90) - .connect_wire(wires.wire3, 5 * cycle90) - .connect_wire(wires.wire7, 6 * cycle90) - .connect_wire(wires.wire2, 7 * cycle90) - ; -} - -//1 - 5 - 4 - 8 - 6 - 3 - 7 - 2 M156 - -private node wires { - output wire1: ignition_wire(); - output wire2: ignition_wire(); - output wire3: ignition_wire(); - output wire4: ignition_wire(); - output wire5: ignition_wire(); - output wire6: ignition_wire(); - output wire7: ignition_wire(); - output wire8: ignition_wire(); -} - -private node add_sym_sample { - input angle; - input lift; - input this; - alias output __out: this; - - this.add_sample(angle * units.deg, lift * units.thou) - this.add_sample(-angle * units.deg, lift * units.thou) -} - -private node amg_lobe_profile_int { - alias output __out: - harmonic_cam_lobe( - duration_at_50_thou: 264 * units.deg, //288 - gamma: 3, - lift: 11 * units.mm, //14.5 - steps: 100 - ); -} - -private node amg_lobe_profile_exh { - alias output __out: - harmonic_cam_lobe( - duration_at_50_thou: 264 * units.deg, //280 - gamma: 3, - lift: 9.8 * units.mm, //14.5 - steps: 100 - ); -} - -private node camshaft_builder { - input lobe_profile: amg_lobe_profile_int(); - input ex_lobe_profile: amg_lobe_profile_exh(); - input intake_lobe_profile: lobe_profile; - input exhaust_lobe_profile: ex_lobe_profile; - input lobe_separation: 112.0 * units.deg; - input intake_lobe_center: lobe_separation; - input exhaust_lobe_center: 112.0 * units.deg; - input advance: 0.0 * units.deg; - input base_radius: 0.6 * units.inch; - - output intake_cam_0: _intake_cam_0; - output intake_cam_1: _intake_cam_1; - output exhaust_cam_0: _exhaust_cam_0; - output exhaust_cam_1: _exhaust_cam_1; - - camshaft_parameters params( - advance: advance, - base_radius: base_radius - ) - - camshaft _intake_cam_0(params, lobe_profile: intake_lobe_profile) - camshaft _intake_cam_1(params, lobe_profile: intake_lobe_profile) - camshaft _exhaust_cam_0(params, lobe_profile: exhaust_lobe_profile) - camshaft _exhaust_cam_1(params, lobe_profile: exhaust_lobe_profile) - - - label rot60(60 * units.deg) - label rot90(90 * units.deg) - label rot120(120 * units.deg) - label rot135(135 * units.deg) - label rot180(180 * units.deg) - label rot360(360 * units.deg) - label rot(90 * units.deg) - - // 1-5-3-7-4-8-2-6 - // 4 8 - // 3 7 - // 2 6 - // 1 5 - // 1 - 5 - 4 - 8 - 6 - 3 - 7 - 2 M156 - - _intake_cam_0 - .add_lobe(rot360 + intake_lobe_center + 0 * rot) // 1 - .add_lobe(rot360 + intake_lobe_center + 6 * rot) // 2 - .add_lobe(rot360 + intake_lobe_center + 5 * rot) // 3 - .add_lobe(rot360 + intake_lobe_center + 2 * rot) // 4 - - _intake_cam_1 - .add_lobe(rot360 + intake_lobe_center + 1 * rot) // 5 - .add_lobe(rot360 + intake_lobe_center + 4 * rot) // 6 - .add_lobe(rot360 + intake_lobe_center + 6 * rot) // 7 - .add_lobe(rot360 + intake_lobe_center + 3 * rot) // 8 - - _exhaust_cam_0 - .add_lobe(rot360 - exhaust_lobe_center + 0 * rot) // 1 - .add_lobe(rot360 - exhaust_lobe_center + 6 * rot) // 2 - .add_lobe(rot360 - exhaust_lobe_center + 5 * rot) // 3 - .add_lobe(rot360 - exhaust_lobe_center + 2 * rot) // 4 - - _exhaust_cam_1 - .add_lobe(rot360 - exhaust_lobe_center + 1 * rot) // 5 - .add_lobe(rot360 - exhaust_lobe_center + 4 * rot) // 6 - .add_lobe(rot360 - exhaust_lobe_center + 6 * rot) // 7 - .add_lobe(rot360 - exhaust_lobe_center + 3 * rot) // 8 -} - -private node add_flow_sample { - input lift; - input flow; - input this; - alias output __out: this; - - this.add_sample(lift * units.mm, k_28inH2O(flow)) -} - -private node amg_head { - input intake_camshaft; - input exhaust_camshaft; - input chamber_volume: 28.23 * units.cc; - input intake_runner_volume: 250.0 * units.cc; - input intake_runner_cross_section_area: 100.0 * units.cm2; - input exhaust_runner_volume: 250.0 * units.cc; - input exhaust_runner_cross_section_area: 100.0 * units.cm2; - input flip_display: false; - - input flow_attenuation: 1.0; - input lift_scale: 1.0; - alias output __out: head; - - function intake_flow(1 * units.mm) - intake_flow - .add_flow_sample(0 * lift_scale, 0 * flow_attenuation) - .add_flow_sample(1 * lift_scale, 40 * flow_attenuation) - .add_flow_sample(2 * lift_scale, 100 * flow_attenuation) - .add_flow_sample(3 * lift_scale, 168 * flow_attenuation) - .add_flow_sample(4 * lift_scale, 196 * flow_attenuation) - .add_flow_sample(5 * lift_scale, 228 * flow_attenuation) - .add_flow_sample(6 * lift_scale, 254 * flow_attenuation) - .add_flow_sample(7 * lift_scale, 274 * flow_attenuation) - .add_flow_sample(8 * lift_scale, 285 * flow_attenuation) - .add_flow_sample(9 * lift_scale, 314 * flow_attenuation) - .add_flow_sample(10 * lift_scale, 330 * flow_attenuation) - .add_flow_sample(11 * lift_scale, 343 * flow_attenuation) - .add_flow_sample(12 * lift_scale, 355 * flow_attenuation) - .add_flow_sample(13 * lift_scale, 359 * flow_attenuation) - .add_flow_sample(14 * lift_scale, 360 * flow_attenuation) - - function exhaust_flow(1 * units.mm) - exhaust_flow - .add_flow_sample(0 * lift_scale, 0 * flow_attenuation) - .add_flow_sample(1 * lift_scale, 42 * flow_attenuation) - .add_flow_sample(2 * lift_scale, 110 * flow_attenuation) - .add_flow_sample(3 * lift_scale, 140 * flow_attenuation) - .add_flow_sample(4 * lift_scale, 170 * flow_attenuation) - .add_flow_sample(5 * lift_scale, 194 * flow_attenuation) - .add_flow_sample(6 * lift_scale, 228 * flow_attenuation) - .add_flow_sample(7 * lift_scale, 237 * flow_attenuation) - .add_flow_sample(8 * lift_scale, 253 * flow_attenuation) - .add_flow_sample(9 * lift_scale, 288 * flow_attenuation) - .add_flow_sample(10 * lift_scale, 292 * flow_attenuation) - .add_flow_sample(11 * lift_scale, 317 * flow_attenuation) - .add_flow_sample(12 * lift_scale, 323 * flow_attenuation) - .add_flow_sample(13 * lift_scale, 331 * flow_attenuation) - .add_flow_sample(14 * lift_scale, 342 * flow_attenuation) - - - cylinder_head head( - chamber_volume: chamber_volume, - intake_runner_volume: intake_runner_volume, - intake_runner_cross_section_area: intake_runner_cross_section_area, - exhaust_runner_volume: exhaust_runner_volume, - exhaust_runner_cross_section_area: exhaust_runner_cross_section_area, - - intake_port_flow: intake_flow, - exhaust_port_flow: exhaust_flow, - intake_camshaft: intake_camshaft, - exhaust_camshaft: exhaust_camshaft, - flip_display: flip_display - ) -} - -public node amg_vehicle { - input mass: (1730 + 80) * units.kg; - input diff_ratio: 2.82; - input tire_radius: 12.7 * units.inch; - - alias output __out: vehicle; - - vehicle vehicle( - mass: mass, - diff_ratio: diff_ratio, - tire_radius: tire_radius - ) -} - -public node amg_transmission { - input max_clutch_torque: 680 * units.lb_ft; - alias output __out: - transmission(max_clutch_torque) - .add_gear(4.38) - .add_gear(2.86) - .add_gear(1.92) - .add_gear(1.37) - .add_gear(1.0) - .add_gear(0.82) - .add_gear(0.73); -} - - -public node M156 { - alias output __out: engine; - - engine engine( - name: "Mercedes-AMG M156 (C 63 W204) V2", - starter_torque: 200 * units.lb_ft, - starter_speed: 1400 * units.rpm, - redline: 7250 * units.rpm, - fuel: fuel( - max_turbulence_effect: 1.0, - burning_efficiency_randomness: 0.0, - max_burning_efficiency: 1.0 - ), - simulation_frequency: 8500 - ) - - wires wires() - - crankshaft c0( - throw: 94.6 * units.mm / 2, - flywheel_mass: 11.7934 * units.kg, - mass: 16.2 * units.kg, - friction_torque: 10.0 * units.lb_ft, - moment_of_inertia: 0.22986844776863666 * 0.9, - position_x: 0.0, - position_y: 0.0, - tdc: 45.0 * units.deg - ) - - rod_journal rj0(angle: 90.0*units.deg) - rod_journal rj1(angle: 0.0*units.deg) - rod_journal rj2(angle: 180.0*units.deg) - rod_journal rj3(angle: 270.0*units.deg) - -// 4 8 -// 3 7 -// 2 6 -// 1 5 -//1 - 5 - 4 - 8 - 6 - 3 - 7 - 2 M156 - - - c0 - .add_rod_journal(rj0) - .add_rod_journal(rj1) - .add_rod_journal(rj2) - .add_rod_journal(rj3) - - piston_parameters piston_params( - mass: 420 * units.g, - //blowby: k_28inH2O(0.1), - compression_height: 29.0 * units.mm, - wrist_pin_position: 0.0, - displacement: 0.0 - ) - - connecting_rod_parameters cr_params( - mass: 408.0 * units.g, - moment_of_inertia: 0.0015884918028487504, - center_of_mass: 0.0, - length: 144.0 * units.mm - ) - - cylinder_bank_parameters bank_params( - bore: 102.2 * units.mm, - deck_height: 224.0 * units.mm //225 - ) - - intake intake( - plenum_volume: 5.0 * units.L, - plenum_cross_section_area: 25.0 * units.cm2, - intake_flow_rate: k_carb(800.0), - idle_flow_rate: k_carb(0.00), - idle_throttle_plate_position: 0.99598, - throttle_gamma: 1.0 - ) - - exhaust_system_parameters es_params( - outlet_flow_rate: k_carb(1000.0), - primary_tube_length: 18.0 * units.inch, - primary_flow_rate: k_carb(800.0), - velocity_decay: 0.5, - volume: 20.0 * units.L - ) - - exhaust_system_parameters es_params2( - outlet_flow_rate: k_carb(1000.0), - primary_tube_length: 18.0 * units.inch, - primary_flow_rate: k_carb(800.0), - velocity_decay: 0.5, - volume: 20.0 * units.L - ) - - - exhaust_system exhaust0(es_params, audio_volume: 0.5, impulse_response: ir_lib.default_0) - exhaust_system exhaust1(es_params, audio_volume: 1.0, impulse_response: ir_lib.default_0) - - cylinder_bank b0(bank_params, angle: 45 * units.deg) - b0 - .add_cylinder( - piston: piston(piston_params, blowby: k_28inH2O(0.1)), - connecting_rod: connecting_rod(cr_params), - rod_journal: rj0, - intake: intake, - exhaust_system: exhaust0, - ignition_wire: wires.wire1 - ) - .add_cylinder( - piston: piston(piston_params, blowby: k_28inH2O(0.1)), - connecting_rod: connecting_rod(cr_params), - rod_journal: rj1, - intake: intake, - exhaust_system: exhaust0, - ignition_wire: wires.wire2 - ) - .add_cylinder( - piston: piston(piston_params, blowby: k_28inH2O(0.1)), - connecting_rod: connecting_rod(cr_params), - rod_journal: rj2, - intake: intake, - exhaust_system: exhaust0, - ignition_wire: wires.wire3 - ) - .add_cylinder( - piston: piston(piston_params, blowby: k_28inH2O(0.1)), - connecting_rod: connecting_rod(cr_params), - rod_journal: rj3, - intake: intake, - exhaust_system: exhaust0, - ignition_wire: wires.wire4 - ) - - cylinder_bank b1(bank_params, angle: -45 * units.deg) - b1 - .add_cylinder( - piston: piston(piston_params, blowby: k_28inH2O(0.1)), - connecting_rod: connecting_rod(cr_params), - rod_journal: rj0, - intake: intake, - exhaust_system: exhaust1, - ignition_wire: wires.wire5 - ) - .add_cylinder( - piston: piston(piston_params, blowby: k_28inH2O(0.1)), - connecting_rod: connecting_rod(cr_params), - rod_journal: rj1, - intake: intake, - exhaust_system: exhaust1, - ignition_wire: wires.wire6 - ) - .add_cylinder( - piston: piston(piston_params, blowby: k_28inH2O(0.1)), - connecting_rod: connecting_rod(cr_params), - rod_journal: rj2, - intake: intake, - exhaust_system: exhaust1, - ignition_wire: wires.wire7 - ) - .add_cylinder( - piston: piston(piston_params, blowby: k_28inH2O(0.1)), - connecting_rod: connecting_rod(cr_params), - rod_journal: rj3, - intake: intake, - exhaust_system: exhaust1, - ignition_wire: wires.wire8 - ) - - - engine - .add_cylinder_bank(b0) - .add_cylinder_bank(b1) - - engine.add_crankshaft(c0) - - - camshaft_builder camshaft( - lobe_profile: amg_lobe_profile_int(), - ex_lobe_profile: amg_lobe_profile_exh() - ) - - b0.set_cylinder_head ( - amg_head( - intake_camshaft: camshaft.intake_cam_0, - exhaust_camshaft: camshaft.exhaust_cam_0 - ) - ) - - b1.set_cylinder_head ( - amg_head( - intake_camshaft: camshaft.intake_cam_1, - exhaust_camshaft: camshaft.exhaust_cam_1, - flip_display:true - ) - ) - - function timing_curve(1000 * units.rpm) - timing_curve - .add_sample(0000 * units.rpm, 15 * units.deg) - .add_sample(1000 * units.rpm, 28 * units.deg) - .add_sample(2000 * units.rpm, 35 * units.deg) - .add_sample(3000 * units.rpm, 35 * units.deg) - .add_sample(4000 * units.rpm, 40 * units.deg) - .add_sample(5000 * units.rpm, 42 * units.deg) - .add_sample(6000 * units.rpm, 45 * units.deg) - .add_sample(7000 * units.rpm, 51 * units.deg) - .add_sample(8000 * units.rpm, 55 * units.deg) - .add_sample(9000 * units.rpm, 60 * units.deg) - - engine.add_ignition_module( - amg_distributor( - wires: wires, - timing_curve: timing_curve, - rev_limit: 7250 * units.rpm, - limiter_duration: 0.05 - )) -} - -public node C63_vehicle { - alias output __out: vehicle; - vehicle vehicle( - mass: 1730 * units.kg, - drag_coefficient: 0.34, - cross_sectional_area: (1980 * units.mm) * (1383 * units.mm), - diff_ratio: 2.82, - tire_radius: (713.74 / 2) * units.mm, - rolling_resistance: 20 - ) -} - -private node C63_transmission { - alias output __out: - transmission( - max_clutch_torque: 1250 * units.Nm, - max_clutch_flex: 10 * units.deg, - limit_clutch_flex: true, - clutch_stiffness: 50 * units.Nm / units.deg, - clutch_damping: 1.0, - simulate_flex: true - ) - .add_gear(4.34) - .add_gear(2.89) - .add_gear(1.92) - .add_gear(1.37) - .add_gear(1.00) - .add_gear(0.82) - .add_gear(0.73); -} - -public node main{ - run( - engine: M156(), - transmission: C63_transmission(), - vehicle: C63_vehicle() - ) -} - -main() diff --git a/es/Ford_300_i6_cammed.mr b/es/Ford_300_i6_cammed.mr deleted file mode 100644 index 1edbe96..0000000 --- a/es/Ford_300_i6_cammed.mr +++ /dev/null @@ -1,438 +0,0 @@ -import "engine_sim.mr" - -units units() -constants constants() -impulse_response_library ir_lib() - -label Fuel_Name("87 Octane") // Fuel name // -label Fuel_Molecular_Mass(114.23) // Mass of a fuel molecule // -label Fuel_Density(740.0 * (units.g / units.L)) // Fuel mass per unit volume // -label Fuel_Energy_Density(44.0 * (units.kJ / units.g)) // Fuel energy released by combustion per unit weight // -label Fuel_Molecular_AFR(14.1) // Amount of oxygen molecules required to burn a single molecule of fuel // -label Fuel_Maximum_Burning_Efficiency(2.0) // Maximum combustion efficiency of fuel // -label Fuel_Burning_Efficiency_Randomness(0.5) // Randomness of fuel combustion efficiency // -label Fuel_Low_Efficiency_Attenuation(1.66) // Attenuation of low fuel burning efficiency // -label Fuel_Max_Turbulence_Effect(2.0) // Maximum turbulence of air-fuel mixture // -label Fuel_Max_Dilution_Effect(10.0) // Maximum fuel dilution // - -private node wires { - output wire1: ignition_wire(); - output wire2: ignition_wire(); - output wire3: ignition_wire(); - output wire4: ignition_wire(); - output wire5: ignition_wire(); - output wire6: ignition_wire(); -} - -// Ford 300 firing order: 1-5-3-6-2-4 - -label cycle(2 * 360 * units.deg) - -public node wb_ignition { - input wires; - input timing_curve; - input rev_limit: 5500 * units.rpm; - input limiter_duration: 0.1; - alias output __out: - ignition_module(timing_curve: timing_curve, rev_limit: rev_limit, limiter_duration: limiter_duration) - .connect_wire(wires.wire1, 0.0 * units.deg) - .connect_wire(wires.wire2, 480.0 * units.deg) - .connect_wire(wires.wire3, 240.0 * units.deg) - .connect_wire(wires.wire4, 600.0 * units.deg) - .connect_wire(wires.wire5, 120.0 * units.deg) - .connect_wire(wires.wire6, 360.0 * units.deg); -} - -// cam: https://www.summitracing.com/parts/mel-cl-mtf-3/make/ford -public node ford_lobe_profile_int { - alias output __out: - harmonic_cam_lobe( - duration_at_50_thou: 204 * units.deg, - gamma: 1.0, - lift: 485 * units.thou, - steps: 100 - ); -} - -public node ford_lobe_profile_exh { - alias output __out: - harmonic_cam_lobe( - duration_at_50_thou: 214 * units.deg, - gamma: 1.0, - lift: 512 * units.thou, - steps: 100 - ); -} - -public node ford_camshaft_builder { - input in_lobe_profile: ford_lobe_profile_int(); - input ex_lobe_profile: ford_lobe_profile_exh(); - input intake_lobe_profile: in_lobe_profile; - input exhaust_lobe_profile: ex_lobe_profile; - input lobe_separation: 112.0 * units.deg; - input intake_lobe_center: 70 * units.deg; - input exhaust_lobe_center: 70 * units.deg; - input advance: 0.0 * units.deg; - input base_radius: 0.75 * units.inch; - - output intake_cam: _intake_cam; - output exhaust_cam: _exhaust_cam; - - camshaft_parameters params( - advance: advance, - base_radius: base_radius - ) - - camshaft _intake_cam(params, lobe_profile: intake_lobe_profile) - camshaft _exhaust_cam(params, lobe_profile: exhaust_lobe_profile) - - label rot(2 * (360 / 6.0) * units.deg) - label rot360(360 * units.deg) - - // 1 5 3 6 2 4 - _exhaust_cam - .add_lobe(rot360 - exhaust_lobe_center + (0.0 * units.deg)) - .add_lobe(rot360 - exhaust_lobe_center + (480.0 * units.deg)) - .add_lobe(rot360 - exhaust_lobe_center + (240.0 * units.deg)) - .add_lobe(rot360 - exhaust_lobe_center + (600.0 * units.deg)) - .add_lobe(rot360 - exhaust_lobe_center + (120.0 * units.deg)) - .add_lobe(rot360 - exhaust_lobe_center + (360.0 * units.deg)) - - _intake_cam - .add_lobe(rot360 + intake_lobe_center + (0.0 * units.deg)) - .add_lobe(rot360 + intake_lobe_center + (480.0 * units.deg)) - .add_lobe(rot360 + intake_lobe_center + (240.0 * units.deg)) - .add_lobe(rot360 + intake_lobe_center + (600.0 * units.deg)) - .add_lobe(rot360 + intake_lobe_center + (120.0 * units.deg)) - .add_lobe(rot360 + intake_lobe_center + (360.0 * units.deg)) -} - -private node compression { - input stroke: 10.11 * units.cm; - input bore: 10.16 * units.cm; - input const: 0.785; - input ratio: 10.5; - input compression: (((stroke * (bore * bore) * const) / ratio) * units.cc); -} - -private node ford_head { - input intake_camshaft; - input exhaust_camshaft; - input chamber_volume: (((10.11 * (10.16 * 10.16) * 0.785) / 10.5) * units.cc); - input flip_display: false; - - input flow_attenuation: 0.95; - input lift_scale: 1.0; - alias output __out: head; - - function intake_flow(1.0 * units.mm) - intake_flow - .add_flow_sample(0 * lift_scale, 0 * flow_attenuation) - .add_flow_sample(1 * lift_scale, 30 * flow_attenuation) - .add_flow_sample(2 * lift_scale, 60 * flow_attenuation) - .add_flow_sample(3 * lift_scale, 90 * flow_attenuation) - .add_flow_sample(4 * lift_scale, 125 * flow_attenuation) - .add_flow_sample(5 * lift_scale, 160 * flow_attenuation) - .add_flow_sample(6 * lift_scale, 195 * flow_attenuation) - .add_flow_sample(7 * lift_scale, 210 * flow_attenuation) - .add_flow_sample(8 * lift_scale, 235 * flow_attenuation) - .add_flow_sample(9 * lift_scale, 270 * flow_attenuation) - .add_flow_sample(10 * lift_scale, 305 * flow_attenuation) - .add_flow_sample(11 * lift_scale, 320 * flow_attenuation) - .add_flow_sample(12 * lift_scale, 335 * flow_attenuation) - - function exhaust_flow(1.0 * units.mm) - exhaust_flow - .add_flow_sample(0 * lift_scale, 0 * flow_attenuation) - .add_flow_sample(1 * lift_scale, 30 * flow_attenuation) - .add_flow_sample(2 * lift_scale, 55 * flow_attenuation) - .add_flow_sample(3 * lift_scale, 85 * flow_attenuation) - .add_flow_sample(4 * lift_scale, 115 * flow_attenuation) - .add_flow_sample(5 * lift_scale, 140 * flow_attenuation) - .add_flow_sample(6 * lift_scale, 160 * flow_attenuation) - .add_flow_sample(7 * lift_scale, 180 * flow_attenuation) - .add_flow_sample(8 * lift_scale, 205 * flow_attenuation) - .add_flow_sample(9 * lift_scale, 220 * flow_attenuation) - .add_flow_sample(10 * lift_scale, 240 * flow_attenuation) - .add_flow_sample(11 * lift_scale, 260 * flow_attenuation) - .add_flow_sample(12 * lift_scale, 280 * flow_attenuation) - - - cylinder_head head( - chamber_volume: chamber_volume, - intake_runner_volume: 220 * units.cc, - intake_runner_cross_section_area: (1.90 * units.inch) * (1.16 * units.inch), - exhaust_runner_volume: 100 * units.cc, - exhaust_runner_cross_section_area: (1.75 * units.inch) * (1.25 * units.inch), - - intake_port_flow: intake_flow, - exhaust_port_flow: exhaust_flow, - intake_camshaft: intake_camshaft, - exhaust_camshaft: exhaust_camshaft, - flip_display: flip_display - - ) -} - -public node ford300 { - alias output __out: engine; - - wires wires() - - engine engine( - name: "Ford 300 I6 Cammed", - starter_torque: 300 * units.lb_ft, - starter_speed: 650 * units.rpm, - redline: 5200 * units.rpm, - fuel: fuel( - name: Fuel_Name, - molecular_mass: Fuel_Molecular_Mass * units.g, - density: Fuel_Density, - energy_density: Fuel_Energy_Density, - molecular_afr: Fuel_Molecular_AFR, - max_burning_efficiency: Fuel_Maximum_Burning_Efficiency, - burning_efficiency_randomness: Fuel_Burning_Efficiency_Randomness, - low_efficiency_attenuation: Fuel_Low_Efficiency_Attenuation, - max_turbulence_effect: Fuel_Max_Turbulence_Effect, - max_dilution_effect: Fuel_Max_Dilution_Effect - ), - throttle_gamma: 1.0, - jitter: 0.5, - noise: 0.5, - hf_gain: 0.0005, - simulation_frequency: 8000 - ) - - label stroke(10.11 * units.cm) - label bore(10.16 * units.cm) - label rod_length(157.734 * units.mm) - label rod_mass(671 * units.g) - label compression_height(44.196 * units.mm) - label crank_mass(75 * units.lb) - label flywheel_mass(30 * units.lb) - label flywheel_radius(5.5 * units.inch) - label const(0.785) - label ratio(10.5) - - label crank_moment( - disk_moment_of_inertia(mass: crank_mass, radius: stroke / 2) - ) - label flywheel_moment( - disk_moment_of_inertia(mass: flywheel_mass, radius: flywheel_radius) - ) - label other_moment( // Moment from cams, pulleys, etc [estimated] - disk_moment_of_inertia(mass: 5 * units.kg, radius: 8.0 * units.cm) - ) - - crankshaft c0( - throw: stroke / 2, - flywheel_mass: flywheel_mass, - mass: crank_mass, - friction_torque: 5.0 * units.lb_ft, - moment_of_inertia: - crank_moment + flywheel_moment + other_moment, - position_x: 0.0, - position_y: 0.0, - tdc: 125 * units.deg - ) - - // 1 5 3 6 2 4 - rod_journal rj0(angle: 0 * units.deg) - rod_journal rj1(angle: 120 * units.deg) - rod_journal rj2(angle: 240 * units.deg) - rod_journal rj3(angle: 240 * units.deg) - rod_journal rj4(angle: 120 * units.deg) - rod_journal rj5(angle: 0 * units.deg) - - c0 - .add_rod_journal(rj0) - .add_rod_journal(rj1) - .add_rod_journal(rj2) - .add_rod_journal(rj3) - .add_rod_journal(rj4) - .add_rod_journal(rj5) - - piston_parameters piston_params( - mass: 820 * units.g, - blowby: 0, - compression_height: compression_height, - wrist_pin_position: 0 * units.mm, - displacement: 0.0 - ) - - connecting_rod_parameters cr_params( - mass: rod_mass, - moment_of_inertia: rod_moment_of_inertia( - mass: rod_mass, - length: rod_length - ), - center_of_mass: 0.0, - length: rod_length - ) - - cylinder_bank_parameters bank_params( - bore: bore, - deck_height: stroke / 2 + rod_length + compression_height - ) - - intake intake( - plenum_volume: 1250 * units.cc, - plenum_cross_section_area: 35.0 * units.cm2, - intake_flow_rate: k_carb(300.0), - runner_flow_rate: k_carb(180.0), - runner_length: 26.0 * units.inch, - idle_flow_rate: k_carb(0.15), - idle_throttle_plate_position: 0.99325 - ) - - label exhaust_radius((2.5)/2 * units.inch) - - exhaust_system_parameters es_params( - outlet_flow_rate: k_carb(380.0), - collector_cross_section_area: circle_area(2.5 * units.inch), - primary_tube_length: 36.0 * units.inch, - primary_flow_rate: k_carb(163.0), - velocity_decay: 1.0 - ) - - exhaust_system exhaust0( - es_params, - length: 106.65 * units.inch, - audio_volume: 1.0, - impulse_response: ir_lib.smooth_39) - - label spacing(0.5 * units.inch) - - cylinder_bank b0(bank_params, angle: 0) - b0 - .add_cylinder( - piston: piston(piston_params, blowby: k_28inH2O(0.1)), - connecting_rod: connecting_rod(cr_params), - rod_journal: rj0, - intake: intake, - exhaust_system: exhaust0, - ignition_wire: wires.wire1, - primary_length: spacing * 5, - sound_attenuation: 0.9 - ) - .add_cylinder( - piston: piston(piston_params, blowby: k_28inH2O(0.05)), - connecting_rod: connecting_rod(cr_params), - rod_journal: rj1, - intake: intake, - exhaust_system: exhaust0, - ignition_wire: wires.wire2, - primary_length: spacing * 4, - sound_attenuation: 0.95 - ) - .add_cylinder( - piston: piston(piston_params, blowby: k_28inH2O(0.1)), - connecting_rod: connecting_rod(cr_params), - rod_journal: rj2, - intake: intake, - exhaust_system: exhaust0, - ignition_wire: wires.wire3, - primary_length: spacing * 3, - sound_attenuation: 0.9 - ) - .add_cylinder( - piston: piston(piston_params, blowby: k_28inH2O(0.05)), - connecting_rod: connecting_rod(cr_params), - rod_journal: rj3, - intake: intake, - exhaust_system: exhaust0, - ignition_wire: wires.wire4, - primary_length: spacing * 3, - sound_attenuation: 0.97 - ) - .add_cylinder( - piston: piston(piston_params, blowby: k_28inH2O(0.1)), - connecting_rod: connecting_rod(cr_params), - rod_journal: rj4, - intake: intake, - exhaust_system: exhaust0, - ignition_wire: wires.wire5, - primary_length: spacing * 4, - sound_attenuation: 0.98 - ) - .add_cylinder( - piston: piston(piston_params, blowby: k_28inH2O(0.05)), - connecting_rod: connecting_rod(cr_params), - rod_journal: rj5, - intake: intake, - exhaust_system: exhaust0, - ignition_wire: wires.wire6, - primary_length: spacing * 5, - sound_attenuation: 0.93 - ) - - engine - .add_cylinder_bank(b0) - - engine.add_crankshaft(c0) - - ford_camshaft_builder camshaft( - in_lobe_profile: ford_lobe_profile_int(), - ex_lobe_profile: ford_lobe_profile_exh() - ) - - b0.set_cylinder_head ( - ford_head( - intake_camshaft: camshaft.intake_cam, - exhaust_camshaft: camshaft.exhaust_cam, - flip_display: false - ) -) - - function timing_curve(1000 * units.rpm) - timing_curve - .add_sample(0000 * units.rpm, 6 * units.deg) - .add_sample(1000 * units.rpm, 12 * units.deg) - .add_sample(2000 * units.rpm, 20 * units.deg) - .add_sample(3000 * units.rpm, 26 * units.deg) - .add_sample(4000 * units.rpm, 30 * units.deg) - .add_sample(5000 * units.rpm, 34 * units.deg) - .add_sample(6000 * units.rpm, 34 * units.deg) - - engine.add_ignition_module( - wb_ignition( - wires: wires, - timing_curve: timing_curve, - rev_limit: 5500 * units.rpm - ) - ) -} - -private node f150_vehicle { - alias output __out: - vehicle( - mass: 3892 * units.lb, - drag_coefficient: 0.4, - cross_sectional_area: (79 * units.inch) * (70.8 * units.inch), - diff_ratio: 3.55, - tire_radius: 14 * units.inch, - rolling_resistance: 500 * units.N - ); -} - -private node m5od_transmission { - alias output __out: - transmission( - max_clutch_torque: 5000 * units.lb_ft - ) - .add_gear(3.60) - .add_gear(2.12) - .add_gear(1.41) - .add_gear(1.00) - .add_gear(0.85); -} - -public node main { - run( - engine: ford300(), - transmission: m5od_transmission(), - vehicle: f150_vehicle() - ) -} - -main() diff --git a/es/L539 V12.mr b/es/L539 V12.mr deleted file mode 100644 index 9c76334..0000000 --- a/es/L539 V12.mr +++ /dev/null @@ -1,681 +0,0 @@ -// Engine Sim V0.1.14A -// Lamborghini Aventador 572 HP @ 7500 -// Created by oror 2023 -// 1-12-4-9-2-11-6-7-3-10-5-8 - -import "engine_sim.mr" - -units units() -constants constants() -impulse_response_library ir_lib() - -label bore(95.0) -label stroke(76.4) -label compression_ratio(10.7) -label con_rod(155.0) -label IVL(11.38) -label EVL(11.51) -label compression_height(27.6 * units.mm) -label intake_valve_diameter(33.4) -label exhaust_valve_diameter(29.4) -label intake_valves(2.0) -label exhaust_valves(2.0) - -label PT_H(PCH_H / 2.0) // Piston top thickness. Calculated automatically, override only if you are a professional. Units: millimeters. // -label PS_H((PCH_H * 0) - PT_H) // Piston skirt height. Calculated automatically, override only if you are a professional. Units: millimeters. // -label PCH_d(4.0) // Piston compression height divisor. Determines the "Piston stroke/piston compression height" ratio. // -label PCH_H(E_S / PCH_d) // Piston compression height. Calculated automatically, but can be overridden. Units: millimeters. // -label E_S(108.4) // Piston stroke. Units: millimeters. // - - -label volume(6.192) // L; port_flow.py v0.7 -label redline(8500.0) // RPM 7700 Default - -label cyl(12.0) -label row(2.0) -label cycle(720.0 * units.deg) -label vee(60.0 * units.deg) -label rot(cycle / cyl) -label rot90(90.0 * units.deg) -label rot180(180.0 * units.deg) -label rot360(360.0 * units.deg) -label cyl_base(cyl / row) -label rot_base(cycle / cyl_base) - -// Murcielago valve timings -label IVO(40.0 * units.deg) //BTDC -label IVC(68.0 * units.deg) //ABDC -label EVO(68.0 * units.deg) //BBDC -label EVC(22.0 * units.deg) //ATDC - -label intake_duration(IVO + IVC + rot180) -label exhaust_duration(EVO + EVC + rot180) - -label ILC((rot180 - IVO + IVC) / 2.0 + rot360) -label ELC((rot180 - EVO + EVC) / 2.0 + rot180) - -label con_rod_mass(650.0) // ? g -label piston_mass(500.0) // ? -label crank_mass(25.0) // ? kg -label flywheel_mass(7.0) // kg - -label exhaust_delay_coeff(1.5) - -/* -{ - "cam_cfg":{ - "es_version":"0.1.14a", - "resolution":64, - "intake_volume":0.3, - "exhaust_volume":0.3, - "intake_at_lift":0.5, - "exhaust_at_lift":0.5, - "intake_trim":1.0, - "exhaust_trim":1.0, - "intake_sigma":1.0, - "exhaust_sigma":1.0, - "intake_base_mult":1.66, - "exhaust_base_mult":1.66, - "intake_cos":true, - "exhaust_cos":true, - "equal_base_radius":true, - "ramp_steepness": 3 - } -} -*/ -public node intake_lobe_profile { - // lobes.py v0.8 - // IVO: 40.0 IVC: 68.0 EVO: 68.0 EVC: 22.0 - // ID: 288.0 ED: 270.0 LSA: 108.50, ADV: 4.50 I_COS: True E_COS True - alias output __out: _lobe_profile; - function _lobe_profile(3.058 * units.deg) - _lobe_profile - .add_sample(-96.329 * units.deg, 0.000 * units.mm) - .add_sample(-93.271 * units.deg, 0.000 * units.mm) - .add_sample(-90.213 * units.deg, 0.000 * units.mm) - .add_sample(-87.155 * units.deg, 0.020 * units.mm) - .add_sample(-84.097 * units.deg, 0.058 * units.mm) - .add_sample(-81.039 * units.deg, 0.129 * units.mm) - .add_sample(-77.981 * units.deg, 0.230 * units.mm) - .add_sample(-74.923 * units.deg, 0.357 * units.mm) - .add_sample(-71.865 * units.deg, 0.506 * units.mm) - .add_sample(-68.807 * units.deg, 0.662 * units.mm) - .add_sample(-65.749 * units.deg, 0.846 * units.mm) - .add_sample(-62.690 * units.deg, 1.064 * units.mm) - .add_sample(-59.632 * units.deg, 1.319 * units.mm) - .add_sample(-56.574 * units.deg, 1.614 * units.mm) - .add_sample(-53.516 * units.deg, 1.955 * units.mm) - .add_sample(-50.458 * units.deg, 2.345 * units.mm) - .add_sample(-47.400 * units.deg, 2.787 * units.mm) - .add_sample(-44.342 * units.deg, 3.283 * units.mm) - .add_sample(-41.284 * units.deg, 3.834 * units.mm) - .add_sample(-38.226 * units.deg, 4.438 * units.mm) - .add_sample(-35.168 * units.deg, 5.091 * units.mm) - .add_sample(-32.110 * units.deg, 5.785 * units.mm) - .add_sample(-29.052 * units.deg, 6.511 * units.mm) - .add_sample(-25.994 * units.deg, 7.254 * units.mm) - .add_sample(-22.936 * units.deg, 7.997 * units.mm) - .add_sample(-19.877 * units.deg, 8.719 * units.mm) - .add_sample(-16.819 * units.deg, 9.398 * units.mm) - .add_sample(-13.761 * units.deg, 10.011 * units.mm) - .add_sample(-10.703 * units.deg, 10.534 * units.mm) - .add_sample(-7.645 * units.deg, 10.948 * units.mm) - .add_sample(-4.587 * units.deg, 11.234 * units.mm) - .add_sample(-1.529 * units.deg, 11.380 * units.mm) - .add_sample(1.529 * units.deg, 11.380 * units.mm) - .add_sample(4.587 * units.deg, 11.234 * units.mm) - .add_sample(7.645 * units.deg, 10.948 * units.mm) - .add_sample(10.703 * units.deg, 10.534 * units.mm) - .add_sample(13.761 * units.deg, 10.011 * units.mm) - .add_sample(16.819 * units.deg, 9.398 * units.mm) - .add_sample(19.877 * units.deg, 8.719 * units.mm) - .add_sample(22.936 * units.deg, 7.997 * units.mm) - .add_sample(25.994 * units.deg, 7.254 * units.mm) - .add_sample(29.052 * units.deg, 6.511 * units.mm) - .add_sample(32.110 * units.deg, 5.785 * units.mm) - .add_sample(35.168 * units.deg, 5.091 * units.mm) - .add_sample(38.226 * units.deg, 4.438 * units.mm) - .add_sample(41.284 * units.deg, 3.834 * units.mm) - .add_sample(44.342 * units.deg, 3.283 * units.mm) - .add_sample(47.400 * units.deg, 2.787 * units.mm) - .add_sample(50.458 * units.deg, 2.345 * units.mm) - .add_sample(53.516 * units.deg, 1.955 * units.mm) - .add_sample(56.574 * units.deg, 1.614 * units.mm) - .add_sample(59.632 * units.deg, 1.319 * units.mm) - .add_sample(62.690 * units.deg, 1.064 * units.mm) - .add_sample(65.749 * units.deg, 0.846 * units.mm) - .add_sample(68.807 * units.deg, 0.662 * units.mm) - .add_sample(71.865 * units.deg, 0.506 * units.mm) - .add_sample(74.923 * units.deg, 0.357 * units.mm) - .add_sample(77.981 * units.deg, 0.230 * units.mm) - .add_sample(81.039 * units.deg, 0.129 * units.mm) - .add_sample(84.097 * units.deg, 0.058 * units.mm) - .add_sample(87.155 * units.deg, 0.020 * units.mm) - .add_sample(90.213 * units.deg, 0.000 * units.mm) - .add_sample(93.271 * units.deg, 0.000 * units.mm) - .add_sample(96.329 * units.deg, 0.000 * units.mm) -} - -public node exhaust_lobe_profile { - // lobes.py v0.8 - // IVO: 40.0 IVC: 68.0 EVO: 68.0 EVC: 22.0 - // ID: 288.0 ED: 270.0 LSA: 108.50, ADV: 4.50 I_COS: True E_COS True - alias output __out: _lobe_profile; - function _lobe_profile(2.862 * units.deg) - _lobe_profile - .add_sample(-90.155 * units.deg, 0.000 * units.mm) - .add_sample(-87.293 * units.deg, 0.000 * units.mm) - .add_sample(-84.431 * units.deg, 0.000 * units.mm) - .add_sample(-81.568 * units.deg, 0.020 * units.mm) - .add_sample(-78.706 * units.deg, 0.059 * units.mm) - .add_sample(-75.844 * units.deg, 0.130 * units.mm) - .add_sample(-72.982 * units.deg, 0.233 * units.mm) - .add_sample(-70.120 * units.deg, 0.361 * units.mm) - .add_sample(-67.258 * units.deg, 0.512 * units.mm) - .add_sample(-64.396 * units.deg, 0.669 * units.mm) - .add_sample(-61.534 * units.deg, 0.856 * units.mm) - .add_sample(-58.672 * units.deg, 1.076 * units.mm) - .add_sample(-55.810 * units.deg, 1.334 * units.mm) - .add_sample(-52.948 * units.deg, 1.633 * units.mm) - .add_sample(-50.086 * units.deg, 1.978 * units.mm) - .add_sample(-47.224 * units.deg, 2.372 * units.mm) - .add_sample(-44.362 * units.deg, 2.819 * units.mm) - .add_sample(-41.500 * units.deg, 3.321 * units.mm) - .add_sample(-38.638 * units.deg, 3.878 * units.mm) - .add_sample(-35.776 * units.deg, 4.489 * units.mm) - .add_sample(-32.914 * units.deg, 5.149 * units.mm) - .add_sample(-30.052 * units.deg, 5.851 * units.mm) - .add_sample(-27.189 * units.deg, 6.585 * units.mm) - .add_sample(-24.327 * units.deg, 7.337 * units.mm) - .add_sample(-21.465 * units.deg, 8.088 * units.mm) - .add_sample(-18.603 * units.deg, 8.818 * units.mm) - .add_sample(-15.741 * units.deg, 9.505 * units.mm) - .add_sample(-12.879 * units.deg, 10.125 * units.mm) - .add_sample(-10.017 * units.deg, 10.655 * units.mm) - .add_sample(-7.155 * units.deg, 11.073 * units.mm) - .add_sample(-4.293 * units.deg, 11.362 * units.mm) - .add_sample(-1.431 * units.deg, 11.510 * units.mm) - .add_sample(1.431 * units.deg, 11.510 * units.mm) - .add_sample(4.293 * units.deg, 11.362 * units.mm) - .add_sample(7.155 * units.deg, 11.073 * units.mm) - .add_sample(10.017 * units.deg, 10.655 * units.mm) - .add_sample(12.879 * units.deg, 10.125 * units.mm) - .add_sample(15.741 * units.deg, 9.505 * units.mm) - .add_sample(18.603 * units.deg, 8.818 * units.mm) - .add_sample(21.465 * units.deg, 8.088 * units.mm) - .add_sample(24.327 * units.deg, 7.337 * units.mm) - .add_sample(27.189 * units.deg, 6.585 * units.mm) - .add_sample(30.052 * units.deg, 5.851 * units.mm) - .add_sample(32.914 * units.deg, 5.149 * units.mm) - .add_sample(35.776 * units.deg, 4.489 * units.mm) - .add_sample(38.638 * units.deg, 3.878 * units.mm) - .add_sample(41.500 * units.deg, 3.321 * units.mm) - .add_sample(44.362 * units.deg, 2.819 * units.mm) - .add_sample(47.224 * units.deg, 2.372 * units.mm) - .add_sample(50.086 * units.deg, 1.978 * units.mm) - .add_sample(52.948 * units.deg, 1.633 * units.mm) - .add_sample(55.810 * units.deg, 1.334 * units.mm) - .add_sample(58.672 * units.deg, 1.076 * units.mm) - .add_sample(61.534 * units.deg, 0.856 * units.mm) - .add_sample(64.396 * units.deg, 0.669 * units.mm) - .add_sample(67.258 * units.deg, 0.512 * units.mm) - .add_sample(70.120 * units.deg, 0.361 * units.mm) - .add_sample(72.982 * units.deg, 0.233 * units.mm) - .add_sample(75.844 * units.deg, 0.130 * units.mm) - .add_sample(78.706 * units.deg, 0.059 * units.mm) - .add_sample(81.568 * units.deg, 0.020 * units.mm) - .add_sample(84.431 * units.deg, 0.000 * units.mm) - .add_sample(87.293 * units.deg, 0.000 * units.mm) - .add_sample(90.155 * units.deg, 0.000 * units.mm) -} - -intake_lobe_profile intake_lobe_profile() -exhaust_lobe_profile exhaust_lobe_profile() - -private node add_lobes { - input base; - input shift: 0.0; - input this; - alias output __out: this; - - this.add_lobe(base + 0 * rot * row + shift) - this.add_lobe(base + 2 * rot * row + shift) - this.add_lobe(base + 4 * rot * row + shift) - this.add_lobe(base + 1 * rot * row + shift) - this.add_lobe(base + 5 * rot * row + shift) - this.add_lobe(base + 3 * rot * row + shift) -} - -public node bank_builder { - input angle; - input phasing; - input ignition; - input intake; - input exhaust; - input pls; - - input rj0; - input rj1; - input rj2; - input rj3; - input rj4; - input rj5; - - input flip: false; - - output bank: _b0; - - ignition_wire _wire1() - ignition_wire _wire2() - ignition_wire _wire3() - ignition_wire _wire4() - ignition_wire _wire5() - ignition_wire _wire6() - - - - piston_parameters piston_params( - mass: piston_mass * units.g, - blowby: k_28inH2O(0.1), - compression_height: compression_height, - wrist_pin_position: 0.0, - displacement: 0.0 - ) - - connecting_rod_parameters cr_params( - mass: con_rod_mass * units.g, - moment_of_inertia: rod_moment_of_inertia( - mass: con_rod_mass * units.g, - length: con_rod * units.mm - ), - center_of_mass: 0.0, - length: con_rod * units.mm - ) - - cylinder_bank_parameters bank_params( - bore: bore * units.mm, - deck_height: (con_rod + stroke / 2.0) * units.mm + compression_height - ) - - camshaft _intake_cam_0(base_radius: 19.0 * units.mm, lobe_profile: intake_lobe_profile) - camshaft _exhaust_cam_0(base_radius: 19.0 * units.mm, lobe_profile: exhaust_lobe_profile) - - _intake_cam_0.add_lobes(ILC, phasing) - _exhaust_cam_0.add_lobes(ELC, phasing) - - ignition.connect_wire(_wire1, rot_base * 0 + phasing) - ignition.connect_wire(_wire4, rot_base * 1 + phasing) - ignition.connect_wire(_wire2, rot_base * 2 + phasing) - ignition.connect_wire(_wire6, rot_base * 3 + phasing) - ignition.connect_wire(_wire3, rot_base * 4 + phasing) - ignition.connect_wire(_wire5, rot_base * 5 + phasing) - - cylinder_bank _b0(bank_params, angle: angle) - - _b0 - .add_cylinder( - piston: piston(piston_params), - connecting_rod: connecting_rod(cr_params), - rod_journal: rj0, - intake: intake, - exhaust_system: exhaust, - primary_length: pls.pl0, - ignition_wire: _wire1 - ) - .add_cylinder( - piston: piston(piston_params), - connecting_rod: connecting_rod(cr_params), - rod_journal: rj1, - intake: intake, - exhaust_system: exhaust, - primary_length: pls.pl1, - ignition_wire: _wire2 - ) - .add_cylinder( - piston: piston(piston_params), - connecting_rod: connecting_rod(cr_params), - rod_journal: rj2, - intake: intake, - exhaust_system: exhaust, - primary_length: pls.pl2, - ignition_wire: _wire3 - ) - .add_cylinder( - piston: piston(piston_params), - connecting_rod: connecting_rod(cr_params), - rod_journal: rj3, - intake: intake, - exhaust_system: exhaust, - primary_length: pls.pl3, - ignition_wire: _wire4 - ) - .add_cylinder( - piston: piston(piston_params), - connecting_rod: connecting_rod(cr_params), - rod_journal: rj4, - intake: intake, - exhaust_system: exhaust, - primary_length: pls.pl4, - ignition_wire: _wire5 - ) - .add_cylinder( - piston: piston(piston_params), - connecting_rod: connecting_rod(cr_params), - rod_journal: rj5, - intake: intake, - exhaust_system: exhaust, - primary_length: pls.pl5, - ignition_wire: _wire6 - ) - .set_cylinder_head( - head( - intake_camshaft: _intake_cam_0, - exhaust_camshaft: _exhaust_cam_0, - flip_display: flip - ) - ) -} - -private node add_flow_sample { - input lift; - input flow; - input this; - alias output __out: this; - - this.add_sample(lift * units.mm, k_28inH2O(flow)) -} - -public node head { // generated by port_flow.py v0.7 - // intake H: 33.4 L: 11.38 N: 2.0 - // exhaust H: 29.4 L: 11.51 N: 2.0 - // intake port area: 14.9 cm2; effective lift: 7.2 mm - // exhaust port area: 11.5 cm2; effective lift: 6.4 mm - // cylinder volume: 516.0 cc (31.5 CI); engine volume: 6.192 L (377.9 CI) - // 16 harmonic intake runner length: 10.7 cm; diameter: 4.7 cm - // primary length: 37.4 cm, area: 11.6 cm2, diameter: 3.8 cm - // collector diameter: 9.4 cm, area: 69.8 cm2 - // target power: 7650 RPM, torque: 5049 RPM, power factor 1.5 - - input intake_camshaft; - input exhaust_camshaft; - input flip_display: false; - - alias output __out: head; - function intake_flow(0.759 * units.mm) - intake_flow - .add_flow_sample(0.0, 0.0) - .add_flow_sample(0.759, 35.4) - .add_flow_sample(1.517, 61.8) - .add_flow_sample(2.276, 84.9) - .add_flow_sample(3.035, 105.7) - .add_flow_sample(3.793, 124.9) - .add_flow_sample(4.552, 142.8) - .add_flow_sample(5.311, 159.7) - .add_flow_sample(6.069, 175.6) - .add_flow_sample(6.828, 190.7) - .add_flow_sample(7.587, 201.7) - .add_flow_sample(8.345, 202.2) - .add_flow_sample(9.104, 202.7) - .add_flow_sample(9.863, 203.2) - .add_flow_sample(10.621, 203.8) - .add_flow_sample(11.380, 204.4) - - function exhaust_flow(0.767 * units.mm) - exhaust_flow - .add_flow_sample(0.0, 0.0) - .add_flow_sample(0.767, 30.7) - .add_flow_sample(1.535, 53.4) - .add_flow_sample(2.302, 73.1) - .add_flow_sample(3.069, 90.9) - .add_flow_sample(3.837, 107.2) - .add_flow_sample(4.604, 122.4) - .add_flow_sample(5.371, 136.6) - .add_flow_sample(6.139, 149.9) - .add_flow_sample(6.906, 156.1) - .add_flow_sample(7.673, 156.5) - .add_flow_sample(8.441, 156.9) - .add_flow_sample(9.208, 157.3) - .add_flow_sample(9.975, 157.8) - .add_flow_sample(10.743, 158.3) - .add_flow_sample(11.510, 158.8) - - generic_cylinder_head head( - chamber_volume: 48.224 * units.cc, - intake_runner_volume: 188.1 * units.cc, - intake_runner_cross_section_area: 17.6 * units.cm2, - exhaust_runner_volume: 62.7 * units.cc, - exhaust_runner_cross_section_area: 11.6 * units.cm2, - - intake_port_flow: intake_flow, - exhaust_port_flow: exhaust_flow, - valvetrain: standard_valvetrain( - intake_camshaft: intake_camshaft, - exhaust_camshaft: exhaust_camshaft - ), - flip_display: flip_display - ) -} - -public node eng { - alias output __out: engine; - - engine engine( - name: "Lamborghini L539 V12", - starter_torque: 100 * units.Nm, - starter_speed: 650 * units.rpm, - redline: redline * units.rpm, - fuel: fuel( // ChatGPT modern gasoline - max_turbulence_effect: 1.5, - burning_efficiency_randomness: 0.1, - max_burning_efficiency: 0.90, - molecular_mass: 116.0 * units.g, - energy_density: 46.5 * units.MJ / units.kg, - density: 0.74 * units.kg / units.L, - molecular_afr: 14.7 - ), - throttle_gamma: 1.5, - jitter: 0.10, - noise: 0.6, - hf_gain: 0.3, - convolution:0.98, - simulation_frequency: 5000 - ) - - label crank_moment(disk_moment_of_inertia(mass: crank_mass * units.kg, radius: (stroke / 2.0) * units.mm)) - label flywheel_moment(disk_moment_of_inertia(mass: flywheel_mass * units.kg, radius: (stroke * 3.5) * units.mm)) - label other_moment(disk_moment_of_inertia(mass: 1 * units.kg, radius: 1.0 * units.cm)) - - crankshaft c0( - throw: (stroke / 2.0) * units.mm, - flywheel_mass: flywheel_mass * units.kg, - mass: crank_mass * units.kg, - friction_torque: 9.3 * units.Nm, // port_flow.py v0.7 - moment_of_inertia: crank_moment + flywheel_moment + other_moment, - position_x: 0.0, - position_y: 0.0, - tdc: 0.0 - ) - - ignition_module ignition(timing_curve: timing_curve, rev_limit: redline * 1.05 * units.rpm, limiter_duration: 0.0598) - - exh_setup_1 exh() - - bank_builder bank0( - angle: vee / 2.0, - phasing: 0.0 * units.deg, - ignition: ignition, - intake: intake, - exhaust: exh.ex0, - pls: exh, - rj0: rj0, - rj1: rj1, - rj2: rj2, - rj3: rj3, - rj4: rj4, - rj5: rj5, - flip: true - ) - - bank_builder bank1( - angle: -vee / 2.0, - phasing: vee + rot360, - ignition: ignition, - intake: intake, - exhaust: exh.ex1, - pls: exh, - rj0: rj0, - rj1: rj1, - rj2: rj2, - rj3: rj3, - rj4: rj4, - rj5: rj5 - ) - - rod_journal rj0(angle: rot * 0 + rot90 + vee / 2) - rod_journal rj1(angle: rot * 4 + rot90 + vee / 2) - rod_journal rj2(angle: rot * 8 + rot90 + vee / 2) - rod_journal rj3(angle: rot * 2 + rot90 + vee / 2) - rod_journal rj4(angle: rot * 10 + rot90 + vee / 2) - rod_journal rj5(angle: rot * 6 + rot90 + vee / 2) - - c0 - .add_rod_journal(rj0) - .add_rod_journal(rj1) - .add_rod_journal(rj2) - .add_rod_journal(rj3) - .add_rod_journal(rj4) - .add_rod_journal(rj5) - - intake intake( - plenum_volume: 8.9 * units.L, // port_flow.py v0.7 - plenum_cross_section_area: 105.7 * units.cm2, // port_flow.py v0.7 - runner_length: 10.7 * units.cm, // port_flow.py v0.7 - intake_flow_rate: k_carb(1096.5), // port_flow.py v0.7 - idle_flow_rate: k_carb(0.03), - idle_throttle_plate_position: 0.9975, - runner_flow_rate: k_carb(182.7), // port_flow.py v0.7 - velocity_decay: 0.05 - ) - - engine - .add_crankshaft(c0) - .add_cylinder_bank(bank0.bank) - .add_cylinder_bank(bank1.bank) - .add_ignition_module(ignition) - - // ignition_timing.py v0.3 from = 10.0, to = 37.0, i = 500, r = 8500 - function timing_curve(850.0 * units.rpm) - timing_curve - .add_sample(0.0 * units.rpm, 0.0 * units.deg) - .add_sample(850.0 * units.rpm, 10.0 * units.deg) - .add_sample(1700.0 * units.rpm, 15.0 * units.deg) - .add_sample(2550.0 * units.rpm, 19.3 * units.deg) - .add_sample(3400.0 * units.rpm, 23.1 * units.deg) - .add_sample(4250.0 * units.rpm, 26.3 * units.deg) - .add_sample(5100.0 * units.rpm, 29.1 * units.deg) - .add_sample(5950.0 * units.rpm, 31.5 * units.deg) - .add_sample(6800.0 * units.rpm, 33.6 * units.deg) - .add_sample(7650.0 * units.rpm, 35.4 * units.deg) - .add_sample(8500.0 * units.rpm, 37.0 * units.deg) - .add_sample(9350.0 * units.rpm, -15.0 * units.deg) - .add_sample(10200.0 * units.rpm, -60.0 * units.deg) -} - -private node exh_setup_1 { - output ex0: _ex0; - output ex1: _ex1; - - output pl0: _pl0; - output pl1: _pl1; - output pl2: _pl2; - output pl3: _pl3; - output pl4: _pl4; - output pl5: _pl5; - - label spacing_factor(1.1) - label flange_density(1.0 * exhaust_delay_coeff) - label collector_cross_section_area(34.9) // port_flow.py v0.7 - - label exhaust_pipe_length_0(151.0) // cm - label exhaust_volume_0(collector_cross_section_area * exhaust_pipe_length_0 / 100.0) // Litres - - label exhaust_pipe_length_1(150.0) // cm - label exhaust_volume_1(collector_cross_section_area * exhaust_pipe_length_0 / 100.0) // Litres - - label sh(0.2) - float _pl3 ((1.2 * bore * spacing_factor / flange_density) * units.mm) - float _pl4 ((1.3 * bore * spacing_factor / flange_density) * units.mm) - float _pl5 ((1.0 * bore * spacing_factor / flange_density) * units.mm) - float _pl0 (((1.2 + sh) * bore * spacing_factor / flange_density) * units.mm) - float _pl1 (((1.3 + sh) * bore * spacing_factor / flange_density) * units.mm) - float _pl2 (((1.0 + sh) * bore * spacing_factor / flange_density) * units.mm) - - exhaust_system_parameters es_params0( - outlet_flow_rate: k_carb(913.7), // port_flow.py v0.7 - collector_cross_section_area: 52.3 * units.cm2, // CF 1.5; port_flow.py v0.7 - length: exhaust_pipe_length_0 * units.cm, - primary_tube_length: 37.4 * units.cm, // port_flow.py v0.7 - primary_flow_rate: k_carb(304.6), // port_flow.py v0.7 - velocity_decay: 0.8, - volume: (exhaust_volume_0 + 5.0) * units.L - ) - - exhaust_system_parameters es_params1( - outlet_flow_rate: k_carb(913.7), // port_flow.py v0.7 - collector_cross_section_area: 52.3 * units.cm2, // CF 1.5; port_flow.py v0.7 - length: exhaust_pipe_length_1 * units.cm, - primary_tube_length: 37.4 * units.cm, // port_flow.py v0.7 - primary_flow_rate: k_carb(304.6), // port_flow.py v0.7 - velocity_decay: 0.8, - volume: (exhaust_volume_1 + 5.0) * units.L - ) - - exhaust_system _ex0(es_params0, impulse_response: ir_lib.sharp_0, audio_volume: 2000.005) - exhaust_system _ex1(es_params1, impulse_response: ir_lib.sharp_0, audio_volume: 2000.005) -} - -// Murcielago -public node veh { - alias output __out: vehicle; - - label car_mass(1750) // 1650 - - vehicle vehicle( - mass: 950 * units.kg, - drag_coefficient: 0.35, - cross_sectional_area: 2.02 * (units.m * units.m), - diff_ratio: 3.133, - stiffness: 20 * units.lb_ft / units.deg, - damping: 6.0, - max_flex: 15 * units.deg, - limit_flex: true, - simulate_flex: true, - tire_radius: 317.5 * units.mm, - rolling_resistance: 100 * units.N - ) -} - -// Murcielago -private node trn { - alias output __out: - transmission( - max_clutch_torque: 1750 * units.Nm, - max_clutch_flex: 25 * units.deg, - limit_clutch_flex: true, - clutch_stiffness: 10 * units.Nm / units.deg, - clutch_damping: 1.0, - simulate_flex: true - ) - .add_gear(2.941) - .add_gear(2.056) - .add_gear(1.520) - .add_gear(1.179) - .add_gear(1.030) - .add_gear(0.914); -} - -run( - engine: eng(), - transmission: trn(), - vehicle: veh() -) diff --git a/es/Lamborghini_6_5.mr b/es/Lamborghini_6_5.mr deleted file mode 100644 index 1fe267b..0000000 --- a/es/Lamborghini_6_5.mr +++ /dev/null @@ -1,532 +0,0 @@ -import "engine_sim.mr" - -units units() -constants constants() -impulse_response_library ir_lib() - -//Aventador SVJ - V12 6.5 L (L539) V2 - //engine file made by [dacxl] - //vehicle and transmission settings available, v12_vehicle & v12_transmission - -label cycle60(60 * units.deg) - -private node lamborghini_6_5_distributor { - input wires; - input timing_curve; - input rev_limit: 8500 * units.rpm; - input limiter_duration: 0.045; - alias output __out: - ignition_module(timing_curve: timing_curve, rev_limit: rev_limit, limiter_duration: limiter_duration) - .connect_wire(wires.wire1, 0) - .connect_wire(wires.wire12, 1.0 * cycle60) - .connect_wire(wires.wire4, 2.0 * cycle60) - .connect_wire(wires.wire9, 3.0 * cycle60) - .connect_wire(wires.wire2, 4.0 * cycle60) - .connect_wire(wires.wire11, 5.0 * cycle60) - .connect_wire(wires.wire6, 6.0 * cycle60) - .connect_wire(wires.wire7, 7.0 * cycle60) - .connect_wire(wires.wire3, 8.0 * cycle60) - .connect_wire(wires.wire10, 9.0 * cycle60) - .connect_wire(wires.wire5, 10.0 * cycle60) - .connect_wire(wires.wire8, 11.0 * cycle60) - ; -} - -//1–12–4–9–2–11–6–7–3–10–5–8 - // 6 7 - // 5 8 - // 4 9 - // 3 10 - // 2 11 - // 1 12 - -private node wires { - output wire1: ignition_wire(); - output wire2: ignition_wire(); - output wire3: ignition_wire(); - output wire4: ignition_wire(); - output wire5: ignition_wire(); - output wire6: ignition_wire(); - output wire7: ignition_wire(); - output wire8: ignition_wire(); - output wire9: ignition_wire(); - output wire10: ignition_wire(); - output wire11: ignition_wire(); - output wire12: ignition_wire(); -} - -private node add_sym_sample { - input angle; - input lift; - input this; - alias output __out: this; - - this.add_sample(angle * units.deg, lift * units.thou) - this.add_sample(-angle * units.deg, lift * units.thou) -} - -private node lamborghini_6_5_lobe_profile_int { - alias output __out: - harmonic_cam_lobe( - duration_at_50_thou: 200 * units.deg, - gamma: 1.5, - lift: 18.8 * units.mm, - steps: 100 - ); -} - -private node lamborghini_6_5_lobe_profile_exh { - alias output __out: - harmonic_cam_lobe( - duration_at_50_thou: 200 * units.deg, - gamma: 1.5, - lift: 18.8 * units.mm, - steps: 100 - ); -} - -private node lamborghini_6_5_camshaft_builder { - input lobe_profile: lamborghini_6_5_lobe_profile_int(); - input ex_lobe_profile: lamborghini_6_5_lobe_profile_exh(); - input intake_lobe_profile: lobe_profile; - input exhaust_lobe_profile: ex_lobe_profile; - input lobe_separation: 130.0 * units.deg; - input intake_lobe_center: lobe_separation; - input exhaust_lobe_center: lobe_separation; - input advance: -16.5* units.deg; - input base_radius: 1.0 * units.inch; - - output intake_cam_0: _intake_cam_0; - output intake_cam_1: _intake_cam_1; - output exhaust_cam_0: _exhaust_cam_0; - output exhaust_cam_1: _exhaust_cam_1; - - camshaft_parameters params( - advance: advance, - base_radius: base_radius - ) - - camshaft _intake_cam_0(params, lobe_profile: intake_lobe_profile) - camshaft _intake_cam_1(params, lobe_profile: intake_lobe_profile) - camshaft _exhaust_cam_0(params, lobe_profile: exhaust_lobe_profile) - camshaft _exhaust_cam_1(params, lobe_profile: exhaust_lobe_profile) - - label rot360(360 * units.deg) - label cyl(720/12 * units.deg) - - //1–12–4–9–2–11–6–7–3–10–5–8 - // 6 7 - // 5 8 - // 4 9 - // 3 10 - // 2 11 - // 1 12 -//1-5-3-3-5-1 - -label offset(0.045) - _exhaust_cam_0 - .add_lobe(rot360 - exhaust_lobe_center + 0 * cycle60 + 1* offset) //1 - .add_lobe(rot360 - exhaust_lobe_center + 4 * cycle60 + 3* offset) //2 - .add_lobe(rot360 - exhaust_lobe_center + 8 * cycle60 + 2* offset) //3 - .add_lobe(rot360 - exhaust_lobe_center + 2 * cycle60 - 2* offset) //4 - .add_lobe(rot360 - exhaust_lobe_center + 10 * cycle60 - 3* offset) //5 - .add_lobe(rot360 - exhaust_lobe_center + 6 * cycle60 - 1* offset) //6 - - _exhaust_cam_1 - .add_lobe(rot360 - exhaust_lobe_center + 1 * cycle60 + 1* offset) //12 - .add_lobe(rot360 - exhaust_lobe_center + 5 * cycle60 + 3* offset) //11 - .add_lobe(rot360 - exhaust_lobe_center + 9 * cycle60 + 2* offset) //10 - .add_lobe(rot360 - exhaust_lobe_center + 3 * cycle60 - 2* offset) //9 - .add_lobe(rot360 - exhaust_lobe_center + 11 * cycle60 - 3* offset) //8 - .add_lobe(rot360 - exhaust_lobe_center + 7 * cycle60 - 1* offset) //7 - - - _intake_cam_0 - .add_lobe(rot360 + intake_lobe_center + 0 * cycle60) //1 - .add_lobe(rot360 + intake_lobe_center + 4 * cycle60) //2 - .add_lobe(rot360 + intake_lobe_center + 8 * cycle60) //3 - .add_lobe(rot360 + intake_lobe_center + 2 * cycle60) //4 - .add_lobe(rot360 + intake_lobe_center + 10 * cycle60) //5 - .add_lobe(rot360 + intake_lobe_center + 6 * cycle60) //6 - - _intake_cam_1 - .add_lobe(rot360 + intake_lobe_center + 1 * cycle60) //12 - .add_lobe(rot360 + intake_lobe_center + 5 * cycle60) //11 - .add_lobe(rot360 + intake_lobe_center + 9 * cycle60) //10 - .add_lobe(rot360 + intake_lobe_center + 3 * cycle60) //9 - .add_lobe(rot360 + intake_lobe_center + 11 * cycle60) //8 - .add_lobe(rot360 + intake_lobe_center + 7 * cycle60) //7 - -} - -private node add_flow_sample { - input lift; - input flow; - input this; - alias output __out: this; - - this.add_sample(lift * units.mm, k_28inH2O(flow)) -} - -public node v12_vehicle { - input mass: (1525 + 80) * units.kg; //dry weight + driver weight (not with fluids to save weight and achieve more accurate acceleration) - input diff_ratio: 2.86; - input tire_radius: (27.91/2) * units.inch; - input drag_coefficient: 0.33; - input cross_sectional_area: 1.91 * units.m2; - - alias output __out: vehicle; - - vehicle vehicle( - mass: mass, - diff_ratio: diff_ratio, - tire_radius: tire_radius, - drag_coefficient: drag_coefficient, - cross_sectional_area: cross_sectional_area - ) -} - -public node v12_transmission { - input max_clutch_torque: 900 * units.lb_ft; - alias output __out: - transmission(max_clutch_torque) - .add_gear(3.91) - .add_gear(2.44) - .add_gear(1.81) - .add_gear(1.46) - .add_gear(1.19) - .add_gear(0.97) - .add_gear(0.89); -} - -public node lamborghini_6_5_head { - input intake_camshaft; - input exhaust_camshaft; - input chamber_volume: 41.0 * units.cc; - input flip_display: false; - - input flow_attenuation: 1.00; - input lift_scale: 1.0; - alias output __out: head; - - function intake_flow(1 * units.mm) - intake_flow - .add_flow_sample(0 * lift_scale, 0 * flow_attenuation) - .add_flow_sample(1 * lift_scale, 35 * flow_attenuation) - .add_flow_sample(2 * lift_scale, 60 * flow_attenuation) - .add_flow_sample(3 * lift_scale, 90 * flow_attenuation) - .add_flow_sample(4 * lift_scale, 125 * flow_attenuation) - .add_flow_sample(5 * lift_scale, 150 * flow_attenuation) - .add_flow_sample(6 * lift_scale, 175 * flow_attenuation) - .add_flow_sample(7 * lift_scale, 200 * flow_attenuation) - .add_flow_sample(8 * lift_scale, 215 * flow_attenuation) - .add_flow_sample(9 * lift_scale, 230 * flow_attenuation) - .add_flow_sample(10 * lift_scale, 280 * flow_attenuation) - .add_flow_sample(11 * lift_scale, 300 * flow_attenuation) - .add_flow_sample(12 * lift_scale, 345 * flow_attenuation) - - function exhaust_flow(1 * units.mm) - exhaust_flow - .add_flow_sample(0 * lift_scale, 0 * flow_attenuation) - .add_flow_sample(1 * lift_scale, 35 * flow_attenuation) - .add_flow_sample(2 * lift_scale, 55 * flow_attenuation) - .add_flow_sample(3 * lift_scale, 85 * flow_attenuation) - .add_flow_sample(4 * lift_scale, 105 * flow_attenuation) - .add_flow_sample(5 * lift_scale, 120 * flow_attenuation) - .add_flow_sample(6 * lift_scale, 140 * flow_attenuation) - .add_flow_sample(7 * lift_scale, 150 * flow_attenuation) - .add_flow_sample(8 * lift_scale, 155 * flow_attenuation) - .add_flow_sample(9 * lift_scale, 160 * flow_attenuation) - .add_flow_sample(10 * lift_scale, 200 * flow_attenuation) - .add_flow_sample(11 * lift_scale, 210 * flow_attenuation) - .add_flow_sample(12 * lift_scale, 215 * flow_attenuation) - - - cylinder_head head( - chamber_volume: chamber_volume, - intake_runner_volume: 500.0 * units.cc, - intake_runner_cross_section_area: 2 * 12.4087 * units.cm2, - - intake_port_flow: intake_flow, - exhaust_port_flow: exhaust_flow, - intake_camshaft: intake_camshaft, - exhaust_camshaft: exhaust_camshaft, - flip_display: flip_display - ) -} - -public node Lamborghini_6_5 { - alias output __out: engine; - - //Aventador SVJ - V12 6.5 L (L539) - //engine file made by [dacxl] - - engine engine( - name: "Lamborghini 6.5 V12 LP770-4 (Aventador SVJ) V2", - starter_torque: 200 * units.Nm, - starter_speed: 1500 * units.rpm, - redline: 8500 * units.rpm, - fuel: fuel( - max_turbulence_effect: 4.0 - ) - ) - - wires wires() - - crankshaft c0( - throw: 76.4 * units.mm / 2, - flywheel_mass: 12 * 2 * units.Nm, - mass: 8 * units.kg, - friction_torque: 13.5 * units.Nm, - moment_of_inertia: 0.22986844776863666 * 2, - position_x: 0.0, - position_y: 0.0, - tdc: 60 * units.deg - ) - - //1–12–4–9–2–11–6–7–3–10–5–8 - // 6 7 - // 5 8 - // 4 9 - // 3 10 - // 2 11 - // 1 12 - - rod_journal rj0(angle: 1 * cycle60) - rod_journal rj2(angle: 5 * cycle60) - rod_journal rj4(angle: 3 * cycle60) - rod_journal rj6(angle: 3 * cycle60) - rod_journal rj8(angle: 5 * cycle60) - rod_journal rj10(angle: 1 * cycle60) - - c0 - .add_rod_journal(rj0) - .add_rod_journal(rj2) - .add_rod_journal(rj4) - .add_rod_journal(rj6) - .add_rod_journal(rj8) - .add_rod_journal(rj10) - - piston_parameters piston_params( - mass: 350 * units.g, - compression_height: 39.8 * units.mm, - wrist_pin_position: 0.0, - displacement: 0.0 - ) - - connecting_rod_parameters cr_params( - mass: 200.0 * units.g, - moment_of_inertia: 0.0015884918028487504, - center_of_mass: 0.0, - length: 135.0 * units.mm - ) - - cylinder_bank_parameters bank_params( - bore: 95 * units.mm, - deck_height: (135.0 + 31.82) * units.mm + 95.8 * units.mm / 2.0 - ) - - performer_rpm_intake intake( - carburetor_cfm: 9000.0, - idle_flow_rate_cfm: 0.3, - idle_throttle_plate_position: 0.99927, - throttle_gamma: 2.0 - ) - - exhaust_system_parameters es_params( - outlet_flow_rate: k_carb(3000.0), - primary_tube_length: 8.0 * units.inch, - primary_flow_rate: k_carb(300.0), - velocity_decay: 1.0, - volume: 150.0 * units.L - ) - - exhaust_system_parameters es_params2( - outlet_flow_rate: k_carb(3000.0), - primary_tube_length: 8.0 * units.inch, - primary_flow_rate: k_carb(300.0), - velocity_decay: 1.0, - volume: 150.0 * units.L - ) - - exhaust_system_parameters es_params3( - outlet_flow_rate: k_carb(3000.0), - primary_tube_length: 5.0 * units.inch, - primary_flow_rate: k_carb(300.0), - velocity_decay: 1.0, - volume: 150.0 * units.L - ) - - exhaust_system_parameters es_params4( - outlet_flow_rate: k_carb(3000.0), - primary_tube_length: 5.0 * units.inch, - primary_flow_rate: k_carb(300.0), - velocity_decay: 1.0, - volume: 150.0 * units.L - ) - - exhaust_system exhaust0(es_params, audio_volume: 1.0, impulse_response: ir_lib.default_0) - exhaust_system exhaust1(es_params2, audio_volume: 1.0, impulse_response: ir_lib.default_0) - exhaust_system exhaust2(es_params3, audio_volume: 0.6, impulse_response: ir_lib.default_0) - exhaust_system exhaust3(es_params4, audio_volume: 0.6, impulse_response: ir_lib.default_0) - - // 6 7 - // 5 8 - // 4 9 - // 3 10 - // 2 11 - // 1 12 - - cylinder_bank b0(bank_params, angle: 30 * units.deg) - b0 - .add_cylinder( - piston: piston(piston_params, blowby: k_28inH2O(0.1)), - connecting_rod: connecting_rod(cr_params), - rod_journal: rj0, - intake: intake, - exhaust_system: exhaust2, - ignition_wire: wires.wire1 - ) - .add_cylinder( - piston: piston(piston_params, blowby: k_28inH2O(0.1)), - connecting_rod: connecting_rod(cr_params), - rod_journal: rj2, - intake: intake, - exhaust_system: exhaust2, - ignition_wire: wires.wire2 - ) - .add_cylinder( - piston: piston(piston_params, blowby: k_28inH2O(0.1)), - connecting_rod: connecting_rod(cr_params), - rod_journal: rj4, - intake: intake, - exhaust_system: exhaust2, - ignition_wire: wires.wire3 - ) - .add_cylinder( - piston: piston(piston_params, blowby: k_28inH2O(0.1)), - connecting_rod: connecting_rod(cr_params), - rod_journal: rj6, - intake: intake, - exhaust_system: exhaust0, - ignition_wire: wires.wire4 - ) - .add_cylinder( - piston: piston(piston_params, blowby: k_28inH2O(0.1)), - connecting_rod: connecting_rod(cr_params), - rod_journal: rj8, - intake: intake, - exhaust_system: exhaust0, - ignition_wire: wires.wire5 - ) - .add_cylinder( - piston: piston(piston_params, blowby: k_28inH2O(0.1)), - connecting_rod: connecting_rod(cr_params), - rod_journal: rj10, - intake: intake, - exhaust_system: exhaust0, - ignition_wire: wires.wire6 - ) - - cylinder_bank b1(bank_params, angle: -30.0 * units.deg) - b1 - .add_cylinder( - piston: piston(piston_params, blowby: k_28inH2O(0.1)), - connecting_rod: connecting_rod(cr_params), - rod_journal: rj0, - intake: intake, - exhaust_system: exhaust3, - ignition_wire: wires.wire12 - ) - .add_cylinder( - piston: piston(piston_params, blowby: k_28inH2O(0.1)), - connecting_rod: connecting_rod(cr_params), - rod_journal: rj2, - intake: intake, - exhaust_system: exhaust3, - ignition_wire: wires.wire11 - ) - .add_cylinder( - piston: piston(piston_params, blowby: k_28inH2O(0.1)), - connecting_rod: connecting_rod(cr_params), - rod_journal: rj4, - intake: intake, - exhaust_system: exhaust3, - ignition_wire: wires.wire10 - ) - .add_cylinder( - piston: piston(piston_params, blowby: k_28inH2O(0.1)), - connecting_rod: connecting_rod(cr_params), - rod_journal: rj6, - intake: intake, - exhaust_system: exhaust1, - ignition_wire: wires.wire9 - ) - .add_cylinder( - piston: piston(piston_params, blowby: k_28inH2O(0.1)), - connecting_rod: connecting_rod(cr_params), - rod_journal: rj8, - intake: intake, - exhaust_system: exhaust1, - ignition_wire: wires.wire8 - ) - .add_cylinder( - piston: piston(piston_params, blowby: k_28inH2O(0.1)), - connecting_rod: connecting_rod(cr_params), - rod_journal: rj10, - intake: intake, - exhaust_system: exhaust1, - ignition_wire: wires.wire7 - ) - - engine - .add_cylinder_bank(b1) - .add_cylinder_bank(b0) - - engine.add_crankshaft(c0) - - harmonic_cam_lobe lobe( - duration_at_50_thou: 256 * units.deg, - gamma: 1.1, - lift: 11.0 * units.mm, - steps: 100 - ) - - lamborghini_6_5_camshaft_builder camshaft( - lobe_profile: lamborghini_6_5_lobe_profile_int(), - ex_lobe_profile: lamborghini_6_5_lobe_profile_exh() - ) - - b0.set_cylinder_head ( - lamborghini_6_5_head( - intake_camshaft: camshaft.intake_cam_0, - exhaust_camshaft: camshaft.exhaust_cam_0 - ) - ) - b1.set_cylinder_head ( - lamborghini_6_5_head( - intake_camshaft: camshaft.intake_cam_1, - exhaust_camshaft: camshaft.exhaust_cam_1 - ) - ) - function timing_curve(1000 * units.rpm) - timing_curve - .add_sample(0000 * units.rpm, 10 * units.deg) - .add_sample(1000 * units.rpm, 30 * units.deg) - .add_sample(2000 * units.rpm, 65 * units.deg) - .add_sample(3000 * units.rpm, 65 * units.deg) - .add_sample(4000 * units.rpm, 70 * units.deg) - .add_sample(5000 * units.rpm, 70 * units.deg) - .add_sample(6000 * units.rpm, 75 * units.deg) - .add_sample(7000 * units.rpm, 80 * units.deg) - .add_sample(8000 * units.rpm, 85 * units.deg) - .add_sample(8500 * units.rpm, 90 * units.deg) - - engine.add_ignition_module( - lamborghini_6_5_distributor( - wires: wires, - timing_curve: timing_curve, - rev_limit: 8500 * units.rpm, - limiter_duration: 0.045 - )) -} \ No newline at end of file diff --git a/es/Lamborghini_6_5_SVJ_V2.mr b/es/Lamborghini_6_5_SVJ_V2.mr deleted file mode 100644 index bad887a..0000000 --- a/es/Lamborghini_6_5_SVJ_V2.mr +++ /dev/null @@ -1,561 +0,0 @@ -import "engine_sim.mr" - -units units() -constants constants() -impulse_response_library ir_lib() - -//Aventador SVJ - V12 6.5 L (L539) V2 - //engine file made by [dacxl] - //vehicle and transmission settings available, v12_vehicle & v12_transmission - -label cycle60(60 * units.deg) - -private node lamborghini_6_5_distributor { - input wires; - input timing_curve; - input rev_limit: 8500 * units.rpm; - input limiter_duration: 0.045; - alias output __out: - ignition_module(timing_curve: timing_curve, rev_limit: rev_limit, limiter_duration: limiter_duration) - .connect_wire(wires.wire1, 0) - .connect_wire(wires.wire12, 1.0 * cycle60) - .connect_wire(wires.wire4, 2.0 * cycle60) - .connect_wire(wires.wire9, 3.0 * cycle60) - .connect_wire(wires.wire2, 4.0 * cycle60) - .connect_wire(wires.wire11, 5.0 * cycle60) - .connect_wire(wires.wire6, 6.0 * cycle60) - .connect_wire(wires.wire7, 7.0 * cycle60) - .connect_wire(wires.wire3, 8.0 * cycle60) - .connect_wire(wires.wire10, 9.0 * cycle60) - .connect_wire(wires.wire5, 10.0 * cycle60) - .connect_wire(wires.wire8, 11.0 * cycle60) - ; -} - -//1–12–4–9–2–11–6–7–3–10–5–8 - // 6 7 - // 5 8 - // 4 9 - // 3 10 - // 2 11 - // 1 12 - -private node wires { - output wire1: ignition_wire(); - output wire2: ignition_wire(); - output wire3: ignition_wire(); - output wire4: ignition_wire(); - output wire5: ignition_wire(); - output wire6: ignition_wire(); - output wire7: ignition_wire(); - output wire8: ignition_wire(); - output wire9: ignition_wire(); - output wire10: ignition_wire(); - output wire11: ignition_wire(); - output wire12: ignition_wire(); -} - -private node add_sym_sample { - input angle; - input lift; - input this; - alias output __out: this; - - this.add_sample(angle * units.deg, lift * units.thou) - this.add_sample(-angle * units.deg, lift * units.thou) -} - -private node lamborghini_6_5_lobe_profile_int { - alias output __out: - harmonic_cam_lobe( - duration_at_50_thou: 200 * units.deg, - gamma: 1.5, - lift: 18.8 * units.mm, - steps: 100 - ); -} - -private node lamborghini_6_5_lobe_profile_exh { - alias output __out: - harmonic_cam_lobe( - duration_at_50_thou: 200 * units.deg, - gamma: 1.5, - lift: 18.8 * units.mm, - steps: 100 - ); -} - -private node lamborghini_6_5_camshaft_builder { - input lobe_profile: lamborghini_6_5_lobe_profile_int(); - input ex_lobe_profile: lamborghini_6_5_lobe_profile_exh(); - input intake_lobe_profile: lobe_profile; - input exhaust_lobe_profile: ex_lobe_profile; - input lobe_separation: 110.0 * units.deg; - input intake_lobe_center: lobe_separation; - input exhaust_lobe_center: lobe_separation; - input advance: -16.5* units.deg; - input base_radius: 0.75 * units.inch; - - output intake_cam_0: _intake_cam_0; - output intake_cam_1: _intake_cam_1; - output exhaust_cam_0: _exhaust_cam_0; - output exhaust_cam_1: _exhaust_cam_1; - - camshaft_parameters params( - advance: advance, - base_radius: base_radius - ) - - camshaft _intake_cam_0(params, lobe_profile: intake_lobe_profile) - camshaft _intake_cam_1(params, lobe_profile: intake_lobe_profile) - camshaft _exhaust_cam_0(params, lobe_profile: exhaust_lobe_profile) - camshaft _exhaust_cam_1(params, lobe_profile: exhaust_lobe_profile) - - label rot360(360 * units.deg) - label cyl(720/12 * units.deg) - - //1–12–4–9–2–11–6–7–3–10–5–8 - // 6 7 - // 5 8 - // 4 9 - // 3 10 - // 2 11 - // 1 12 -//1-5-3-3-5-1 - -label offset(0.045) - _exhaust_cam_0 - .add_lobe(rot360 - exhaust_lobe_center + 0 * cycle60 + 1* offset) //1 - .add_lobe(rot360 - exhaust_lobe_center + 4 * cycle60 + 3* offset) //2 - .add_lobe(rot360 - exhaust_lobe_center + 8 * cycle60 + 2* offset) //3 - .add_lobe(rot360 - exhaust_lobe_center + 2 * cycle60 - 2* offset) //4 - .add_lobe(rot360 - exhaust_lobe_center + 10 * cycle60 - 3* offset) //5 - .add_lobe(rot360 - exhaust_lobe_center + 6 * cycle60 - 1* offset) //6 - - _exhaust_cam_1 - .add_lobe(rot360 - exhaust_lobe_center + 1 * cycle60 + 1* offset) //12 - .add_lobe(rot360 - exhaust_lobe_center + 5 * cycle60 + 3* offset) //11 - .add_lobe(rot360 - exhaust_lobe_center + 9 * cycle60 + 2* offset) //10 - .add_lobe(rot360 - exhaust_lobe_center + 3 * cycle60 - 2* offset) //9 - .add_lobe(rot360 - exhaust_lobe_center + 11 * cycle60 - 3* offset) //8 - .add_lobe(rot360 - exhaust_lobe_center + 7 * cycle60 - 1* offset) //7 - - - _intake_cam_0 - .add_lobe(rot360 + intake_lobe_center + 0 * cycle60) //1 - .add_lobe(rot360 + intake_lobe_center + 4 * cycle60) //2 - .add_lobe(rot360 + intake_lobe_center + 8 * cycle60) //3 - .add_lobe(rot360 + intake_lobe_center + 2 * cycle60) //4 - .add_lobe(rot360 + intake_lobe_center + 10 * cycle60) //5 - .add_lobe(rot360 + intake_lobe_center + 6 * cycle60) //6 - - _intake_cam_1 - .add_lobe(rot360 + intake_lobe_center + 1 * cycle60) //12 - .add_lobe(rot360 + intake_lobe_center + 5 * cycle60) //11 - .add_lobe(rot360 + intake_lobe_center + 9 * cycle60) //10 - .add_lobe(rot360 + intake_lobe_center + 3 * cycle60) //9 - .add_lobe(rot360 + intake_lobe_center + 11 * cycle60) //8 - .add_lobe(rot360 + intake_lobe_center + 7 * cycle60) //7 - -} - -private node add_flow_sample { - input lift; - input flow; - input this; - alias output __out: this; - - this.add_sample(lift * units.mm, k_28inH2O(flow)) -} - -public node lamborghini_6_5_head { - input intake_camshaft; - input exhaust_camshaft; - input chamber_volume: 41.0 * units.cc; - input flip_display: false; - - input flow_attenuation: 1.00; - input lift_scale: 1.0; - alias output __out: head; - - function intake_flow(1 * units.mm) - intake_flow - .add_flow_sample(0 * lift_scale, 0 * flow_attenuation) - .add_flow_sample(1 * lift_scale, 35 * flow_attenuation) - .add_flow_sample(2 * lift_scale, 60 * flow_attenuation) - .add_flow_sample(3 * lift_scale, 90 * flow_attenuation) - .add_flow_sample(4 * lift_scale, 125 * flow_attenuation) - .add_flow_sample(5 * lift_scale, 150 * flow_attenuation) - .add_flow_sample(6 * lift_scale, 175 * flow_attenuation) - .add_flow_sample(7 * lift_scale, 200 * flow_attenuation) - .add_flow_sample(8 * lift_scale, 215 * flow_attenuation) - .add_flow_sample(9 * lift_scale, 230 * flow_attenuation) - .add_flow_sample(10 * lift_scale, 280 * flow_attenuation) - .add_flow_sample(11 * lift_scale, 300 * flow_attenuation) - .add_flow_sample(12 * lift_scale, 345 * flow_attenuation) - - function exhaust_flow(1 * units.mm) - exhaust_flow - .add_flow_sample(0 * lift_scale, 0 * flow_attenuation) - .add_flow_sample(1 * lift_scale, 35 * flow_attenuation) - .add_flow_sample(2 * lift_scale, 55 * flow_attenuation) - .add_flow_sample(3 * lift_scale, 85 * flow_attenuation) - .add_flow_sample(4 * lift_scale, 105 * flow_attenuation) - .add_flow_sample(5 * lift_scale, 120 * flow_attenuation) - .add_flow_sample(6 * lift_scale, 140 * flow_attenuation) - .add_flow_sample(7 * lift_scale, 150 * flow_attenuation) - .add_flow_sample(8 * lift_scale, 155 * flow_attenuation) - .add_flow_sample(9 * lift_scale, 160 * flow_attenuation) - .add_flow_sample(10 * lift_scale, 200 * flow_attenuation) - .add_flow_sample(11 * lift_scale, 210 * flow_attenuation) - .add_flow_sample(12 * lift_scale, 215 * flow_attenuation) - - - cylinder_head head( - chamber_volume: chamber_volume, - intake_runner_volume: 300.0 * units.cc, - intake_runner_cross_section_area: 2 * 12.4087 * units.cm2, - - intake_port_flow: intake_flow, - exhaust_port_flow: exhaust_flow, - intake_camshaft: intake_camshaft, - exhaust_camshaft: exhaust_camshaft, - flip_display: flip_display - ) -} - -public node Lamborghini_6_5 { - alias output __out: engine; - - //Aventador SVJ - V12 6.5 L (L539) - //engine file made by [dacxl] - - engine engine( - name: "Lamborghini 6.5 V12 LP770-4 (Aventador SVJ) V2", - starter_torque: 200 * units.Nm, - starter_speed: 700 * units.rpm, - redline: 8500 * units.rpm, - fuel: fuel( - max_turbulence_effect: 1.0, - burning_efficiency_randomness: 0.0, - max_burning_efficiency: 1.0 - ), - simulation_frequency: 6350 - ) - - wires wires() - - crankshaft c0( - throw: 76.4 * units.mm / 2, - flywheel_mass: 7 * 2 * units.Nm, - mass: 8 * units.kg, - friction_torque: 13.5 * units.Nm, - moment_of_inertia: 0.22986844776863666 * 2, - position_x: 0.0, - position_y: 0.0, - tdc: 60 * units.deg - ) - - //1–12–4–9–2–11–6–7–3–10–5–8 - // 6 7 - // 5 8 - // 4 9 - // 3 10 - // 2 11 - // 1 12 - - rod_journal rj0(angle: 1 * cycle60) - rod_journal rj2(angle: 5 * cycle60) - rod_journal rj4(angle: 3 * cycle60) - rod_journal rj6(angle: 3 * cycle60) - rod_journal rj8(angle: 5 * cycle60) - rod_journal rj10(angle: 1 * cycle60) - - c0 - .add_rod_journal(rj0) - .add_rod_journal(rj2) - .add_rod_journal(rj4) - .add_rod_journal(rj6) - .add_rod_journal(rj8) - .add_rod_journal(rj10) - - piston_parameters piston_params( - mass: 350 * units.g, - compression_height: 39.8 * units.mm, - wrist_pin_position: 0.0, - displacement: 0.0 - ) - - connecting_rod_parameters cr_params( - mass: 200.0 * units.g, - moment_of_inertia: 0.0015884918028487504, - center_of_mass: 0.0, - length: 135.0 * units.mm - ) - - cylinder_bank_parameters bank_params( - bore: 95 * units.mm, - deck_height: (135.0 + 31.82) * units.mm + 95.8 * units.mm / 2.0 - ) - - intake intake( - plenum_volume: 6.0 * units.L, - plenum_cross_section_area: 20.0 * units.cm2, - intake_flow_rate: k_carb(500.0), - idle_flow_rate: k_carb(0.0), - idle_throttle_plate_position: 0.9942, - throttle_gamma: 1.0 - ) - - exhaust_system_parameters es_params( - outlet_flow_rate: k_carb(1000.0), - primary_tube_length: 11.0 * units.inch, - primary_flow_rate: k_carb(300.0), - velocity_decay: 1.0, - volume: 25.0 * units.L - ) - - exhaust_system_parameters es_params2( - outlet_flow_rate: k_carb(1000.0), - primary_tube_length: 11.0 * units.inch, - primary_flow_rate: k_carb(300.0), - velocity_decay: 1.0, - volume: 25.0 * units.L - ) - - exhaust_system_parameters es_params3( - outlet_flow_rate: k_carb(1000.0), - primary_tube_length: 15.0 * units.inch, - primary_flow_rate: k_carb(300.0), - velocity_decay: 1.0, - volume: 25.0 * units.L - ) - - exhaust_system_parameters es_params4( - outlet_flow_rate: k_carb(1000.0), - primary_tube_length: 15.0 * units.inch, - primary_flow_rate: k_carb(300.0), - velocity_decay: 1.0, - volume: 25.0 * units.L - ) - - exhaust_system exhaust0(es_params, audio_volume: 1.0, impulse_response: ir_lib.default_0) - exhaust_system exhaust1(es_params2, audio_volume: 1.0, impulse_response: ir_lib.default_0) - exhaust_system exhaust2(es_params3, audio_volume: 0.6, impulse_response: ir_lib.default_0) - exhaust_system exhaust3(es_params4, audio_volume: 0.6, impulse_response: ir_lib.default_0) - - // 6 7 - // 5 8 - // 4 9 - // 3 10 - // 2 11 - // 1 12 - - cylinder_bank b0(bank_params, angle: 30 * units.deg) - b0 - .add_cylinder( - piston: piston(piston_params, blowby: k_28inH2O(0.1)), - connecting_rod: connecting_rod(cr_params), - rod_journal: rj0, - intake: intake, - exhaust_system: exhaust0, - ignition_wire: wires.wire1, - primary_length: 20 * units.mm - ) - .add_cylinder( - piston: piston(piston_params, blowby: k_28inH2O(0.1)), - connecting_rod: connecting_rod(cr_params), - rod_journal: rj2, - intake: intake, - exhaust_system: exhaust0, - ignition_wire: wires.wire2, - primary_length: 25 * units.mm - ) - .add_cylinder( - piston: piston(piston_params, blowby: k_28inH2O(0.1)), - connecting_rod: connecting_rod(cr_params), - rod_journal: rj4, - intake: intake, - exhaust_system: exhaust0, - ignition_wire: wires.wire3, - primary_length: 30 * units.mm - ) - .add_cylinder( - piston: piston(piston_params, blowby: k_28inH2O(0.1)), - connecting_rod: connecting_rod(cr_params), - rod_journal: rj6, - intake: intake, - exhaust_system: exhaust1, - ignition_wire: wires.wire4, - primary_length: 35 * units.mm - ) - .add_cylinder( - piston: piston(piston_params, blowby: k_28inH2O(0.1)), - connecting_rod: connecting_rod(cr_params), - rod_journal: rj8, - intake: intake, - exhaust_system: exhaust1, - ignition_wire: wires.wire5, - primary_length: 40 * units.mm - ) - .add_cylinder( - piston: piston(piston_params, blowby: k_28inH2O(0.1)), - connecting_rod: connecting_rod(cr_params), - rod_journal: rj10, - intake: intake, - exhaust_system: exhaust1, - ignition_wire: wires.wire6, - primary_length: 45 * units.mm - ) - - cylinder_bank b1(bank_params, angle: -30.0 * units.deg) - b1 - .add_cylinder( - piston: piston(piston_params, blowby: k_28inH2O(0.1)), - connecting_rod: connecting_rod(cr_params), - rod_journal: rj0, - intake: intake, - exhaust_system: exhaust2, - ignition_wire: wires.wire12, - primary_length: 20 * units.mm - ) - .add_cylinder( - piston: piston(piston_params, blowby: k_28inH2O(0.1)), - connecting_rod: connecting_rod(cr_params), - rod_journal: rj2, - intake: intake, - exhaust_system: exhaust2, - ignition_wire: wires.wire11, - primary_length: 25 * units.mm - ) - .add_cylinder( - piston: piston(piston_params, blowby: k_28inH2O(0.1)), - connecting_rod: connecting_rod(cr_params), - rod_journal: rj4, - intake: intake, - exhaust_system: exhaust2, - ignition_wire: wires.wire10, - primary_length: 30 * units.mm - ) - .add_cylinder( - piston: piston(piston_params, blowby: k_28inH2O(0.1)), - connecting_rod: connecting_rod(cr_params), - rod_journal: rj6, - intake: intake, - exhaust_system: exhaust3, - ignition_wire: wires.wire9, - primary_length: 35 * units.mm - ) - .add_cylinder( - piston: piston(piston_params, blowby: k_28inH2O(0.1)), - connecting_rod: connecting_rod(cr_params), - rod_journal: rj8, - intake: intake, - exhaust_system: exhaust3, - ignition_wire: wires.wire8, - primary_length: 40 * units.mm - ) - .add_cylinder( - piston: piston(piston_params, blowby: k_28inH2O(0.1)), - connecting_rod: connecting_rod(cr_params), - rod_journal: rj10, - intake: intake, - exhaust_system: exhaust3, - ignition_wire: wires.wire7, - primary_length: 45 * units.mm - ) - - engine - .add_cylinder_bank(b1) - .add_cylinder_bank(b0) - - engine.add_crankshaft(c0) - - harmonic_cam_lobe lobe( - duration_at_50_thou: 196 * units.deg, - gamma: 1.0, - lift: 11.5 * units.mm, - steps: 100 - ) - - lamborghini_6_5_camshaft_builder camshaft( - lobe_profile: lamborghini_6_5_lobe_profile_int(), - ex_lobe_profile: lamborghini_6_5_lobe_profile_exh() - ) - - b0.set_cylinder_head ( - lamborghini_6_5_head( - intake_camshaft: camshaft.intake_cam_0, - exhaust_camshaft: camshaft.exhaust_cam_0, - flip_display: true - ) - ) - b1.set_cylinder_head ( - lamborghini_6_5_head( - intake_camshaft: camshaft.intake_cam_1, - exhaust_camshaft: camshaft.exhaust_cam_1 - ) - ) - function timing_curve(1000 * units.rpm) - timing_curve - .add_sample(0000 * units.rpm, 10 * units.deg) - .add_sample(1000 * units.rpm, 30 * units.deg) - .add_sample(2000 * units.rpm, 65 * units.deg) - .add_sample(3000 * units.rpm, 65 * units.deg) - .add_sample(4000 * units.rpm, 70 * units.deg) - .add_sample(5000 * units.rpm, 70 * units.deg) - .add_sample(6000 * units.rpm, 75 * units.deg) - .add_sample(7000 * units.rpm, 80 * units.deg) - .add_sample(8000 * units.rpm, 85 * units.deg) - .add_sample(8500 * units.rpm, 90 * units.deg) - - engine.add_ignition_module( - lamborghini_6_5_distributor( - wires: wires, - timing_curve: timing_curve, - rev_limit: 8500 * units.rpm, - limiter_duration: 0.045 - )) -} - -private node SVJ_vehicle { - input mass: (1525 + 80) * units.kg; //dry weight + driver weight (not with fluids to save weight and achieve more accurate acceleration) - input diff_ratio: 2.867; - input tire_radius: (23.23/2) * units.inch; - input drag_coefficient: 0.33; - input cross_sectional_area: 1.91 * units.m2; - - alias output __out: vehicle; - - vehicle vehicle( - mass: mass, - diff_ratio: diff_ratio, - tire_radius: tire_radius, - drag_coefficient: drag_coefficient, - cross_sectional_area: cross_sectional_area, - rolling_resistance: 400 * units.N - ) -} - -private node SVJ_transmission { - input max_clutch_torque: 1200 * units.lb_ft; - alias output __out: - transmission(max_clutch_torque) - .add_gear(3.909) - .add_gear(2.438) - .add_gear(1.810) - .add_gear(1.458) - .add_gear(1.185) - .add_gear(0.967) - .add_gear(0.844); -} - -public node main { - run( - engine: Lamborghini_6_5(), - vehicle: SVJ_vehicle(), - transmission: SVJ_transmission() - ) - } - -main() \ No newline at end of file diff --git a/es/actions.mr b/es/actions.mr deleted file mode 100644 index f975aab..0000000 --- a/es/actions.mr +++ /dev/null @@ -1,238 +0,0 @@ -module { - @name: "Actions" - @author: "ATG (Ange Yaghi)" - @copyright: "Copyright 2022, Ange Yaghi" -} - -private import "../types/atomic_types.mr" -private import "../types/conversions.mr" -private import "../types/operations.mr" -private import "../constants/constants.mr" -private import "../constants/units.mr" -private import "../objects/objects.mr" - -constants constants() -units units() - -public node set_engine => __engine_sim__set_engine { - input engine [engine]; -} - -private node _add_rod_journal => __engine_sim__add_rod_journal { - input rod_journal [rod_journal]; - input crankshaft [crankshaft]; -} - -public node add_rod_journal { - input rod_journal; - input this; - alias output out: this; - - _add_rod_journal(rod_journal, this) -} - -private node _add_slave_journal => __engine_sim__add_slave_journal { - input rod_journal [rod_journal]; - input rod [connecting_rod]; -} - -public node add_slave_journal { - input rod_journal; - input this; - alias output out: this; - - _add_slave_journal(rod_journal, this) -} - -public node _add_crankshaft => __engine_sim__add_crankshaft { - input crankshaft [crankshaft]; - input engine [engine]; -} - -public node add_crankshaft { - input crankshaft; - input this; - alias output out: this; - - _add_crankshaft(crankshaft, engine: this) -} - -private node _add_cylinder_bank => __engine_sim__add_cylinder_bank { - input engine [engine]; - input cylinder_bank [cylinder_bank]; -} - -public node add_cylinder_bank { - input cylinder_bank; - input this; - alias output __out: this; - - _add_cylinder_bank(engine: this, cylinder_bank) -} - -private node _add_cylinder => __engine_sim__add_cylinder { - input piston [piston]; - input connecting_rod [connecting_rod]; - input rod_journal [rod_journal]; - input exhaust_system [exhaust_system]; - input intake [intake]; - input cylinder_bank [cylinder_bank]; - input ignition_wire [ignition_wire]; - input sound_attenuation [float]; - input primary_length [float]; -} - -public node add_cylinder { - input intake; - input exhaust_system; - input piston; - input connecting_rod; - input rod_journal; - input ignition_wire; - input sound_attenuation: 1.0; - input primary_length: 0.0; - input this; - alias output __out: this; - - _add_cylinder( - piston: piston, - connecting_rod: connecting_rod, - rod_journal: rod_journal, - exhaust_system: exhaust_system, - intake: intake, - ignition_wire: ignition_wire, - cylinder_bank: this, - sound_attenuation: sound_attenuation, - primary_length: primary_length - ) -} - -private node _add_sample => __engine_sim__add_sample { - input x [float]; - input y [float]; - input function [function]; -} - -public node add_sample { - input x; - input y; - input this; - alias output __out: this; - - _add_sample(x: x, y: y, function: this) -} - -private node _add_lobe => __engine_sim__add_lobe { - input centerline [float]; - input camshaft [camshaft]; -} - -public node add_lobe { - input centerline; - input this; - alias output __out: this; - - _add_lobe(centerline: centerline, camshaft: this) -} - -private node _set_cylinder_head => __engine_sim__set_cylinder_head { - input head [cylinder_head]; - input bank [cylinder_bank]; -} - -public node set_cylinder_head { - input head; - input this; - - _set_cylinder_head(head: head, bank: this) -} - -public node k_28inH2O => __engine_sim__k_28inH2O { - input flow [float]: 1.0; - alias output __out [float]; -} - -public node k_carb => __engine_sim__k_carb { - input flow [float]: 1.0; - alias output __out [float]; -} - -public node circle_area { - input radius; - alias output __out: - constants.pi * radius * radius; -} - -public node _connect_wire => __engine_sim__connect_ignition_wire { - input wire [ignition_wire]; - input ignition_module [ignition_module]; - input angle [float]; -} - -public node connect_wire { - input wire; - input angle; - input this; - alias output __out: this; - - _connect_wire(wire: wire, angle: angle, ignition_module: this) -} - -private node _add_ignition_module => __engine_sim__add_ignition_module { - input ignition_module [ignition_module]; - input engine [engine]; -} - -public node add_ignition_module { - input ignition_module; - input this; - alias output __out: this; - - _add_ignition_module(ignition_module: ignition_module, engine: this) -} - -public node _generate_harmonic_cam_lobe => __engine_sim__generate_harmonic_cam_lobe { - input duration_at_50_thou [float]; - input gamma [float]; - input lift [float]; - input steps [int]; - input function [function]; -} - -public node harmonic_cam_lobe { - input duration_at_50_thou: 0.0; - input gamma: 1.0; - input lift: 300 * units.thou; - input steps: 100; - alias output __out: generated_function; - - function generated_function() - _generate_harmonic_cam_lobe( - duration_at_50_thou: duration_at_50_thou, - gamma: gamma, - lift: lift, - steps: steps, - function: generated_function - ) -} - -public node set_vehicle => __engine_sim__set_vehicle { - input vehicle [vehicle]; -} - -private node _add_gear => __engine_sim__add_gear { - input ratio [float]; - input transmission [transmission]; -} - -public node add_gear { - input ratio; - input this; - alias output __out: this; - - _add_gear(ratio, this) -} - -public node set_transmission => __engine_sim__set_transmission { - input transmission [transmission]; -} diff --git a/es/actions/actions.mr b/es/actions/actions.mr deleted file mode 100644 index f975aab..0000000 --- a/es/actions/actions.mr +++ /dev/null @@ -1,238 +0,0 @@ -module { - @name: "Actions" - @author: "ATG (Ange Yaghi)" - @copyright: "Copyright 2022, Ange Yaghi" -} - -private import "../types/atomic_types.mr" -private import "../types/conversions.mr" -private import "../types/operations.mr" -private import "../constants/constants.mr" -private import "../constants/units.mr" -private import "../objects/objects.mr" - -constants constants() -units units() - -public node set_engine => __engine_sim__set_engine { - input engine [engine]; -} - -private node _add_rod_journal => __engine_sim__add_rod_journal { - input rod_journal [rod_journal]; - input crankshaft [crankshaft]; -} - -public node add_rod_journal { - input rod_journal; - input this; - alias output out: this; - - _add_rod_journal(rod_journal, this) -} - -private node _add_slave_journal => __engine_sim__add_slave_journal { - input rod_journal [rod_journal]; - input rod [connecting_rod]; -} - -public node add_slave_journal { - input rod_journal; - input this; - alias output out: this; - - _add_slave_journal(rod_journal, this) -} - -public node _add_crankshaft => __engine_sim__add_crankshaft { - input crankshaft [crankshaft]; - input engine [engine]; -} - -public node add_crankshaft { - input crankshaft; - input this; - alias output out: this; - - _add_crankshaft(crankshaft, engine: this) -} - -private node _add_cylinder_bank => __engine_sim__add_cylinder_bank { - input engine [engine]; - input cylinder_bank [cylinder_bank]; -} - -public node add_cylinder_bank { - input cylinder_bank; - input this; - alias output __out: this; - - _add_cylinder_bank(engine: this, cylinder_bank) -} - -private node _add_cylinder => __engine_sim__add_cylinder { - input piston [piston]; - input connecting_rod [connecting_rod]; - input rod_journal [rod_journal]; - input exhaust_system [exhaust_system]; - input intake [intake]; - input cylinder_bank [cylinder_bank]; - input ignition_wire [ignition_wire]; - input sound_attenuation [float]; - input primary_length [float]; -} - -public node add_cylinder { - input intake; - input exhaust_system; - input piston; - input connecting_rod; - input rod_journal; - input ignition_wire; - input sound_attenuation: 1.0; - input primary_length: 0.0; - input this; - alias output __out: this; - - _add_cylinder( - piston: piston, - connecting_rod: connecting_rod, - rod_journal: rod_journal, - exhaust_system: exhaust_system, - intake: intake, - ignition_wire: ignition_wire, - cylinder_bank: this, - sound_attenuation: sound_attenuation, - primary_length: primary_length - ) -} - -private node _add_sample => __engine_sim__add_sample { - input x [float]; - input y [float]; - input function [function]; -} - -public node add_sample { - input x; - input y; - input this; - alias output __out: this; - - _add_sample(x: x, y: y, function: this) -} - -private node _add_lobe => __engine_sim__add_lobe { - input centerline [float]; - input camshaft [camshaft]; -} - -public node add_lobe { - input centerline; - input this; - alias output __out: this; - - _add_lobe(centerline: centerline, camshaft: this) -} - -private node _set_cylinder_head => __engine_sim__set_cylinder_head { - input head [cylinder_head]; - input bank [cylinder_bank]; -} - -public node set_cylinder_head { - input head; - input this; - - _set_cylinder_head(head: head, bank: this) -} - -public node k_28inH2O => __engine_sim__k_28inH2O { - input flow [float]: 1.0; - alias output __out [float]; -} - -public node k_carb => __engine_sim__k_carb { - input flow [float]: 1.0; - alias output __out [float]; -} - -public node circle_area { - input radius; - alias output __out: - constants.pi * radius * radius; -} - -public node _connect_wire => __engine_sim__connect_ignition_wire { - input wire [ignition_wire]; - input ignition_module [ignition_module]; - input angle [float]; -} - -public node connect_wire { - input wire; - input angle; - input this; - alias output __out: this; - - _connect_wire(wire: wire, angle: angle, ignition_module: this) -} - -private node _add_ignition_module => __engine_sim__add_ignition_module { - input ignition_module [ignition_module]; - input engine [engine]; -} - -public node add_ignition_module { - input ignition_module; - input this; - alias output __out: this; - - _add_ignition_module(ignition_module: ignition_module, engine: this) -} - -public node _generate_harmonic_cam_lobe => __engine_sim__generate_harmonic_cam_lobe { - input duration_at_50_thou [float]; - input gamma [float]; - input lift [float]; - input steps [int]; - input function [function]; -} - -public node harmonic_cam_lobe { - input duration_at_50_thou: 0.0; - input gamma: 1.0; - input lift: 300 * units.thou; - input steps: 100; - alias output __out: generated_function; - - function generated_function() - _generate_harmonic_cam_lobe( - duration_at_50_thou: duration_at_50_thou, - gamma: gamma, - lift: lift, - steps: steps, - function: generated_function - ) -} - -public node set_vehicle => __engine_sim__set_vehicle { - input vehicle [vehicle]; -} - -private node _add_gear => __engine_sim__add_gear { - input ratio [float]; - input transmission [transmission]; -} - -public node add_gear { - input ratio; - input this; - alias output __out: this; - - _add_gear(ratio, this) -} - -public node set_transmission => __engine_sim__set_transmission { - input transmission [transmission]; -} diff --git a/es/application_settings.mr b/es/application_settings.mr deleted file mode 100644 index 98ba2f0..0000000 --- a/es/application_settings.mr +++ /dev/null @@ -1,24 +0,0 @@ -private import "engine_sim.mr" - -units units() - -public node set_application_settings => __engine_sim__set_application_settings { - input start_fullscreen [bool]: false; - input power_units [string]: "HP"; - input torque_units [string]: "FTLBS"; - input speed_units [string]: "MPH"; - input pressure_units [string]: "INHG"; - input boost_units [string]: "PSI"; - input color_background [int]: 0x0E1012; - input color_foreground [int]: 0xFFFFFF; - input color_shadow [int]: 0x0E1012; - input color_highlight1 [int]: 0xEF4545; - input color_highlight2 [int]: 0xFFFFFF; - input color_pink [int]: 0xF394BE; - input color_red [int]: 0xEE4445; - input color_orange [int]: 0xF4802A; - input color_yellow [int]: 0xFDBD2E; - input color_blue [int]: 0x77CEE0; - input color_green [int]: 0xBDD869; - -} diff --git a/es/atomic_types.mr b/es/atomic_types.mr deleted file mode 100644 index 760d7ef..0000000 --- a/es/atomic_types.mr +++ /dev/null @@ -1,75 +0,0 @@ -module { - @name: "Atomic Types" - @author: "ATG (Ange Yaghi)" - @copyright: "Copyright 2022, Ange Yaghi" -} - -// ======================================================== -// Channels -// ======================================================== - -@doc: "Floating-point channel type" -private node float_channel => __engine_sim__float { /* void */ } - -@doc: "String channel type" -private node string_channel => __engine_sim__string { /* void */ } - -@doc: "Integer channel type" -private node int_channel => __engine_sim__int { /* void */ } - -@doc: "Bool channel type" -private node bool_channel => __engine_sim__bool { /* void */ } - -// ======================================================== -// Types -// ======================================================== - -@doc: "Float cast type" -@detail: "Converts anything connected to __in to " - "a float type" -public inline node float { - input __in [::float_channel]: 0.0; - alias output __out [::float_channel]: __in; -} - -@doc: "Integer cast type" -@detail: "Converts anything connected to __in to " - "an integer type" -public inline node int { - input __in [::int_channel]: 0; - alias output __out [::int_channel]: __in; -} - -@doc: "Boolean cast type" -@detail: "Converts anything connected to __in to " - "a boolean type" -public inline node bool { - input __in [::bool_channel]: false; - alias output __out [::bool_channel]: __in; -} - -@doc: "String type" -public inline node string { - input s [::string_channel]: ""; - alias output __out [::string_channel]: s; -} - -// ======================================================== -// Literals -// ======================================================== - -public node literal_string => __engine_sim__literal_string { - alias output __out [::string]; -} - -public node literal_float => __engine_sim__literal_float { - alias output __out [::float]; -} - -public node literal_int => __engine_sim__literal_int { - alias output __out [::int]; -} - -public node literal_bool => __engine_sim__literal_bool { - alias output __out [::bool]; -} diff --git a/es/cam_lobes.mr b/es/cam_lobes.mr deleted file mode 100644 index c8c80cf..0000000 --- a/es/cam_lobes.mr +++ /dev/null @@ -1,53 +0,0 @@ -private import "engine_sim.mr" - -units units() - -private node add_sym_sample { - input angle; - input lift; - input this; - alias output __out: this; - - this.add_sample(angle * units.deg, lift * units.thou) - this.add_sample(-angle * units.deg, lift * units.thou) -} - -public node stock_454_intake_lobe_profile { - alias output __out: - harmonic_cam_lobe( - duration_at_50_thou: 194 * units.deg, - gamma: 0.8, - lift: 390 * units.thou, - steps: 100 - ); -} - -public node stock_454_exhaust_lobe_profile { - alias output __out: - harmonic_cam_lobe( - duration_at_50_thou: 202 * units.deg, - gamma: 0.8, - lift: 409 * units.thou, - steps: 100 - ); -} - -public node comp_cams_magnum_11_450_8_lobe_profile { - alias output __out: - harmonic_cam_lobe( - duration_at_50_thou: 232 * units.deg, - gamma: 0.75, - lift: 578 * units.thou, - steps: 100 - ); -} - -public node comp_cams_magnum_11_470_8_lobe_profile { - alias output __out: - harmonic_cam_lobe( - duration_at_50_thou: 252 * units.deg, - gamma: 0.8, - lift: 612 * units.thou, - steps: 100 - ); -} diff --git a/es/camshafts.mr b/es/camshafts.mr deleted file mode 100644 index 0a917ba..0000000 --- a/es/camshafts.mr +++ /dev/null @@ -1,153 +0,0 @@ -private import "cam_lobes.mr" - -private import "engine_sim.mr" - -units units() - -public node chevy_bbc_camshaft_builder { - input lobe_profile: stock_454_intake_lobe_profile(); - input intake_lobe_profile: lobe_profile; - input exhaust_lobe_profile: lobe_profile; - input lobe_separation: 114.0 * units.deg; - input intake_lobe_center: lobe_separation; - input exhaust_lobe_center: lobe_separation; - input advance: 0.0 * units.deg; - input base_radius: 0.75 * units.inch; - - output intake_cam_0: _intake_cam_0; - output intake_cam_1: _intake_cam_1; - output exhaust_cam_0: _exhaust_cam_0; - output exhaust_cam_1: _exhaust_cam_1; - - camshaft_parameters params( - advance: advance, - base_radius: base_radius - ) - - camshaft _intake_cam_0(params, lobe_profile: intake_lobe_profile) - camshaft _intake_cam_1(params, lobe_profile: intake_lobe_profile) - camshaft _exhaust_cam_0(params, lobe_profile: exhaust_lobe_profile) - camshaft _exhaust_cam_1(params, lobe_profile: exhaust_lobe_profile) - - label rot90(90 * units.deg) - label rot360(360 * units.deg) - - _exhaust_cam_0 - .add_lobe(rot360 - exhaust_lobe_center) - .add_lobe(rot360 - exhaust_lobe_center + 3 * rot90) - .add_lobe(rot360 - exhaust_lobe_center + 5 * rot90) - .add_lobe(rot360 - exhaust_lobe_center + 6 * rot90) - - _exhaust_cam_1 - .add_lobe(rot360 - exhaust_lobe_center + 7 * rot90) - .add_lobe(rot360 - exhaust_lobe_center + 2 * rot90) - .add_lobe(rot360 - exhaust_lobe_center + 4 * rot90) - .add_lobe(rot360 - exhaust_lobe_center + 1 * rot90) - - _intake_cam_0 - .add_lobe(rot360 + intake_lobe_center) - .add_lobe(rot360 + intake_lobe_center + 3 * rot90) - .add_lobe(rot360 + intake_lobe_center + 5 * rot90) - .add_lobe(rot360 + intake_lobe_center + 6 * rot90) - - _intake_cam_1 - .add_lobe(rot360 + intake_lobe_center + 7 * rot90) - .add_lobe(rot360 + intake_lobe_center + 2 * rot90) - .add_lobe(rot360 + intake_lobe_center + 4 * rot90) - .add_lobe(rot360 + intake_lobe_center + 1 * rot90) -} - -public node vtwin_camshaft_builder { - input lobe_profile; - input intake_lobe_profile: lobe_profile; - input exhaust_lobe_profile: lobe_profile; - input lobe_separation: 114.0 * units.deg; - input intake_lobe_center: lobe_separation; - input exhaust_lobe_center: lobe_separation; - input advance: 0.0 * units.deg; - input base_radius: 0.75 * units.inch; - input angle: 90 * 3 * units.deg; - - output intake_cam_0: _intake_cam_0; - output intake_cam_1: _intake_cam_1; - output exhaust_cam_0: _exhaust_cam_0; - output exhaust_cam_1: _exhaust_cam_1; - - camshaft_parameters params( - advance: advance, - base_radius: base_radius - ) - - camshaft _intake_cam_0(params, lobe_profile: intake_lobe_profile) - camshaft _intake_cam_1(params, lobe_profile: intake_lobe_profile) - camshaft _exhaust_cam_0(params, lobe_profile: exhaust_lobe_profile) - camshaft _exhaust_cam_1(params, lobe_profile: exhaust_lobe_profile) - - label rot90(90 * units.deg) - label rot360(360 * units.deg) - - _exhaust_cam_0 - .add_lobe(rot360 - exhaust_lobe_center) - _exhaust_cam_1 - .add_lobe(rot360 - exhaust_lobe_center + angle) - _intake_cam_0 - .add_lobe(rot360 + intake_lobe_center) - _intake_cam_1 - .add_lobe(rot360 + intake_lobe_center + angle) -} - -public node vtwin90_camshaft_builder { - input lobe_profile; - input intake_lobe_profile: lobe_profile; - input exhaust_lobe_profile: lobe_profile; - input lobe_separation: 114.0 * units.deg; - input intake_lobe_center: lobe_separation; - input exhaust_lobe_center: lobe_separation; - input advance: 0.0 * units.deg; - input base_radius: 0.75 * units.inch; - - output intake_cam_0: camshaft.intake_cam_0; - output intake_cam_1: camshaft.intake_cam_1; - output exhaust_cam_0: camshaft.exhaust_cam_0; - output exhaust_cam_1: camshaft.exhaust_cam_1; - - vtwin_camshaft_builder camshaft( - lobe_profile: lobe_profile, - intake_lobe_profile: intake_lobe_profile, - exhaust_lobe_profile: exhaust_lobe_profile, - lobe_separation: lobe_separation, - intake_lobe_center: intake_lobe_center, - exhaust_lobe_center: exhaust_lobe_center, - advance: advance, - base_radius: base_radius, - angle: 90 * 3 * units.deg - ) -} - -public node chevy_454_stock_camshaft { - alias output __out: - chevy_bbc_camshaft_builder( - advance: 0 * units.deg, - intake_lobe_profile: stock_454_intake_lobe_profile(), - exhaust_lobe_profile: stock_454_exhaust_lobe_profile(), - intake_lobe_center: 108 * units.deg, - exhaust_lobe_center: 113 * units.deg); -} - -public node comp_cams_magnum_11_450_8 { - alias output __out: - chevy_bbc_camshaft_builder( - lobe_profile: comp_cams_magnum_11_450_8_lobe_profile(), - lobe_separation: 110 * units.deg, - advance: 4.0 * units.deg, - base_radius: 1000.0 * units.thou); -} - -public node comp_cams_magnum_11_470_8 { - alias output __out: - chevy_bbc_camshaft_builder( - lobe_profile: comp_cams_magnum_11_470_8_lobe_profile(), - lobe_separation: 110 * units.deg, - advance: 4.0 * units.deg, - base_radius: 1000.0 * units.thou); -} diff --git a/es/constants.mr b/es/constants.mr deleted file mode 100644 index 5ee4176..0000000 --- a/es/constants.mr +++ /dev/null @@ -1,12 +0,0 @@ -module { - @name: "Units" - @author: "ATG (Ange Yaghi)" - @copyright: "Copyright 2022, Ange Yaghi" -} - -private import "../types/atomic_types.mr" -private import "../types/conversions.mr" - -public node constants { - output pi: 3.14159265359; -} diff --git a/es/constants/constants.mr b/es/constants/constants.mr deleted file mode 100644 index 5ee4176..0000000 --- a/es/constants/constants.mr +++ /dev/null @@ -1,12 +0,0 @@ -module { - @name: "Units" - @author: "ATG (Ange Yaghi)" - @copyright: "Copyright 2022, Ange Yaghi" -} - -private import "../types/atomic_types.mr" -private import "../types/conversions.mr" - -public node constants { - output pi: 3.14159265359; -} diff --git a/es/constants/units.mr b/es/constants/units.mr deleted file mode 100644 index 4e60838..0000000 --- a/es/constants/units.mr +++ /dev/null @@ -1,131 +0,0 @@ -module { - @name: "Units" - @author: "ATG (Ange Yaghi)" - @copyright: "Copyright 2022, Ange Yaghi" -} - -private import "constants.mr" - -private import "../types/atomic_types.mr" -private import "../types/conversions.mr" -private import "../types/operations.mr" - -constants constants() -public node units { - // Force - output N: 1.0; - output lbf: N * 4.44822; - - // Mass - output kg: 1.0; - output g: kg / 1000.0; - - output lb: 0.45359237 * kg; - - // Distance - output m: 1.0; - output cm: m / 100.0; - output mm: m / 1000.0; - output km: m * 1000.0; - - output inch: cm * 2.54; - output foot: inch * 12.0; - output thou: inch / 1000.0; - - output mile: m * 1609.344; - - // Time - output sec: 1.0; - output minute: 60.0 * sec; - output hour: 60.0 * minute; - - // Torque - output Nm: N * m; - output lb_ft: lbf * foot; - - // Volume - output m3: 1.0; - output cc: cm * cm * cm; - output mL: cc; - output L: mL * 1000.0; - output cubic_feet: foot * foot * foot; - output cubic_inches: inch * inch * inch; - output gal: 3.785411784 * L; - - // Molecular - output mol: 1.0; - output kmol: mol / 1000.0; - output mmol: kmol / 1000.0; - output lbmol: mol * 453.59237; - - // Flow-rate - output mol_per_sec: mol / sec; - output scfm: 0.002641 * lbmol / minute; - - // Area - output m2: 1.0; - output cm2: cm * cm; - - // Pressure - output Pa: 1.0; - output kPa: Pa * 1000.0; - output MPa: kPa * 1000.0; - output atm: 101.325 * kPa; - - output psi: lb / (inch * inch); - output psig: psi; - output inHg: Pa * 3386.3886666666713; - output inH2O: inHg * 0.0734824; - - // Temperature - output K: 1.0; - output K0: 273.15; - output C: K; - output F: (5.0 / 9.0) * K; - output F0: -459.67; - - // Energy - output J: 1.0; - output kJ: J * 1000.0; - output MJ: kJ * 1000.0; - - // Angles - output rad: 1.0; - output deg: rad * (constants.pi / 180.0); - - // RPM - output rpm: 0.104719755; - - // Speed - output mph: mile / hour; -} - -public node unit_names { - // Pressure - output inHg: "inHg"; - output mbar: "mbar"; - output millibar: mbar; - output bar: "bar"; - output kPa: "kPa"; - output psi: "psi"; - - // Speed - output mph: "mph"; - output kph: "kph"; - output american: mph; - output murican: american; - output british: mph; - output european: kph; - output euro: european; - - // Torque - output lb_ft: "lb-ft"; - output ft_lb: lb_ft; - output Nm: "Nm"; - - // Power - output hp: "hp"; - output kW: "kW"; - output horsepower: hp; - output kilowatt: kW; -} diff --git a/es/conversions.mr b/es/conversions.mr deleted file mode 100644 index d703961..0000000 --- a/es/conversions.mr +++ /dev/null @@ -1,25 +0,0 @@ -module { - @name: "Conversions" - @author: "ATG (Ange Yaghi)" - @copyright: "Copyright 2022, Ange Yaghi" -} - -private import "atomic_types.mr" - -// Float conversions -public node int_to_float => __engine_sim__int_to_float { - input __in [int]; - alias output __out [float]; -} - -// String conversions -public node int_to_string => __engine_sim__int_to_string { - input __in [int]; - alias output __out [string]; -} - -// Integer conversions -public node string_to_int => __engine_sim__string_to_int { - input __in [string]; - alias output __out [int]; -} diff --git a/es/engine_sim.mr b/es/engine_sim.mr deleted file mode 100644 index a64bb46..0000000 --- a/es/engine_sim.mr +++ /dev/null @@ -1,33 +0,0 @@ -module { - @name: "Engine Simulator Library" - @author: "ATG (Ange Yaghi)" - @copyright: "Copyright 2022, Ange Yaghi" -} - -// Types -public import "types/atomic_types.mr" -public import "types/conversions.mr" -public import "types/operations.mr" - -// Actions -public import "actions/actions.mr" - -// Objects -public import "objects/objects.mr" - -// Constants -public import "constants/constants.mr" -public import "constants/units.mr" - -// Infrastructure -public import "infrastructure/infrastructure.mr" - -// Library -public import "part-library/part_library.mr" -public import "sound-library/impulse_responses.mr" - -// Utilities -public import "utilities/utilities.mr" - -// Application settings -public import "settings/application_settings.mr" diff --git a/es/engines/atg-video-1/01_honda_trx520.mr b/es/engines/atg-video-1/01_honda_trx520.mr deleted file mode 100644 index 0ce7fcf..0000000 --- a/es/engines/atg-video-1/01_honda_trx520.mr +++ /dev/null @@ -1,174 +0,0 @@ -import "engine_sim.mr" - -units units() -constants constants() -impulse_response_library ir_lib() - -private node wires { - output wire1: ignition_wire(); - output wire2: ignition_wire(); -} - -public node honda_trx520 { - alias output __out: engine; - - engine engine( - name: "Honda TRX520 (ATV)", - starter_torque: 50 * units.lb_ft, - starter_speed: 500 * units.rpm, - redline: 5000 * units.rpm, - fuel: fuel( - max_burning_efficiency: 1.0 - ), - hf_gain: 0.00121, - noise: 0.229, - jitter: 0.42, - simulation_frequency: 40000 - ) - - wires wires() - - crankshaft c0( - throw: 71.5 * units.mm / 2, - flywheel_mass: 5 * units.lb, - mass: 5 * units.lb, - friction_torque: 5.0 * units.lb_ft, - moment_of_inertia: 0.22986844776863666 * 0.2, - position_x: 0.0, - position_y: 0.0, - tdc: constants.pi / 2 - ) - - rod_journal rj0(angle: 0.0) - c0 - .add_rod_journal(rj0) - - piston_parameters piston_params( - mass: 100 * units.g, - compression_height: 1.0 * units.inch, - wrist_pin_position: 0.0, - displacement: 0.0 - ) - - connecting_rod_parameters cr_params( - mass: 100.0 * units.g, - moment_of_inertia: 0.0015884918028487504, - center_of_mass: 0.0, - length: 6.0 * units.inch - ) - - cylinder_bank_parameters bank_params( - bore: 96 * units.mm, - deck_height: 71.5 * units.mm / 2 + 6.0 * units.inch + 1.0 * units.inch - ) - - intake intake( - plenum_volume: 1.5 * units.L, - plenum_cross_section_area: 10.0 * units.cm2, - intake_flow_rate: k_carb(100.0), - idle_flow_rate: k_carb(0.0), - idle_throttle_plate_position: 0.993, - velocity_decay: 0.5 - ) - - exhaust_system_parameters es_params( - outlet_flow_rate: k_carb(500.0), - primary_tube_length: 20.0 * units.inch, - primary_flow_rate: k_carb(200.0), - velocity_decay: 0.5, - volume: 5.0 * units.L - ) - - exhaust_system exhaust0( - es_params, - audio_volume: 1.0, - impulse_response: ir_lib.mild_exhaust_0_reverb - ) - - cylinder_bank b0(bank_params, angle: 0 * units.deg) - b0 - .add_cylinder( - piston: piston(piston_params, blowby: k_28inH2O(0.1)), - connecting_rod: connecting_rod(cr_params), - rod_journal: rj0, - intake: intake, - exhaust_system: exhaust0, - ignition_wire: wires.wire1 - ) - - engine - .add_cylinder_bank(b0) - - engine.add_crankshaft(c0) - - harmonic_cam_lobe lobe( - duration_at_50_thou: 180 * units.deg, - gamma: 1.0, - lift: 200 * units.thou, - steps: 100 - ) - - vtwin90_camshaft_builder camshaft( - lobe_profile: lobe, - lobe_separation: 100 * units.deg, - base_radius: 500 * units.thou - ) - - b0.set_cylinder_head ( - generic_small_engine_head( - chamber_volume: 60 * units.cc, - intake_camshaft: camshaft.intake_cam_0, - exhaust_camshaft: camshaft.exhaust_cam_0, - flow_attenuation: 2.0, - intake_runner_cross_section_area: 9.0 * units.cm2, - exhaust_runner_cross_section_area: 9.0 * units.cm2 - ) - ) - - function timing_curve(1000 * units.rpm) - timing_curve - .add_sample(0000 * units.rpm, 12 * units.deg) - .add_sample(1000 * units.rpm, 12 * units.deg) - .add_sample(2000 * units.rpm, 20 * units.deg) - .add_sample(3000 * units.rpm, 35 * units.deg) - .add_sample(4000 * units.rpm, 35 * units.deg) - - engine.add_ignition_module( - single_cylinder_distributor( - wires: wires, - timing_curve: timing_curve, - rev_limit: 6000 * units.rpm - )) -} - -private node honda_trx520_transmission { - alias output __out: transmission; - - transmission transmission( - max_clutch_torque: 50 * units.lb_ft - ) - - transmission.add_gear(4.0) - transmission.add_gear(3.5) - transmission.add_gear(3.0) - transmission.add_gear(2.5) - transmission.add_gear(2.0) -} - -private node honda_trx520_vehicle { - alias output __out: - vehicle( - mass: 500 * units.kg, - drag_coefficient: 0.25, - cross_sectional_area: (47 * units.inch) * (47 * units.inch), - diff_ratio: 3.33, - tire_radius: 11 * units.inch, - rolling_resistance: 200 * units.N - ); -} - -public node main { - set_engine(honda_trx520()) - set_transmission(honda_trx520_transmission()) - set_vehicle(honda_trx520_vehicle()) -} diff --git a/es/engines/atg-video-1/02_kohler_ch750.mr b/es/engines/atg-video-1/02_kohler_ch750.mr deleted file mode 100644 index fa240a8..0000000 --- a/es/engines/atg-video-1/02_kohler_ch750.mr +++ /dev/null @@ -1,194 +0,0 @@ -import "engine_sim.mr" - -units units() -constants constants() -impulse_response_library ir_lib() - -private node wires { - output wire1: ignition_wire(); - output wire2: ignition_wire(); -} - -public node kohler_ch750 { - alias output __out: engine; - - engine engine( - name: "Kohler CH750", - starter_torque: 50 * units.lb_ft, - starter_speed: 500 * units.rpm, - redline: 3600 * units.rpm, - throttle: - governor( - min_speed: 1600 * units.rpm, - max_speed: 3500 * units.rpm, - min_v: -5.0, - max_v: 5.0, - k_s: 0.0006, - k_d: 200.0, - gamma: 2.0 - ), - hf_gain: 0.01, - noise: 1.0, - jitter: 0.5, - simulation_frequency: 30000 - ) - - wires wires() - - crankshaft c0( - throw: 69 * units.mm / 2, - flywheel_mass: 5 * units.lb, - mass: 5 * units.lb, - friction_torque: 10.0 * units.lb_ft, - moment_of_inertia: 0.22986844776863666 * 0.5, - position_x: 0.0, - position_y: 0.0, - tdc: constants.pi / 4 - ) - - rod_journal rj0(angle: 0.0) - c0 - .add_rod_journal(rj0) - - piston_parameters piston_params( - mass: 400 * units.g, - //blowby: k_28inH2O(0.1), - compression_height: 1.0 * units.inch, - wrist_pin_position: 0.0, - displacement: 0.0 - ) - - connecting_rod_parameters cr_params( - mass: 300.0 * units.g, - moment_of_inertia: 0.0015884918028487504, - center_of_mass: 0.0, - length: 4.0 * units.inch - ) - - cylinder_bank_parameters bank_params( - bore: 83 * units.mm, - deck_height: (4.0 + 1) * units.inch + 69 * units.mm / 2 - ) - - intake intake( - plenum_volume: 1.0 * units.L, - plenum_cross_section_area: 10.0 * units.cm2, - intake_flow_rate: k_carb(50.0), - idle_flow_rate: k_carb(0.0), - idle_throttle_plate_position: 0.96 - ) - - exhaust_system_parameters es_params( - outlet_flow_rate: k_carb(300.0), - primary_tube_length: 10.0 * units.inch, - primary_flow_rate: k_carb(200.0), - velocity_decay: 1.0, - volume: 20.0 * units.L - ) - - exhaust_system exhaust0( - es_params, - audio_volume: 1.0, - impulse_response: ir_lib.default_0 - ) - - cylinder_bank b0(bank_params, angle: -45 * units.deg) - b0 - .add_cylinder( - piston: piston(piston_params, blowby: k_28inH2O(0.1)), - connecting_rod: connecting_rod(cr_params), - rod_journal: rj0, - intake: intake, - exhaust_system: exhaust0, - ignition_wire: wires.wire1 - ) - - cylinder_bank b1(bank_params, angle: 45.0 * units.deg) - b1 - .add_cylinder( - piston: piston(piston_params, blowby: k_28inH2O(0.1)), - connecting_rod: connecting_rod(cr_params), - rod_journal: rj0, - intake: intake, - exhaust_system: exhaust0, - ignition_wire: wires.wire2 - ) - - engine - .add_cylinder_bank(b0) - .add_cylinder_bank(b1) - - engine.add_crankshaft(c0) - - harmonic_cam_lobe lobe( - duration_at_50_thou: 160 * units.deg, - gamma: 1.1, - lift: 200 * units.thou, - steps: 100 - ) - - vtwin90_camshaft_builder camshaft( - lobe_profile: lobe, - lobe_separation: 114 * units.deg, - base_radius: 500 * units.thou - ) - - b0.set_cylinder_head ( - generic_small_engine_head( - chamber_volume: 50 * units.cc, - intake_camshaft: camshaft.intake_cam_0, - exhaust_camshaft: camshaft.exhaust_cam_0 - ) - ) - b1.set_cylinder_head ( - generic_small_engine_head( - chamber_volume: 50 * units.cc, - intake_camshaft: camshaft.intake_cam_1, - exhaust_camshaft: camshaft.exhaust_cam_1, - flip_display: true - ) - ) - - function timing_curve(1000 * units.rpm) - timing_curve - .add_sample(0000 * units.rpm, 18 * units.deg) - .add_sample(1000 * units.rpm, 30 * units.deg) - .add_sample(2000 * units.rpm, 50 * units.deg) - .add_sample(3000 * units.rpm, 50 * units.deg) - .add_sample(4000 * units.rpm, 50 * units.deg) - - engine.add_ignition_module( - vtwin90_distributor( - wires: wires, - timing_curve: timing_curve, - rev_limit: 5000 * units.rpm - )) -} - -private node direct_drive { - alias output __out: transmission; - - transmission transmission( - max_clutch_torque: 35 * units.lb_ft - ) - - transmission.add_gear(1.0) -} - -private node static_load { - alias output __out: - vehicle( - mass: 563 * units.lb, - drag_coefficient: 0.1, - cross_sectional_area: (20 * units.inch) * (47 * units.inch), - diff_ratio: 2.353, - tire_radius: 8.5 * units.inch, - rolling_resistance: 10000 * units.N - ); -} - -public node main { - set_engine(kohler_ch750()) - set_transmission(direct_drive()) - set_vehicle(static_load()) -} diff --git a/es/engines/atg-video-1/03_harley_davidson_shovelhead.mr b/es/engines/atg-video-1/03_harley_davidson_shovelhead.mr deleted file mode 100644 index daa2020..0000000 --- a/es/engines/atg-video-1/03_harley_davidson_shovelhead.mr +++ /dev/null @@ -1,231 +0,0 @@ -import "engine_sim.mr" - -units units() -constants constants() -impulse_response_library ir_lib() - -private node wires { - output wire1: ignition_wire(); - output wire2: ignition_wire(); -} - -public node harley_distributor { - input wires; - input timing_curve; - input rev_limit: 5500 * units.rpm; - alias output __out: - ignition_module(timing_curve: timing_curve, rev_limit: rev_limit) - .connect_wire(wires.wire1, 0 * units.deg) - .connect_wire(wires.wire2, 315 * units.deg); -} - -public node harley_davidson_shovelhead { - alias output __out: engine; - - engine engine( - name: "Harley Davidson Shovelhead", - starter_torque: 70 * units.lb_ft, - starter_speed: 500 * units.rpm, - redline: 5000 * units.rpm, - hf_gain: 0.01, - noise: 0.115, - jitter: 0.136, - simulation_frequency: 35000 - ) - - wires wires() - - label stroke(4.25 * units.inch) - label bore(3.5 * units.inch) - label rod_length(8 * units.inch) - label compression_height(1.0 * units.inch) - label crank_mass(9.39 * units.kg) - label flywheel_mass(15 * units.kg) - label flywheel_radius(6 * units.inch) - - label crank_moment( - disk_moment_of_inertia(mass: crank_mass, radius: stroke / 2) - ) - label flywheel_moment( - disk_moment_of_inertia(mass: flywheel_mass, radius: flywheel_radius) - ) - label other_moment( // Moment from cams, pulleys, etc [estimated] - disk_moment_of_inertia(mass: 10 * units.kg, radius: 3.0 * units.cm) - ) - - crankshaft c0( - throw: stroke / 2, - flywheel_mass: flywheel_mass, - mass: crank_mass, - friction_torque: 5.0 * units.lb_ft, - moment_of_inertia: - crank_moment + flywheel_moment + other_moment, - position_x: 0.0, - position_y: 0.0, - tdc: (90 - 0.5 * 45) * units.deg - ) - - rod_journal rj0(angle: 0.0) - c0 - .add_rod_journal(rj0) - - piston_parameters piston_params( - mass: 500 * units.g, - compression_height: compression_height, - wrist_pin_position: 0.0, - displacement: 0.0 - ) - - connecting_rod_parameters cr_params( - mass: 500.0 * units.g, - moment_of_inertia: 0.0015884918028487504, - center_of_mass: 0.0, - length: rod_length - ) - - intake intake( - plenum_volume: 1.5 * units.L, - plenum_cross_section_area: 10.0 * units.cm2, - intake_flow_rate: k_carb(100.0), - idle_flow_rate: k_carb(0.0), - idle_throttle_plate_position: 0.991, - throttle_gamma: 1.0, - velocity_decay: 1.0 - ) - - exhaust_system_parameters es_params( - outlet_flow_rate: k_carb(100.0), - primary_tube_length: 70.0 * units.inch, - primary_flow_rate: k_carb(100.0), - velocity_decay: 0.75, - volume: 10.0 * units.L - ) - - exhaust_system exhaust0( - es_params, - audio_volume: 1.0 * 0.1, - impulse_response: ir_lib.minimal_muffling_01 - ) - - exhaust_system exhaust1( - es_params, - audio_volume: 2.0 * 0.1, - impulse_response: ir_lib.minimal_muffling_01 - ) - - cylinder_bank_parameters bank_params( - bore: bore, - deck_height: stroke / 2 + rod_length + compression_height - ) - - cylinder_bank b0(bank_params, angle: -0.5 * 45 * units.deg, display_depth: 0.55) - b0 - .add_cylinder( - piston: piston(piston_params, blowby: k_28inH2O(0.2)), - connecting_rod: connecting_rod(cr_params), - rod_journal: rj0, - intake: intake, - exhaust_system: exhaust0, - ignition_wire: wires.wire1 - ) - - cylinder_bank b1(bank_params, angle: 0.5 * 45 * units.deg, display_depth: 0.55) - b1 - .add_cylinder( - piston: piston(piston_params, blowby: k_28inH2O(0.1)), - connecting_rod: connecting_rod(cr_params), - rod_journal: rj0, - intake: intake, - exhaust_system: exhaust1, - ignition_wire: wires.wire2 - ) - - engine - .add_cylinder_bank(b0) - .add_cylinder_bank(b1) - - engine.add_crankshaft(c0) - - harmonic_cam_lobe lobe( - duration_at_50_thou: 210 * units.deg, - gamma: 0.9, - lift: 400 * units.thou, - steps: 100 - ) - - vtwin_camshaft_builder camshaft( - lobe_profile: lobe, - lobe_separation: 110 * units.deg, - base_radius: 500 * units.thou, - angle: 315 * units.deg - ) - - b0.set_cylinder_head ( - generic_small_engine_head( - chamber_volume: 100 * units.cc, - intake_camshaft: camshaft.intake_cam_0, - exhaust_camshaft: camshaft.exhaust_cam_0, - flow_attenuation: 2.0, - intake_runner_cross_section_area: 20.0 * units.cm2, - exhaust_runner_cross_section_area: 20.0 * units.cm2 - ) - ) - - b1.set_cylinder_head ( - generic_small_engine_head( - flip_display: true, - chamber_volume: 100 * units.cc, - intake_camshaft: camshaft.intake_cam_1, - exhaust_camshaft: camshaft.exhaust_cam_1, - flow_attenuation: 1.0, - intake_runner_cross_section_area: 20.0 * units.cm2, - exhaust_runner_cross_section_area: 20.0 * units.cm2 - ) - ) - - function timing_curve(1000 * units.rpm) - timing_curve - .add_sample(0000 * units.rpm, 18 * units.deg) - .add_sample(1000 * units.rpm, 18 * units.deg) - .add_sample(2000 * units.rpm, 30 * units.deg) - .add_sample(3000 * units.rpm, 40 * units.deg) - .add_sample(4000 * units.rpm, 40 * units.deg) - - engine.add_ignition_module( - harley_distributor( - wires: wires, - timing_curve: timing_curve, - rev_limit: 5500 * units.rpm - )) -} - -private node harley_davidson_motorcyle { - alias output __out: - vehicle( - mass: 900 * units.lb, - drag_coefficient: 0.1, - cross_sectional_area: (15 * units.inch) * (47 * units.inch), - diff_ratio: 2.0, - tire_radius: 11 * units.inch, - rolling_resistance: 200 * units.N - ); -} - -private node harley_davidson_transmission { - alias output __out: - transmission( - max_clutch_torque: 200 * units.lb_ft - ) - .add_gear(3.34) - .add_gear(2.30) - .add_gear(1.71) - .add_gear(1.41) - .add_gear(1.18) - .add_gear(1.00); -} - -public node main { - set_engine(harley_davidson_shovelhead()) - set_vehicle(harley_davidson_motorcyle()) - set_transmission(harley_davidson_transmission()) -} diff --git a/es/engines/atg-video-1/04_hayabusa.mr b/es/engines/atg-video-1/04_hayabusa.mr deleted file mode 100644 index efe839a..0000000 --- a/es/engines/atg-video-1/04_hayabusa.mr +++ /dev/null @@ -1,331 +0,0 @@ -import "engine_sim.mr" - -units units() -constants constants() -impulse_response_library ir_lib() -label cycle(2 * 360 * units.deg) - -private node wires { - output wire1: ignition_wire(); - output wire2: ignition_wire(); - output wire3: ignition_wire(); - output wire4: ignition_wire(); -} - -private node hayabusa_head { - input intake_camshaft; - input exhaust_camshaft; - input chamber_volume: 19.2 * units.cc; - input intake_runner_volume: 149.6 * units.cc; - input intake_runner_cross_section_area: 10.0 * units.cm2 * 2.0; - input exhaust_runner_volume: 50.0 * units.cc; - input exhaust_runner_cross_section_area: 15.0 * units.cm2 * 2.0; - - input flow_attenuation: 1.0; - input lift_scale: 1.0; - input flip_display: false; - alias output __out: head; - - function intake_flow(50 * units.thou) - intake_flow - .add_flow_sample(0 * lift_scale, 0 * flow_attenuation) - .add_flow_sample(50 * lift_scale, 40 * flow_attenuation) - .add_flow_sample(100 * lift_scale, 80 * flow_attenuation) - .add_flow_sample(150 * lift_scale, 125 * flow_attenuation) - .add_flow_sample(200 * lift_scale, 160 * flow_attenuation) - .add_flow_sample(250 * lift_scale, 190 * flow_attenuation) - .add_flow_sample(300 * lift_scale, 210 * flow_attenuation) - .add_flow_sample(350 * lift_scale, 225 * flow_attenuation) - .add_flow_sample(400 * lift_scale, 230 * flow_attenuation) - .add_flow_sample(450 * lift_scale, 240 * flow_attenuation) - - function exhaust_flow(50 * units.thou) - exhaust_flow - .add_flow_sample(0 * lift_scale, 0 * flow_attenuation) - .add_flow_sample(50 * lift_scale, 30 * flow_attenuation) - .add_flow_sample(100 * lift_scale, 70 * flow_attenuation) - .add_flow_sample(150 * lift_scale, 100 * flow_attenuation) - .add_flow_sample(200 * lift_scale, 125 * flow_attenuation) - .add_flow_sample(250 * lift_scale, 140 * flow_attenuation) - .add_flow_sample(300 * lift_scale, 150 * flow_attenuation) - .add_flow_sample(350 * lift_scale, 160 * flow_attenuation) - .add_flow_sample(400 * lift_scale, 165 * flow_attenuation) - .add_flow_sample(450 * lift_scale, 170 * flow_attenuation) - - cylinder_head head( - chamber_volume: chamber_volume, - intake_runner_volume: intake_runner_volume, - intake_runner_cross_section_area: intake_runner_cross_section_area, - exhaust_runner_volume: exhaust_runner_volume, - exhaust_runner_cross_section_area: exhaust_runner_cross_section_area, - - intake_port_flow: intake_flow, - exhaust_port_flow: exhaust_flow, - intake_camshaft: intake_camshaft, - exhaust_camshaft: exhaust_camshaft, - flip_display: flip_display - ) -} - -private node hayabusa_camshaft { - input lobe_profile; - input intake_lobe_profile: lobe_profile; - input exhaust_lobe_profile: lobe_profile; - input lobe_separation: 114 * units.deg; - input intake_lobe_center: lobe_separation; - input exhaust_lobe_center: lobe_separation; - input advance: 0 * units.deg; - input base_radius: 0.75 * units.inch; - - output intake_cam_0: _intake_cam_0; - output exhaust_cam_0: _exhaust_cam_0; - - camshaft_parameters params ( - advance: advance, - base_radius: base_radius - ) - - camshaft _intake_cam_0(params, lobe_profile: intake_lobe_profile) - camshaft _exhaust_cam_0(params, lobe_profile: exhaust_lobe_profile) - - label rot180(180 * units.deg) - label rot360(360 * units.deg) - - _exhaust_cam_0 - .add_lobe(rot360 - exhaust_lobe_center + (0.0 / 4) * cycle) - .add_lobe(rot360 - exhaust_lobe_center + (1.0 / 4) * cycle) - .add_lobe(rot360 - exhaust_lobe_center + (3.0 / 4) * cycle) - .add_lobe(rot360 - exhaust_lobe_center + (2.0 / 4) * cycle) - _intake_cam_0 - .add_lobe(rot360 + intake_lobe_center + (0.0 / 4) * cycle) - .add_lobe(rot360 + intake_lobe_center + (1.0 / 4) * cycle) - .add_lobe(rot360 + intake_lobe_center + (3.0 / 4) * cycle) - .add_lobe(rot360 + intake_lobe_center + (2.0 / 4) * cycle) -} - -public node hayabusa_i4 { - alias output __out: engine; - - engine engine( - name: "Suzuki Hayabusa I4", - starter_torque: 70 * units.lb_ft, - starter_speed: 500 * units.rpm, - redline: 11000 * units.rpm, - fuel: fuel( - max_turbulence_effect: 5.5, - max_dilution_effect: 1000.0, - max_burning_efficiency: 1.0, - burning_efficiency_randomness: 0.0 - ), - throttle_gamma: 2.0, - hf_gain: 0.00407, - noise: 0.292, - jitter: 0.062, - simulation_frequency: 20000 - ) - - wires wires() - - label stroke(65 * units.mm) - label bore(81 * units.mm) - label rod_length(4.705 * units.inch) - label compression_height(1.0 * units.inch) - - crankshaft c0( - throw: stroke / 2, - flywheel_mass: 10 * units.lb, - mass: 24.8 * units.lb, - friction_torque: 1.0 * units.lb_ft, - moment_of_inertia: 0.22986844776863666 * 0.2, - position_x: 0.0, - position_y: 0.0, - tdc: 90 * units.deg - ) - - rod_journal rj0(angle: 0.0 * units.deg) - rod_journal rj1(angle: 180.0 * units.deg) - rod_journal rj2(angle: 180.0 * units.deg) - rod_journal rj3(angle: 0.0 * units.deg) - c0 - .add_rod_journal(rj0) - .add_rod_journal(rj1) - .add_rod_journal(rj2) - .add_rod_journal(rj3) - - piston_parameters piston_params( - mass: 303.5 * units.g, - compression_height: compression_height, - wrist_pin_position: 0.0, - displacement: 0.0 - ) - - connecting_rod_parameters cr_params( - mass: 395.837 * units.g, - moment_of_inertia: 0.0015884918028487504, - center_of_mass: 0.0, - length: rod_length - ) - - intake intake( - plenum_volume: 4.5 * units.L, - plenum_cross_section_area: 10.0 * units.cm2, - intake_flow_rate: k_carb(800.0), - runner_flow_rate: k_carb(300.0), - runner_length: 10.0 * units.inch, - idle_flow_rate: k_carb(0.0), - idle_throttle_plate_position: 0.999, - velocity_decay: 0.5 - ) - - exhaust_system_parameters es_params( - outlet_flow_rate: k_carb(1000.0), - primary_tube_length: 40.0 * units.inch, - primary_flow_rate: k_carb(500.0), - velocity_decay: 1.0, - volume: 10.0 * units.L - ) - - exhaust_system exhaust0( - es_params, - audio_volume: 1.0 * 0.25, - impulse_response: ir_lib.minimal_muffling_03 - ) - - exhaust_system exhaust1( - es_params, - audio_volume: 2.0 * 0.25, - impulse_response: ir_lib.minimal_muffling_03 - ) - - cylinder_bank_parameters bank_params( - bore: bore, - deck_height: stroke / 2 + rod_length + compression_height - ) - - cylinder_bank b0(bank_params, angle: 0.0 * units.deg) - b0 - .add_cylinder( - piston: piston(piston_params, blowby: k_28inH2O(0.001)), - connecting_rod: connecting_rod(cr_params), - rod_journal: rj0, - intake: intake, - exhaust_system: exhaust0, - ignition_wire: wires.wire1, - sound_attenuation: 0.9 - ) - .add_cylinder( - piston: piston(piston_params, blowby: k_28inH2O(0.002)), - connecting_rod: connecting_rod(cr_params), - rod_journal: rj1, - intake: intake, - exhaust_system: exhaust1, - ignition_wire: wires.wire2, - sound_attenuation: 0.8 - ) - .add_cylinder( - piston: piston(piston_params, blowby: k_28inH2O(0.001)), - connecting_rod: connecting_rod(cr_params), - rod_journal: rj2, - intake: intake, - exhaust_system: exhaust0, - ignition_wire: wires.wire3, - sound_attenuation: 1.1 - ) - .add_cylinder( - piston: piston(piston_params, blowby: k_28inH2O(0.002)), - connecting_rod: connecting_rod(cr_params), - rod_journal: rj3, - intake: intake, - exhaust_system: exhaust1, - ignition_wire: wires.wire4, - sound_attenuation: 0.9 - ) - - engine - .add_cylinder_bank(b0) - - engine.add_crankshaft(c0) - - harmonic_cam_lobe intake_lobe( - duration_at_50_thou: 240 * units.deg, - gamma: 1.2, - lift: 345 * units.thou, - steps: 100 - ) - - harmonic_cam_lobe exhaust_lobe( - duration_at_50_thou: 220 * units.deg, - gamma: 1.2, - lift: 294 * units.thou, - steps: 100 - ) - - hayabusa_camshaft camshaft( - lobe_profile: "N/A", - intake_lobe_profile: intake_lobe, - exhaust_lobe_profile: exhaust_lobe, - intake_lobe_center: 105 * units.deg, - exhaust_lobe_center: 100 * units.deg, - base_radius: 500 * units.thou - ) - - b0.set_cylinder_head ( - hayabusa_head( - intake_camshaft: camshaft.intake_cam_0, - exhaust_camshaft: camshaft.exhaust_cam_0 - ) - ) - - function timing_curve(1000 * units.rpm) - timing_curve - .add_sample(0000 * units.rpm, 25 * units.deg) - .add_sample(1000 * units.rpm, 25 * units.deg) - .add_sample(2000 * units.rpm, 30 * units.deg) - .add_sample(3000 * units.rpm, 40 * units.deg) - .add_sample(4000 * units.rpm, 40 * units.deg) - - ignition_module ignition_module( - timing_curve: timing_curve, - rev_limit: 11500 * units.rpm, - limiter_duration: 0.05) - ignition_module - .connect_wire(wires.wire1, (0.0 / 4.0) * cycle) - .connect_wire(wires.wire2, (1.0 / 4.0) * cycle) - .connect_wire(wires.wire4, (2.0 / 4.0) * cycle) - .connect_wire(wires.wire3, (3.0 / 4.0) * cycle) - - engine.add_ignition_module(ignition_module) -} - -private node hayabusa_transmission { - alias output __out: transmission; - - transmission transmission( - max_clutch_torque: 200 * units.lb_ft - ) - - transmission.add_gear(2.615) - transmission.add_gear(1.937) - transmission.add_gear(1.526) - transmission.add_gear(1.285) - transmission.add_gear(1.136) - transmission.add_gear(1.043) -} - -private node hayabusa { - alias output __out: - vehicle( - mass: 563 * units.lb, - drag_coefficient: 0.1, - cross_sectional_area: (20 * units.inch) * (47 * units.inch), - diff_ratio: 2.353, - tire_radius: 8.5 * units.inch, - rolling_resistance: 100 * units.N - ); -} - -public node main { - set_engine(hayabusa_i4()) - set_transmission(hayabusa_transmission()) - set_vehicle(hayabusa()) -} diff --git a/es/engines/atg-video-1/05_honda_vtec.mr b/es/engines/atg-video-1/05_honda_vtec.mr deleted file mode 100644 index e78abcb..0000000 --- a/es/engines/atg-video-1/05_honda_vtec.mr +++ /dev/null @@ -1,370 +0,0 @@ -import "engine_sim.mr" - -units units() -constants constants() -impulse_response_library ir_lib() -label cycle(2 * 360 * units.deg) - -private node wires { - output wire1: ignition_wire(); - output wire2: ignition_wire(); - output wire3: ignition_wire(); - output wire4: ignition_wire(); -} - -private node honda_vtec_head { - input camshaft_set; - input chamber_volume: 41.6 * units.cc; - input intake_runner_volume: 149.6 * units.cc; - input intake_runner_cross_section_area: 1.35 * units.inch * 1.35 * units.inch; - input exhaust_runner_volume: 50.0 * units.cc; - input exhaust_runner_cross_section_area: 1.25 * units.inch * 1.25 * units.inch; - - input flow_attenuation: 1.0; - input lift_scale: 1.0; - input flip_display: false; - alias output __out: head; - - function intake_flow(50 * units.thou) - intake_flow - .add_flow_sample(0 * lift_scale, 0 * flow_attenuation) - .add_flow_sample(50 * lift_scale, 50 * flow_attenuation) - .add_flow_sample(100 * lift_scale, 80 * flow_attenuation) - .add_flow_sample(150 * lift_scale, 125 * flow_attenuation) - .add_flow_sample(200 * lift_scale, 160 * flow_attenuation) - .add_flow_sample(250 * lift_scale, 190 * flow_attenuation) - .add_flow_sample(300 * lift_scale, 210 * flow_attenuation) - .add_flow_sample(350 * lift_scale, 225 * flow_attenuation) - .add_flow_sample(400 * lift_scale, 230 * flow_attenuation) - .add_flow_sample(450 * lift_scale, 250 * flow_attenuation) - - function exhaust_flow(50 * units.thou) - exhaust_flow - .add_flow_sample(0 * lift_scale, 0 * flow_attenuation) - .add_flow_sample(50 * lift_scale, 50 * flow_attenuation) - .add_flow_sample(100 * lift_scale, 80 * flow_attenuation) - .add_flow_sample(150 * lift_scale, 110 * flow_attenuation) - .add_flow_sample(200 * lift_scale, 130 * flow_attenuation) - .add_flow_sample(250 * lift_scale, 150 * flow_attenuation) - .add_flow_sample(300 * lift_scale, 160 * flow_attenuation) - .add_flow_sample(350 * lift_scale, 170 * flow_attenuation) - .add_flow_sample(400 * lift_scale, 170 * flow_attenuation) - .add_flow_sample(450 * lift_scale, 170 * flow_attenuation) - - generic_cylinder_head head( - chamber_volume: chamber_volume, - intake_runner_volume: intake_runner_volume, - intake_runner_cross_section_area: intake_runner_cross_section_area, - exhaust_runner_volume: exhaust_runner_volume, - exhaust_runner_cross_section_area: exhaust_runner_cross_section_area, - - intake_port_flow: intake_flow, - exhaust_port_flow: exhaust_flow, - valvetrain: vtec_valvetrain( - vtec_intake_camshaft: camshaft_set.vtec_intake_cam, - vtec_exhaust_camshaft: camshaft_set.vtec_exhaust_cam, - intake_camshaft: camshaft_set.intake_cam, - exhaust_camshaft: camshaft_set.exhaust_cam - ), - flip_display: flip_display - ) -} - -private node honda_vtec_camshaft { - input lobe_profile; - input intake_lobe_profile: lobe_profile; - input exhaust_lobe_profile: lobe_profile; - - input vtec_lobe_profile; - input vtec_intake_lobe_profile: vtec_lobe_profile; - input vtec_exhaust_lobe_profile: vtec_lobe_profile; - - input lobe_separation: 114 * units.deg; - input intake_lobe_center: lobe_separation; - input exhaust_lobe_center: lobe_separation; - input vtec_lobe_separation: 110 * units.deg; - input vtec_intake_lobe_center: vtec_lobe_separation; - input vtec_exhaust_lobe_center: vtec_lobe_separation; - input advance: 0 * units.deg; - input base_radius: 1.0 * units.inch; - - output intake_cam: _intake_cam; - output exhaust_cam: _exhaust_cam; - output vtec_intake_cam: _vtec_intake_cam; - output vtec_exhaust_cam: _vtec_exhaust_cam; - - camshaft_parameters params ( - advance: advance, - base_radius: base_radius - ) - - camshaft _intake_cam(params, lobe_profile: intake_lobe_profile) - camshaft _exhaust_cam(params, lobe_profile: exhaust_lobe_profile) - camshaft _vtec_intake_cam(params, lobe_profile: vtec_intake_lobe_profile) - camshaft _vtec_exhaust_cam(params, lobe_profile: vtec_exhaust_lobe_profile) - - label rot180(180 * units.deg) - label rot360(360 * units.deg) - - _exhaust_cam - .add_lobe(rot360 + exhaust_lobe_center - (0.0 / 4) * cycle) - .add_lobe(rot360 + exhaust_lobe_center - (3.0 / 4) * cycle) - .add_lobe(rot360 + exhaust_lobe_center - (1.0 / 4) * cycle) - .add_lobe(rot360 + exhaust_lobe_center - (2.0 / 4) * cycle) - _intake_cam - .add_lobe(rot360 - intake_lobe_center - (0.0 / 4) * cycle) - .add_lobe(rot360 - intake_lobe_center - (3.0 / 4) * cycle) - .add_lobe(rot360 - intake_lobe_center - (1.0 / 4) * cycle) - .add_lobe(rot360 - intake_lobe_center - (2.0 / 4) * cycle) - _vtec_exhaust_cam - .add_lobe(rot360 + vtec_exhaust_lobe_center - (0.0 / 4) * cycle) - .add_lobe(rot360 + vtec_exhaust_lobe_center - (3.0 / 4) * cycle) - .add_lobe(rot360 + vtec_exhaust_lobe_center - (1.0 / 4) * cycle) - .add_lobe(rot360 + vtec_exhaust_lobe_center - (2.0 / 4) * cycle) - _vtec_intake_cam - .add_lobe(rot360 - vtec_intake_lobe_center - (0.0 / 4) * cycle) - .add_lobe(rot360 - vtec_intake_lobe_center - (3.0 / 4) * cycle) - .add_lobe(rot360 - vtec_intake_lobe_center - (1.0 / 4) * cycle) - .add_lobe(rot360 - vtec_intake_lobe_center - (2.0 / 4) * cycle) -} - -public node honda_vtec_i4 { - alias output __out: engine; - - engine engine( - name: "Honda B18C5 [VTEC, I4]", - starter_torque: 70 * units.lb_ft, - starter_speed: -500 * units.rpm, - redline: 8400 * units.rpm, - fuel: fuel( - max_turbulence_effect: 2.5, - max_burning_efficiency: 0.75 - ), - throttle_gamma: 2.0, - hf_gain: 0.002, - noise: 0.253, - jitter: 0.195, - simulation_frequency: 20000 - ) - - wires wires() - - label stroke(87.2 * units.mm) - label bore(81 * units.mm) - label rod_length(5.430 * units.inch) - label compression_height(1.0 * units.inch) - - crankshaft c0( - throw: stroke / 2, - flywheel_mass: 10 * units.lb, - mass: 35.5 * units.lb, - friction_torque: 1.0 * units.lb_ft, - moment_of_inertia: 0.22986844776863666 * 0.5, - position_x: 0.0, - position_y: 0.0, - tdc: 90 * units.deg - ) - - rod_journal rj0(angle: 0.0 * units.deg) - rod_journal rj1(angle: 180.0 * units.deg) - rod_journal rj2(angle: 180.0 * units.deg) - rod_journal rj3(angle: 0.0 * units.deg) - c0 - .add_rod_journal(rj0) - .add_rod_journal(rj1) - .add_rod_journal(rj2) - .add_rod_journal(rj3) - - piston_parameters piston_params( - mass: 303.5 * units.g, - compression_height: compression_height, - wrist_pin_position: 0.0, - displacement: 0.0 - ) - - connecting_rod_parameters cr_params( - mass: 395.837 * units.g, - moment_of_inertia: 0.0015884918028487504, - center_of_mass: 0.0, - length: rod_length - ) - - intake intake( - plenum_volume: 1.325 * units.L, - plenum_cross_section_area: 20.0 * units.cm2, - intake_flow_rate: k_carb(800.0), - runner_flow_rate: k_carb(250.0), - runner_length: 7.0 * units.inch, - idle_flow_rate: k_carb(0.0), - idle_throttle_plate_position: 0.9989, - velocity_decay: 0.5 - ) - - exhaust_system_parameters es_params( - outlet_flow_rate: k_carb(1000.0), - primary_tube_length: 10.0 * units.inch, - primary_flow_rate: k_carb(200.0), - velocity_decay: 1.0, - volume: 100.0 * units.L - ) - - exhaust_system exhaust0( - es_params, - audio_volume: 8 * 0.75, - impulse_response: ir_lib.mild_exhaust_0 - ) - - exhaust_system exhaust1( - es_params, - audio_volume: 8 * 1.0, - impulse_response: ir_lib.mild_exhaust_0 - ) - - cylinder_bank_parameters bank_params( - bore: bore, - deck_height: stroke / 2 + rod_length + compression_height - ) - - cylinder_bank b0(bank_params, angle: 0.0 * units.deg) - b0 - .add_cylinder( - piston: piston(piston_params, blowby: k_28inH2O(0.001)), - connecting_rod: connecting_rod(cr_params), - rod_journal: rj0, - intake: intake, - exhaust_system: exhaust0, - ignition_wire: wires.wire1, - sound_attenuation: 0.9 - ) - .add_cylinder( - piston: piston(piston_params, blowby: k_28inH2O(0.002)), - connecting_rod: connecting_rod(cr_params), - rod_journal: rj1, - intake: intake, - exhaust_system: exhaust1, - ignition_wire: wires.wire2, - sound_attenuation: 1.1 - ) - .add_cylinder( - piston: piston(piston_params, blowby: k_28inH2O(0.001)), - connecting_rod: connecting_rod(cr_params), - rod_journal: rj2, - intake: intake, - exhaust_system: exhaust0, - ignition_wire: wires.wire3, - sound_attenuation: 0.8 - ) - .add_cylinder( - piston: piston(piston_params, blowby: k_28inH2O(0.002)), - connecting_rod: connecting_rod(cr_params), - rod_journal: rj3, - intake: intake, - exhaust_system: exhaust1, - ignition_wire: wires.wire4, - sound_attenuation: 0.9 - ) - - engine - .add_cylinder_bank(b0) - - engine.add_crankshaft(c0) - - harmonic_cam_lobe intake_lobe( - duration_at_50_thou: 210 * units.deg, - gamma: 1.0, - lift: 6.9 * units.mm, - steps: 100 - ) - - harmonic_cam_lobe exhaust_lobe( - duration_at_50_thou: 190 * units.deg, - gamma: 1.0, - lift: 6.5 * units.mm, - steps: 100 - ) - - harmonic_cam_lobe vtec_intake_lobe( - duration_at_50_thou: 240 * units.deg, - gamma: 0.5, - lift: 11.5 * units.mm, - steps: 100 - ) - - harmonic_cam_lobe vtec_exhaust_lobe( - duration_at_50_thou: 232 * units.deg, - gamma: 0.5, - lift: 10.5 * units.mm, - steps: 100 - ) - - honda_vtec_camshaft camshaft( - lobe_profile: "N/A", - vtec_lobe_profile: "N/A", - - intake_lobe_profile: intake_lobe, - exhaust_lobe_profile: exhaust_lobe, - vtec_intake_lobe_profile: vtec_intake_lobe, - vtec_exhaust_lobe_profile: vtec_exhaust_lobe, - intake_lobe_center: 116 * units.deg, - exhaust_lobe_center: 116 * units.deg, - vtec_intake_lobe_center: 100 * units.deg, - vtec_exhaust_lobe_center: 100 * units.deg, - base_radius: 500 * units.thou - ) - - b0.set_cylinder_head ( - honda_vtec_head( - camshaft_set: camshaft - ) - ) - - function timing_curve(1000 * units.rpm) - timing_curve - .add_sample(0000 * units.rpm, -25 * units.deg) - .add_sample(1000 * units.rpm, -25 * units.deg) - .add_sample(2000 * units.rpm, -30 * units.deg) - .add_sample(3000 * units.rpm, -40 * units.deg) - .add_sample(4000 * units.rpm, -40 * units.deg) - - ignition_module ignition_module( - timing_curve: timing_curve, - rev_limit: 9400 * units.rpm, //43244374 - limiter_duration: 0.05) - ignition_module - .connect_wire(wires.wire1, (0.0 / 4.0) * cycle) - .connect_wire(wires.wire3, (3.0 / 4.0) * cycle) - .connect_wire(wires.wire4, (2.0 / 4.0) * cycle) - .connect_wire(wires.wire2, (1.0 / 4.0) * cycle) - - engine.add_ignition_module(ignition_module) -} - -private node integra_type_r { - alias output __out: - vehicle( - mass: 2400 * units.lb, - drag_coefficient: 0.2, - cross_sectional_area: (66 * units.inch) * (50 * units.inch), - diff_ratio: 3.55, - tire_radius: 10 * units.inch, - rolling_resistance: 300 * units.N - ); -} - -private node integra_type_r_transmission { - alias output __out: - transmission( - max_clutch_torque: 300 * units.lb_ft - ) - .add_gear(3.23) - .add_gear(2.105) - .add_gear(1.458) - .add_gear(1.107) - .add_gear(0.848); -} - -public node main { - set_engine(honda_vtec_i4()) - set_vehicle(integra_type_r()) - set_transmission(integra_type_r_transmission()) -} diff --git a/es/engines/atg-video-1/06_subaru_ej25.mr b/es/engines/atg-video-1/06_subaru_ej25.mr deleted file mode 100644 index 44d2027..0000000 --- a/es/engines/atg-video-1/06_subaru_ej25.mr +++ /dev/null @@ -1,358 +0,0 @@ -import "engine_sim.mr" - -units units() -constants constants() -impulse_response_library ir_lib() -label cycle(2 * 360 * units.deg) - -private node wires { - output wire1: ignition_wire(); - output wire2: ignition_wire(); - output wire3: ignition_wire(); - output wire4: ignition_wire(); -} - -private node ej25_head { - input intake_camshaft; - input exhaust_camshaft; - input chamber_volume: 67 * units.cc; - input intake_runner_volume: 149.6 * units.cc; - input intake_runner_cross_section_area: 1.35 * units.inch * 1.35 * units.inch; - input exhaust_runner_volume: 50.0 * units.cc; - input exhaust_runner_cross_section_area: 1.25 * units.inch * 1.25 * units.inch; - - input flow_attenuation: 1.0; - input lift_scale: 1.0; - input flip_display: false; - alias output __out: head; - - function intake_flow(50 * units.thou) - intake_flow - .add_flow_sample(0 * lift_scale, 0 * flow_attenuation) - .add_flow_sample(50 * lift_scale, 58 * flow_attenuation) - .add_flow_sample(100 * lift_scale, 103 * flow_attenuation) - .add_flow_sample(150 * lift_scale, 156 * flow_attenuation) - .add_flow_sample(200 * lift_scale, 214 * flow_attenuation) - .add_flow_sample(250 * lift_scale, 249 * flow_attenuation) - .add_flow_sample(300 * lift_scale, 268 * flow_attenuation) - .add_flow_sample(350 * lift_scale, 280 * flow_attenuation) - .add_flow_sample(400 * lift_scale, 280 * flow_attenuation) - .add_flow_sample(450 * lift_scale, 281 * flow_attenuation) - - function exhaust_flow(50 * units.thou) - exhaust_flow - .add_flow_sample(0 * lift_scale, 0 * flow_attenuation) - .add_flow_sample(50 * lift_scale, 37 * flow_attenuation) - .add_flow_sample(100 * lift_scale, 72 * flow_attenuation) - .add_flow_sample(150 * lift_scale, 113 * flow_attenuation) - .add_flow_sample(200 * lift_scale, 160 * flow_attenuation) - .add_flow_sample(250 * lift_scale, 196 * flow_attenuation) - .add_flow_sample(300 * lift_scale, 222 * flow_attenuation) - .add_flow_sample(350 * lift_scale, 235 * flow_attenuation) - .add_flow_sample(400 * lift_scale, 245 * flow_attenuation) - .add_flow_sample(450 * lift_scale, 246 * flow_attenuation) - - generic_cylinder_head head( - chamber_volume: chamber_volume, - intake_runner_volume: intake_runner_volume, - intake_runner_cross_section_area: intake_runner_cross_section_area, - exhaust_runner_volume: exhaust_runner_volume, - exhaust_runner_cross_section_area: exhaust_runner_cross_section_area, - - intake_port_flow: intake_flow, - exhaust_port_flow: exhaust_flow, - valvetrain: standard_valvetrain( - intake_camshaft: intake_camshaft, - exhaust_camshaft: exhaust_camshaft - ), - flip_display: flip_display - ) -} - -private node ej25_camshaft { - input lobe_profile; - input intake_lobe_profile: lobe_profile; - input exhaust_lobe_profile: lobe_profile; - input lobe_separation: 114 * units.deg; - input intake_lobe_center: lobe_separation; - input exhaust_lobe_center: lobe_separation; - input advance: 0 * units.deg; - input base_radius: 1.0 * units.inch; - - output intake_cam_0: _intake_cam_0; - output exhaust_cam_0: _exhaust_cam_0; - - output intake_cam_1: _intake_cam_1; - output exhaust_cam_1: _exhaust_cam_1; - - camshaft_parameters params ( - advance: advance, - base_radius: base_radius - ) - - camshaft _intake_cam_0(params, lobe_profile: intake_lobe_profile) - camshaft _exhaust_cam_0(params, lobe_profile: exhaust_lobe_profile) - camshaft _intake_cam_1(params, lobe_profile: intake_lobe_profile) - camshaft _exhaust_cam_1(params, lobe_profile: exhaust_lobe_profile) - - label rot180(180 * units.deg) - label rot360(360 * units.deg) - - _exhaust_cam_0 - .add_lobe(rot360 - exhaust_lobe_center + (0.0 / 4) * cycle) - .add_lobe(rot360 - exhaust_lobe_center + (1.0 / 4) * cycle) - _intake_cam_0 - .add_lobe(rot360 + intake_lobe_center + (0.0 / 4) * cycle) - .add_lobe(rot360 + intake_lobe_center + (1.0 / 4) * cycle) - - _exhaust_cam_1 - .add_lobe(rot360 - exhaust_lobe_center + (2.0 / 4) * cycle) - .add_lobe(rot360 - exhaust_lobe_center + (3.0 / 4) * cycle) - _intake_cam_1 - .add_lobe(rot360 + intake_lobe_center + (2.0 / 4) * cycle) - .add_lobe(rot360 + intake_lobe_center + (3.0 / 4) * cycle) -} - -public node subaru_ej25 { - alias output __out: engine; - - engine engine( - name: "Subaru EJ25", - starter_torque: 70 * units.lb_ft, - starter_speed: 500 * units.rpm, - redline: 6500 * units.rpm, - fuel: fuel( - max_turbulence_effect: 2.5, - max_burning_efficiency: 0.75 - ), - throttle_gamma: 2.0, - hf_gain: 0.01, - noise: 1.0, - jitter: 0.5, - simulation_frequency: 20000 - ) - - wires wires() - - label stroke(79 * units.mm) - label bore(99.5 * units.mm) - label rod_length(5.142 * units.inch) - label rod_mass(535 * units.g) - label compression_height(1.0 * units.inch) - label crank_mass(9.39 * units.kg) - label flywheel_mass(6.8 * units.kg) - label flywheel_radius(6 * units.inch) - - label crank_moment( - disk_moment_of_inertia(mass: crank_mass, radius: stroke / 2) - ) - label flywheel_moment( - disk_moment_of_inertia(mass: flywheel_mass, radius: flywheel_radius) - ) - label other_moment( // Moment from cams, pulleys, etc [estimated] - disk_moment_of_inertia(mass: 10 * units.kg, radius: 6.0 * units.cm) - ) - - crankshaft c0( - throw: stroke / 2, - flywheel_mass: flywheel_mass, - mass: crank_mass, - friction_torque: 1.0 * units.lb_ft, - moment_of_inertia: - crank_moment + flywheel_moment + other_moment, - position_x: 0.0, - position_y: 0.0, - tdc: 180 * units.deg - ) - - rod_journal rj0(angle: 0.0 * units.deg) - rod_journal rj1(angle: 180.0 * units.deg) - rod_journal rj2(angle: 0.0 * units.deg) - rod_journal rj3(angle: 180.0 * units.deg) - c0 - .add_rod_journal(rj0) - .add_rod_journal(rj1) - .add_rod_journal(rj2) - .add_rod_journal(rj3) - - piston_parameters piston_params( - mass: (414 + 152) * units.g, // 414 - piston mass, 152 - pin weight - compression_height: compression_height, - wrist_pin_position: 0.0, - displacement: 0.0 - ) - - connecting_rod_parameters cr_params( - mass: rod_mass, - moment_of_inertia: rod_moment_of_inertia( - mass: rod_mass, - length: rod_length - ), - center_of_mass: 0.0, - length: rod_length - ) - - intake intake( - plenum_volume: 1.325 * units.L, - plenum_cross_section_area: 20.0 * units.cm2, - intake_flow_rate: k_carb(800.0), - runner_flow_rate: k_carb(250.0), - runner_length: 12.0 * units.inch, - idle_flow_rate: k_carb(0.0), - idle_throttle_plate_position: 0.9985, - velocity_decay: 0.5 - ) - - exhaust_system_parameters es_params( - outlet_flow_rate: k_carb(1000.0), - primary_tube_length: 10.0 * units.inch, - primary_flow_rate: k_carb(200.0), - velocity_decay: 1.0, - volume: 100.0 * units.L - ) - - exhaust_system exhaust0( - es_params, - audio_volume: 0.5 * 8, - impulse_response: ir_lib.mild_exhaust_0 - ) - exhaust_system exhaust1( - es_params, - audio_volume: 1.0 * 8, - impulse_response: ir_lib.mild_exhaust_0 - ) - - cylinder_bank_parameters bank_params( - bore: bore, - deck_height: stroke / 2 + rod_length + compression_height - ) - - cylinder_bank b0(bank_params, angle: 90.0 * units.deg) - cylinder_bank b1(bank_params, angle: -90.0 * units.deg) - b0 - .add_cylinder( - piston: piston(piston_params, blowby: k_28inH2O(0.001)), - connecting_rod: connecting_rod(cr_params), - rod_journal: rj0, - intake: intake, - exhaust_system: exhaust0, - ignition_wire: wires.wire1 - ) - .add_cylinder( - piston: piston(piston_params, blowby: k_28inH2O(0.002)), - connecting_rod: connecting_rod(cr_params), - rod_journal: rj3, - intake: intake, - exhaust_system: exhaust0, - ignition_wire: wires.wire3 - ) - .set_cylinder_head( - ej25_head( - flip_display: true, - intake_camshaft: camshaft.intake_cam_0, - exhaust_camshaft: camshaft.exhaust_cam_0) - ) - b1 - .add_cylinder( - piston: piston(piston_params, blowby: k_28inH2O(0.001)), - connecting_rod: connecting_rod(cr_params), - rod_journal: rj1, - intake: intake, - exhaust_system: exhaust1, - ignition_wire: wires.wire2 - ) - .add_cylinder( - piston: piston(piston_params, blowby: k_28inH2O(0.002)), - connecting_rod: connecting_rod(cr_params), - rod_journal: rj2, - intake: intake, - exhaust_system: exhaust1, - ignition_wire: wires.wire4 - ) - .set_cylinder_head( - ej25_head( - intake_camshaft: camshaft.intake_cam_1, - exhaust_camshaft: camshaft.exhaust_cam_1) - ) - - engine - .add_cylinder_bank(b0) - .add_cylinder_bank(b1) - - engine.add_crankshaft(c0) - - harmonic_cam_lobe intake_lobe( - duration_at_50_thou: 232 * units.deg, - gamma: 2.0, - lift: 9.78 * units.mm, - steps: 100 - ) - - harmonic_cam_lobe exhaust_lobe( - duration_at_50_thou: 236 * units.deg, - gamma: 2.0, - lift: 9.60 * units.mm, - steps: 100 - ) - - ej25_camshaft camshaft( - lobe_profile: "N/A", - - intake_lobe_profile: intake_lobe, - exhaust_lobe_profile: exhaust_lobe, - intake_lobe_center: 117 * units.deg, - exhaust_lobe_center: 112 * units.deg, - base_radius: (34.0 / 2) * units.mm - ) - - function timing_curve(1000 * units.rpm) - timing_curve - .add_sample(0000 * units.rpm, 25 * units.deg) - .add_sample(1000 * units.rpm, 25 * units.deg) - .add_sample(2000 * units.rpm, 30 * units.deg) - .add_sample(3000 * units.rpm, 40 * units.deg) - .add_sample(4000 * units.rpm, 40 * units.deg) - - ignition_module ignition_module( - timing_curve: timing_curve, - rev_limit: 6500 * units.rpm, - limiter_duration: 0.08) - ignition_module - .connect_wire(wires.wire1, (0.0 / 4.0) * cycle) - .connect_wire(wires.wire3, (1.0 / 4.0) * cycle) - .connect_wire(wires.wire2, (2.0 / 4.0) * cycle) - .connect_wire(wires.wire4, (3.0 / 4.0) * cycle) - - engine.add_ignition_module(ignition_module) -} - -private node impreza { - alias output __out: - vehicle( - mass: 2700 * units.lb, - drag_coefficient: 0.2, - cross_sectional_area: (66 * units.inch) * (56 * units.inch), - diff_ratio: 3.9, - tire_radius: 10 * units.inch, - rolling_resistance: 300 * units.N - ); -} - -private node impreza_transmission { - alias output __out: - transmission( - max_clutch_torque: 300 * units.lb_ft - ) - .add_gear(3.636) - .add_gear(2.375) - .add_gear(1.761) - .add_gear(1.346) - .add_gear(0.971) - .add_gear(0.756); -} - -public node main { - set_engine(subaru_ej25()) - set_vehicle(impreza()) - set_transmission(impreza_transmission()) -} diff --git a/es/engines/atg-video-1/07_audi_i5.mr b/es/engines/atg-video-1/07_audi_i5.mr deleted file mode 100644 index 4d52587..0000000 --- a/es/engines/atg-video-1/07_audi_i5.mr +++ /dev/null @@ -1,372 +0,0 @@ -import "engine_sim.mr" - -units units() -constants constants() -impulse_response_library ir_lib() - -private node wires { - output wire1: ignition_wire(); - output wire2: ignition_wire(); - output wire3: ignition_wire(); - output wire4: ignition_wire(); - output wire5: ignition_wire(); -} - -label cycle(2 * 360 * units.deg) -public node wb_ignition { - input wires; - input timing_curve; - input rev_limit: 7500 * units.rpm; - alias output __out: - ignition_module( - timing_curve: timing_curve, - rev_limit: rev_limit, - limiter_duration: 0.1 - ) - .connect_wire(wires.wire1, (0.0 / 5.0) * cycle) - .connect_wire(wires.wire2, (1.0 / 5.0) * cycle) - .connect_wire(wires.wire4, (2.0 / 5.0) * cycle) - .connect_wire(wires.wire5, (3.0 / 5.0) * cycle) - .connect_wire(wires.wire3, (4.0 / 5.0) * cycle); -} - -public node i5_camshaft_builder { - input lobe_profile: comp_cams_magnum_11_450_8_lobe_profile(); - input intake_lobe_profile: lobe_profile; - input exhaust_lobe_profile: lobe_profile; - input lobe_separation: 110.0 * units.deg; - input intake_lobe_center: lobe_separation; - input exhaust_lobe_center: lobe_separation; - input advance: 0.0 * units.deg; - input base_radius: 0.75 * units.inch; - - output intake_cam: _intake_cam; - output exhaust_cam: _exhaust_cam; - - camshaft_parameters params( - advance: advance, - base_radius: base_radius - ) - - camshaft _intake_cam(params, lobe_profile: intake_lobe_profile) - camshaft _exhaust_cam(params, lobe_profile: exhaust_lobe_profile) - - label rot(2 * (360 / 5.0) * units.deg) - label rot360(360 * units.deg) - - _exhaust_cam - .add_lobe(rot360 - exhaust_lobe_center) - .add_lobe((rot360 - exhaust_lobe_center) + 1 * rot) - .add_lobe((rot360 - exhaust_lobe_center) + 4 * rot) - .add_lobe((rot360 - exhaust_lobe_center) + 2 * rot) - .add_lobe((rot360 - exhaust_lobe_center) + 3 * rot) - - _intake_cam - .add_lobe(rot360 + intake_lobe_center) - .add_lobe(rot360 + intake_lobe_center + 1 * rot) - .add_lobe(rot360 + intake_lobe_center + 4 * rot) - .add_lobe(rot360 + intake_lobe_center + 2 * rot) - .add_lobe(rot360 + intake_lobe_center + 3 * rot) -} - -private node audi_i5_head { - input intake_camshaft; - input exhaust_camshaft; - input chamber_volume: 50 * units.cc; - input intake_runner_volume: 149.6 * units.cc; - input intake_runner_cross_section_area: 1.9 * units.inch * 1.9 * units.inch; - input exhaust_runner_volume: 50.0 * units.cc; - input exhaust_runner_cross_section_area: 1.25 * units.inch * 1.25 * units.inch; - - input flow_attenuation: 1.0; - input lift_scale: 1.0; - input flip_display: false; - alias output __out: head; - - function intake_flow(50 * units.thou) - intake_flow - .add_flow_sample(0 * lift_scale, 0 * flow_attenuation) - .add_flow_sample(50 * lift_scale, 58 * flow_attenuation) - .add_flow_sample(100 * lift_scale, 103 * flow_attenuation) - .add_flow_sample(150 * lift_scale, 156 * flow_attenuation) - .add_flow_sample(200 * lift_scale, 214 * flow_attenuation) - .add_flow_sample(250 * lift_scale, 249 * flow_attenuation) - .add_flow_sample(300 * lift_scale, 268 * flow_attenuation) - .add_flow_sample(350 * lift_scale, 280 * flow_attenuation) - .add_flow_sample(400 * lift_scale, 280 * flow_attenuation) - .add_flow_sample(450 * lift_scale, 281 * flow_attenuation) - - function exhaust_flow(50 * units.thou) - exhaust_flow - .add_flow_sample(0 * lift_scale, 0 * flow_attenuation) - .add_flow_sample(50 * lift_scale, 37 * flow_attenuation) - .add_flow_sample(100 * lift_scale, 72 * flow_attenuation) - .add_flow_sample(150 * lift_scale, 113 * flow_attenuation) - .add_flow_sample(200 * lift_scale, 160 * flow_attenuation) - .add_flow_sample(250 * lift_scale, 196 * flow_attenuation) - .add_flow_sample(300 * lift_scale, 222 * flow_attenuation) - .add_flow_sample(350 * lift_scale, 235 * flow_attenuation) - .add_flow_sample(400 * lift_scale, 245 * flow_attenuation) - .add_flow_sample(450 * lift_scale, 246 * flow_attenuation) - - generic_cylinder_head head( - chamber_volume: chamber_volume, - intake_runner_volume: intake_runner_volume, - intake_runner_cross_section_area: intake_runner_cross_section_area, - exhaust_runner_volume: exhaust_runner_volume, - exhaust_runner_cross_section_area: exhaust_runner_cross_section_area, - - intake_port_flow: intake_flow, - exhaust_port_flow: exhaust_flow, - valvetrain: standard_valvetrain( - intake_camshaft: intake_camshaft, - exhaust_camshaft: exhaust_camshaft - ), - flip_display: flip_display - ) -} - -public node audi_i5_2_2L { - alias output __out: engine; - - wires wires() - - engine engine( - name: "Audi 2.3 inline 5", - starter_torque: 200 * units.lb_ft, - redline: 6000 * units.rpm, - fuel: fuel( - max_turbulence_effect: 2.5, - max_burning_efficiency: 0.75), - hf_gain: 0.01, - noise: 1.0, - jitter: 0.299, - simulation_frequency: 17000 - ) - - label stroke(79.5 * units.mm) - label bore(86.4 * units.mm) - label rod_length(5.142 * units.inch) - label rod_mass(535 * units.g) - label compression_height(32.8 * units.mm) - label crank_mass(9.39 * units.kg) - label flywheel_mass(6.8 * units.kg) - label flywheel_radius(6 * units.inch) - - label crank_moment( - disk_moment_of_inertia(mass: crank_mass, radius: stroke / 2) - ) - label flywheel_moment( - disk_moment_of_inertia(mass: flywheel_mass, radius: flywheel_radius) - ) - label other_moment( // Moment from cams, pulleys, etc [estimated] - disk_moment_of_inertia(mass: 20 * units.kg, radius: 8.0 * units.cm) - ) - - crankshaft c0( - throw: stroke / 2, - flywheel_mass: flywheel_mass, - mass: crank_mass, - friction_torque: 5.0 * units.lb_ft, - moment_of_inertia: - crank_moment + flywheel_moment + other_moment, - position_x: 0.0, - position_y: 0.0, - tdc: constants.pi / 2 - ) - - rod_journal rj0(angle: (0.0 / 5.0) * 360 * units.deg) - rod_journal rj1(angle: (2.0 / 5.0) * 360 * units.deg) - rod_journal rj2(angle: (3.0 / 5.0) * 360 * units.deg) - rod_journal rj3(angle: (4.0 / 5.0) * 360 * units.deg) - rod_journal rj4(angle: (1.0 / 5.0) * 360 * units.deg) - - c0 - .add_rod_journal(rj0) - .add_rod_journal(rj1) - .add_rod_journal(rj2) - .add_rod_journal(rj3) - .add_rod_journal(rj4) - - piston_parameters piston_params( - mass: (414 + 152) * units.g, // 414 - piston mass, 152 - pin weight - blowby: 0, - compression_height: compression_height, - wrist_pin_position: 0 * units.mm, - displacement: 0.0 - ) - - connecting_rod_parameters cr_params( - mass: rod_mass, - moment_of_inertia: rod_moment_of_inertia( - mass: rod_mass, - length: rod_length - ), - center_of_mass: 0.0, - length: rod_length - ) - - cylinder_bank_parameters bank_params( - bore: bore, - deck_height: stroke / 2 + rod_length + compression_height - ) - - intake intake( - plenum_volume: 1.0 * units.L, - plenum_cross_section_area: 10.0 * units.cm2, - intake_flow_rate: k_carb(350.0), - runner_flow_rate: k_carb(175.0), - runner_length: 5.0 * units.inch, - idle_flow_rate: k_carb(0.0), - idle_throttle_plate_position: 0.993 - ) - - exhaust_system_parameters es_params( - outlet_flow_rate: k_carb(500.0), - primary_tube_length: 10.0 * units.inch, - primary_flow_rate: k_carb(100.0), - velocity_decay: 1.0, - volume: 50.0 * units.L - ) - - exhaust_system exhaust0( - es_params, audio_volume: 1.0, impulse_response: ir_lib.mild_exhaust_0) - exhaust_system exhaust1( - es_params, audio_volume: 0.8, impulse_response: ir_lib.mild_exhaust_0) - - cylinder_bank b0(bank_params, angle: 0) - b0 - .add_cylinder( - piston: piston(piston_params, blowby: k_28inH2O(0.2)), - connecting_rod: connecting_rod(cr_params), - rod_journal: rj0, - intake: intake, - exhaust_system: exhaust0, - ignition_wire: wires.wire1, - sound_attenuation: 0.9 - ) - .add_cylinder( - piston: piston(piston_params, blowby: k_28inH2O(0.6)), - connecting_rod: connecting_rod(cr_params), - rod_journal: rj1, - intake: intake, - exhaust_system: exhaust1, - ignition_wire: wires.wire2, - sound_attenuation: 0.8 - ) - .add_cylinder( - piston: piston(piston_params, blowby: k_28inH2O(0.6)), - connecting_rod: connecting_rod(cr_params), - rod_journal: rj2, - intake: intake, - exhaust_system: exhaust0, - ignition_wire: wires.wire3, - sound_attenuation: 0.9 - ) - .add_cylinder( - piston: piston(piston_params, blowby: k_28inH2O(0.4)), - connecting_rod: connecting_rod(cr_params), - rod_journal: rj3, - intake: intake, - exhaust_system: exhaust1, - ignition_wire: wires.wire4, - sound_attenuation: 1.0 - ) - .add_cylinder( - piston: piston(piston_params, blowby: k_28inH2O(0.4)), - connecting_rod: connecting_rod(cr_params), - rod_journal: rj4, - intake: intake, - exhaust_system: exhaust0, - ignition_wire: wires.wire5, - sound_attenuation: 1.1 - ) - - engine - .add_cylinder_bank(b0) - - engine.add_crankshaft(c0) - - harmonic_cam_lobe intake_lobe( - duration_at_50_thou: 210 * units.deg, - gamma: 2.0, - lift: 9.78 * units.mm, - steps: 100 - ) - - harmonic_cam_lobe exhaust_lobe( - duration_at_50_thou: 215 * units.deg, - gamma: 2.0, - lift: 9.60 * units.mm, - steps: 100 - ) - - i5_camshaft_builder camshaft( - lobe_profile: "N/A", - - intake_lobe_profile: intake_lobe, - exhaust_lobe_profile: exhaust_lobe, - intake_lobe_center: 116 * units.deg, - exhaust_lobe_center: 116 * units.deg, - base_radius: (34.0 / 2) * units.mm - ) - - b0.set_cylinder_head ( - audi_i5_head( - chamber_volume: 50 * units.cc, - intake_camshaft: camshaft.intake_cam, - exhaust_camshaft: camshaft.exhaust_cam, - flow_attenuation: 0.9 - ) - ) - - function timing_curve(1000 * units.rpm) - timing_curve - .add_sample(0000 * units.rpm, 12 * units.deg) - .add_sample(1000 * units.rpm, 12 * units.deg) - .add_sample(2000 * units.rpm, 20 * units.deg) - .add_sample(3000 * units.rpm, 26 * units.deg) - .add_sample(4000 * units.rpm, 30 * units.deg) - .add_sample(5000 * units.rpm, 34 * units.deg) - .add_sample(6000 * units.rpm, 38 * units.deg) - .add_sample(7000 * units.rpm, 38 * units.deg) - - engine.add_ignition_module( - wb_ignition( - wires: wires, - timing_curve: timing_curve, - rev_limit: 6500 * units.rpm - ) - ) -} - -private node audi_vehicle { - alias output __out: - vehicle( - mass: 2844 * units.lb, - drag_coefficient: 0.3, - cross_sectional_area: (66 * units.inch) * (50 * units.inch), - diff_ratio: 3.55, - tire_radius: 10 * units.inch, - rolling_resistance: 500 * units.N - ); -} - -private node audi_transmission { - alias output __out: - transmission( - max_clutch_torque: 200 * units.lb_ft - ) - .add_gear(3.417) - .add_gear(2.105) - .add_gear(1.429) - .add_gear(1.088) - .add_gear(0.970) - .add_gear(0.912); -} - -public node main { - set_engine(audi_i5_2_2L()) - set_vehicle(audi_vehicle()) - set_transmission(audi_transmission()) -} diff --git a/es/engines/atg-video-1/08_radial_5.mr b/es/engines/atg-video-1/08_radial_5.mr deleted file mode 100644 index 24a1fae..0000000 --- a/es/engines/atg-video-1/08_radial_5.mr +++ /dev/null @@ -1,301 +0,0 @@ -import "engine_sim.mr" - -import "radial.mr" - -units units() -constants constants() -impulse_response_library ir_lib() - -private node wires { - output wire1: ignition_wire(); - output wire2: ignition_wire(); - output wire3: ignition_wire(); - output wire4: ignition_wire(); - output wire5: ignition_wire(); -} - -label cycle(2 * 360 * units.deg) -public node radial_5_distributor { - input wires; - input timing_curve; - input rev_limit: 5500 * units.rpm; - alias output __out: - ignition_module( - timing_curve: timing_curve, - rev_limit: rev_limit, - limiter_duration: 0.2 - ) - .connect_wire(wires.wire1, (0 / 5.0) * cycle) - .connect_wire(wires.wire3, (1 / 5.0) * cycle) - .connect_wire(wires.wire5, (2 / 5.0) * cycle) - .connect_wire(wires.wire2, (3 / 5.0) * cycle) - .connect_wire(wires.wire4, (4 / 5.0) * cycle); -} - -public node radial_5 { - alias output __out: engine; - - engine engine( - name: "Radial 5", - starter_torque: 150 * units.lb_ft, - starter_speed: 500 * units.rpm, - redline: 3000 * units.rpm, - throttle_gamma: 2.0, - hf_gain: 0.00121, - noise: 0.623, - jitter: 0.042, - simulation_frequency: 12000 - ) - - wires wires() - - label slave_throw(2.9 * units.inch) - label stroke(5.5 * units.inch) - label bore(5 * units.inch) - label rod_length(12 * units.inch) - label compression_height(1.0 * units.inch) - label rod_mass(535 * units.g) - label crank_mass(20.39 * units.kg) - label flywheel_mass(100 * units.kg) - label flywheel_radius(5 * units.inch) - - label crank_moment( - disk_moment_of_inertia(mass: crank_mass, radius: stroke / 2) - ) - label flywheel_moment( - disk_moment_of_inertia(mass: flywheel_mass, radius: flywheel_radius) - ) - label other_moment( // Moment from cams, pulleys, etc [estimated] - disk_moment_of_inertia(mass: 10 * units.kg, radius: 2.0 * units.cm) - ) - - crankshaft c0( - throw: stroke / 2, - flywheel_mass: 10 * units.lb, - mass: 10 * units.lb, - friction_torque: 10.0 * units.lb_ft, - moment_of_inertia: - crank_moment + flywheel_moment + other_moment, - position_x: 0.0, - position_y: 0.0, - tdc: (90 - 0.5 * 45) * units.deg - ) - - rod_journal rj0(angle: 0.0) - c0 - .add_rod_journal(rj0) - - piston_parameters piston_params( - mass: 200 * units.g, - compression_height: compression_height, - wrist_pin_position: 0.0, - displacement: 0.0 - ) - - connecting_rod_parameters cr_params( - mass: 100.0 * units.g, - moment_of_inertia: 0.0015884918028487504, - center_of_mass: 0.0, - length: rod_length - slave_throw - ) - - intake intake( - plenum_volume: 10.5 * units.L, - plenum_cross_section_area: 10.0 * units.cm2, - intake_flow_rate: k_carb(1000.0), - idle_flow_rate: k_carb(0.0), - idle_throttle_plate_position: 0.995, - velocity_decay: 1.0 - ) - - exhaust_system_parameters es_params( - outlet_flow_rate: k_carb(1000.0), - primary_tube_length: 70.0 * units.inch, - primary_flow_rate: k_carb(300.0), - velocity_decay: 0.75, - volume: 10.0 * units.L - ) - - exhaust_system exhaust0( - es_params, - audio_volume: 1.0, - impulse_response: ir_lib.minimal_muffling_01 - ) - - exhaust_system exhaust1( - es_params, - audio_volume: 0.2, - impulse_response: ir_lib.minimal_muffling_01 - ) - - cylinder_bank_parameters bank_params( - bore: bore, - deck_height: stroke / 2 + rod_length + compression_height - ) - - connecting_rod master( - connecting_rod_parameters( - cr_params, - slave_throw: slave_throw, - length: rod_length - ) - ) - - rod_journal sj0(angle: (0 / 5.0) * 360 * units.deg) - rod_journal sj1(angle: (1 / 5.0) * 360 * units.deg) - rod_journal sj2(angle: (2 / 5.0) * 360 * units.deg) - rod_journal sj3(angle: (3 / 5.0) * 360 * units.deg) - rod_journal sj4(angle: (4 / 5.0) * 360 * units.deg) - master - .add_slave_journal(sj0) - .add_slave_journal(sj1) - .add_slave_journal(sj2) - .add_slave_journal(sj3) - .add_slave_journal(sj4) - - cylinder_bank b0(bank_params, angle: (0 / 5.0) * 360 * units.deg) - b0 - .add_cylinder( - piston: piston(piston_params, blowby: k_28inH2O(0.2)), - connecting_rod: master, - rod_journal: rj0, - intake: intake, - exhaust_system: exhaust0, - ignition_wire: wires.wire1 - ) - - cylinder_bank b1(bank_params, angle: (1 / 5.0) * 360 * units.deg) - b1 - .add_cylinder( - piston: piston(piston_params, blowby: k_28inH2O(0.03)), - connecting_rod: connecting_rod(cr_params), - rod_journal: sj1, - intake: intake, - exhaust_system: exhaust0, - ignition_wire: wires.wire5 - ) - - cylinder_bank b2(bank_params, angle: (2 / 5.0) * 360 * units.deg) - b2 - .add_cylinder( - piston: piston(piston_params, blowby: k_28inH2O(0.1)), - connecting_rod: connecting_rod(cr_params), - rod_journal: sj2, - intake: intake, - exhaust_system: exhaust1, - ignition_wire: wires.wire4 - ) - - cylinder_bank b3(bank_params, angle: (3 / 5.0) * 360 * units.deg) - b3 - .add_cylinder( - piston: piston(piston_params, blowby: k_28inH2O(0.1)), - connecting_rod: connecting_rod(cr_params), - rod_journal: sj3, - intake: intake, - exhaust_system: exhaust1, - ignition_wire: wires.wire3 - ) - cylinder_bank b4(bank_params, angle: (4 / 5.0) * 360 * units.deg) - b4 - .add_cylinder( - piston: piston(piston_params, blowby: k_28inH2O(0.5)), - connecting_rod: connecting_rod(cr_params), - rod_journal: sj4, - intake: intake, - exhaust_system: exhaust1, - ignition_wire: wires.wire2 - ) - - engine - .add_cylinder_bank(b0) - .add_cylinder_bank(b1) - .add_cylinder_bank(b2) - .add_cylinder_bank(b3) - .add_cylinder_bank(b4) - - engine.add_crankshaft(c0) - - harmonic_cam_lobe lobe( - duration_at_50_thou: 260 * units.deg, - gamma: 0.9, - lift: 800 * units.thou, - steps: 100 - ) - - b0.set_cylinder_head ( - radial_head( - offset: 0 / 5.0, - lobe_profile: lobe - ) - ) - - b1.set_cylinder_head ( - radial_head( - offset: 2 / 5.0, - lobe_profile: lobe - ) - ) - - b2.set_cylinder_head ( - radial_head( - offset: 4 / 5.0, - lobe_profile: lobe - ) - ) - - b3.set_cylinder_head ( - radial_head( - offset: 1 / 5.0, - lobe_profile: lobe - ) - ) - - b4.set_cylinder_head ( - radial_head( - offset: 3 / 5.0, - lobe_profile: lobe - ) - ) - - function timing_curve(1000 * units.rpm) - timing_curve - .add_sample(0000 * units.rpm, 18 * units.deg) - .add_sample(1000 * units.rpm, 18 * units.deg) - .add_sample(2000 * units.rpm, 30 * units.deg) - .add_sample(3000 * units.rpm, 40 * units.deg) - .add_sample(4000 * units.rpm, 40 * units.deg) - - engine.add_ignition_module( - radial_5_distributor( - wires: wires, - timing_curve: timing_curve, - rev_limit: 3500 * units.rpm - )) -} - -private node propellor { - alias output __out: - vehicle( - mass: 100 * units.lb, - drag_coefficient: 0.5, - cross_sectional_area: (15 * units.inch) * (47 * units.inch), - diff_ratio: 1.0, - tire_radius: 1.0, - rolling_resistance: 300 * units.N - ); -} - -private node direct_drive { - alias output __out: - transmission( - max_clutch_torque: 500 * units.lb_ft - ) - .add_gear(1.0); -} - -public node main { - set_engine(radial_5()) - set_vehicle(propellor()) - set_transmission(direct_drive()) -} diff --git a/es/engines/atg-video-1/radial.mr b/es/engines/atg-video-1/radial.mr deleted file mode 100644 index dd3e2bb..0000000 --- a/es/engines/atg-video-1/radial.mr +++ /dev/null @@ -1,56 +0,0 @@ -import "engine_sim.mr" - -units units() -constants constants() -label cycle(2 * 360 * units.deg) - -public node radial_head { - input offset; - input lobe_profile; - input chamber_volume: 290 * units.cc; - alias output __head: - generic_small_engine_head( - chamber_volume: chamber_volume, - intake_camshaft: camshaft.intake_cam, - exhaust_camshaft: camshaft.exhaust_cam, - flow_attenuation: 2.0, - intake_runner_cross_section_area: 20.0 * units.cm2, - exhaust_runner_cross_section_area: 20.0 * units.cm2 - ); - - radial_camshaft camshaft( - lobe_profile: lobe_profile, - offset: offset - ) -} - -public node radial_camshaft { - input lobe_profile; - input offset; - input intake_lobe_profile: lobe_profile; - input exhaust_lobe_profile: lobe_profile; - input lobe_separation: 114 * units.deg; - input intake_lobe_center: lobe_separation; - input exhaust_lobe_center: lobe_separation; - input advance: 0 * units.deg; - input base_radius: 1.0 * units.inch; - - output intake_cam: _intake_cam; - output exhaust_cam: _exhaust_cam; - - camshaft_parameters params ( - advance: advance, - base_radius: base_radius - ) - - camshaft _intake_cam(params, lobe_profile: intake_lobe_profile) - camshaft _exhaust_cam(params, lobe_profile: exhaust_lobe_profile) - - label rot180(180 * units.deg) - label rot360(360 * units.deg) - - _exhaust_cam - .add_lobe(rot360 - exhaust_lobe_center + offset * cycle) - _intake_cam - .add_lobe(rot360 + intake_lobe_center + offset * cycle) -} diff --git a/es/engines/atg-video-2/01_subaru_ej25_eh.mr b/es/engines/atg-video-2/01_subaru_ej25_eh.mr deleted file mode 100644 index 586ad92..0000000 --- a/es/engines/atg-video-2/01_subaru_ej25_eh.mr +++ /dev/null @@ -1,379 +0,0 @@ -import "engine_sim.mr" - -units units() -constants constants() -impulse_response_library ir_lib() -label cycle(2 * 360 * units.deg) - -private node turbulence_to_flame_speed_ratio { - alias output __out: - function(5.0) - .add_sample(0.0, 1.0 * 3.0) - .add_sample(5.0, 1.0 * 1.5 * 5.0) - .add_sample(10.0, 1.0 * 1.5 * 10.0) - .add_sample(15.0, 1.1 * 1.5 * 15.0) - .add_sample(20.0, 1.25 * 1.5 * 20.0) - .add_sample(25.0, 1.25 * 1.5 * 25.0) - .add_sample(30.0, 1.25 * 1.5 * 30.0) - .add_sample(35.0, 1.25 * 1.5 * 35.0) - .add_sample(40.0, 1.25 * 1.5 * 40.0) - .add_sample(45.0, 1.25 * 1.5 * 45.0); -} - -private node wires { - output wire1: ignition_wire(); - output wire2: ignition_wire(); - output wire3: ignition_wire(); - output wire4: ignition_wire(); -} - -private node ej25_head { - input intake_camshaft; - input exhaust_camshaft; - input chamber_volume: 67 * units.cc; - input intake_runner_volume: 149.6 * units.cc; - input intake_runner_cross_section_area: 1.75 * units.inch * 1.75 * units.inch; - input exhaust_runner_volume: 50.0 * units.cc; - input exhaust_runner_cross_section_area: 1.25 * units.inch * 1.25 * units.inch; - - input flow_attenuation: 1.0; - input lift_scale: 1.0; - input flip_display: false; - alias output __out: head; - - function intake_flow(50 * units.thou) - intake_flow - .add_flow_sample(0 * lift_scale, 0 * flow_attenuation) - .add_flow_sample(50 * lift_scale, 58 * flow_attenuation) - .add_flow_sample(100 * lift_scale, 103 * flow_attenuation) - .add_flow_sample(150 * lift_scale, 156 * flow_attenuation) - .add_flow_sample(200 * lift_scale, 214 * flow_attenuation) - .add_flow_sample(250 * lift_scale, 249 * flow_attenuation) - .add_flow_sample(300 * lift_scale, 268 * flow_attenuation) - .add_flow_sample(350 * lift_scale, 280 * flow_attenuation) - .add_flow_sample(400 * lift_scale, 280 * flow_attenuation) - .add_flow_sample(450 * lift_scale, 281 * flow_attenuation) - - function exhaust_flow(50 * units.thou) - exhaust_flow - .add_flow_sample(0 * lift_scale, 0 * flow_attenuation) - .add_flow_sample(50 * lift_scale, 37 * flow_attenuation) - .add_flow_sample(100 * lift_scale, 72 * flow_attenuation) - .add_flow_sample(150 * lift_scale, 113 * flow_attenuation) - .add_flow_sample(200 * lift_scale, 160 * flow_attenuation) - .add_flow_sample(250 * lift_scale, 196 * flow_attenuation) - .add_flow_sample(300 * lift_scale, 222 * flow_attenuation) - .add_flow_sample(350 * lift_scale, 235 * flow_attenuation) - .add_flow_sample(400 * lift_scale, 245 * flow_attenuation) - .add_flow_sample(450 * lift_scale, 246 * flow_attenuation) - - generic_cylinder_head head( - chamber_volume: chamber_volume, - intake_runner_volume: intake_runner_volume, - intake_runner_cross_section_area: intake_runner_cross_section_area, - exhaust_runner_volume: exhaust_runner_volume, - exhaust_runner_cross_section_area: exhaust_runner_cross_section_area, - - intake_port_flow: intake_flow, - exhaust_port_flow: exhaust_flow, - valvetrain: standard_valvetrain( - intake_camshaft: intake_camshaft, - exhaust_camshaft: exhaust_camshaft - ), - flip_display: flip_display - ) -} - -private node ej25_camshaft { - input lobe_profile; - input intake_lobe_profile: lobe_profile; - input exhaust_lobe_profile: lobe_profile; - input lobe_separation: 114 * units.deg; - input intake_lobe_center: lobe_separation; - input exhaust_lobe_center: lobe_separation; - input advance: 0 * units.deg; - input base_radius: 1.0 * units.inch; - - output intake_cam_0: _intake_cam_0; - output exhaust_cam_0: _exhaust_cam_0; - - output intake_cam_1: _intake_cam_1; - output exhaust_cam_1: _exhaust_cam_1; - - camshaft_parameters params ( - advance: advance, - base_radius: base_radius - ) - - camshaft _intake_cam_0(params, lobe_profile: intake_lobe_profile) - camshaft _exhaust_cam_0(params, lobe_profile: exhaust_lobe_profile) - camshaft _intake_cam_1(params, lobe_profile: intake_lobe_profile) - camshaft _exhaust_cam_1(params, lobe_profile: exhaust_lobe_profile) - - label rot180(180 * units.deg) - label rot360(360 * units.deg) - - _exhaust_cam_0 - .add_lobe(rot360 - exhaust_lobe_center + (0.0 / 4) * cycle) - .add_lobe(rot360 - exhaust_lobe_center + (1.0 / 4) * cycle) - _intake_cam_0 - .add_lobe(rot360 + intake_lobe_center + (0.0 / 4) * cycle) - .add_lobe(rot360 + intake_lobe_center + (1.0 / 4) * cycle) - - _exhaust_cam_1 - .add_lobe(rot360 - exhaust_lobe_center + (2.0 / 4) * cycle) - .add_lobe(rot360 - exhaust_lobe_center + (3.0 / 4) * cycle) - _intake_cam_1 - .add_lobe(rot360 + intake_lobe_center + (2.0 / 4) * cycle) - .add_lobe(rot360 + intake_lobe_center + (3.0 / 4) * cycle) -} - -public node subaru_ej25 { - alias output __out: engine; - - engine engine( - name: "Subaru EJ25", - starter_torque: 70 * units.lb_ft, - starter_speed: 500 * units.rpm, - redline: 6500 * units.rpm, - fuel: fuel( - max_burning_efficiency: 0.9, - turbulence_to_flame_speed_ratio: turbulence_to_flame_speed_ratio() - ), - throttle_gamma: 2.0, - hf_gain: 0.01, - noise: 1.0, - jitter: 0.5, - simulation_frequency: 20000 - ) - - wires wires() - - label stroke(79 * units.mm) - label bore(99.5 * units.mm) - label rod_length(5.142 * units.inch) - label rod_mass(535 * units.g) - label compression_height(1.0 * units.inch) - label crank_mass(9.39 * units.kg) - label flywheel_mass(6.8 * units.kg) - label flywheel_radius(6 * units.inch) - - label crank_moment( - disk_moment_of_inertia(mass: crank_mass, radius: stroke / 2) - ) - label flywheel_moment( - disk_moment_of_inertia(mass: flywheel_mass, radius: flywheel_radius) * 2 - ) - label other_moment( // Moment from cams, pulleys, etc [estimated] - disk_moment_of_inertia(mass: 10 * units.kg, radius: 6.0 * units.cm) - ) - - crankshaft c0( - throw: stroke / 2, - flywheel_mass: flywheel_mass, - mass: crank_mass, - friction_torque: 1.0 * units.lb_ft, - moment_of_inertia: - crank_moment + flywheel_moment + other_moment, - position_x: 0.0, - position_y: 0.0, - tdc: 180 * units.deg - ) - - rod_journal rj0(angle: 0.0 * units.deg) - rod_journal rj1(angle: 180.0 * units.deg) - rod_journal rj2(angle: 0.0 * units.deg) - rod_journal rj3(angle: 180.0 * units.deg) - c0 - .add_rod_journal(rj0) - .add_rod_journal(rj1) - .add_rod_journal(rj2) - .add_rod_journal(rj3) - - piston_parameters piston_params( - mass: (414 + 152) * units.g, // 414 - piston mass, 152 - pin weight - compression_height: compression_height, - wrist_pin_position: 0.0, - displacement: 0.0 - ) - - connecting_rod_parameters cr_params( - mass: rod_mass, - moment_of_inertia: rod_moment_of_inertia( - mass: rod_mass, - length: rod_length - ), - center_of_mass: 0.0, - length: rod_length - ) - - intake intake( - plenum_volume: 1.325 * units.L, - plenum_cross_section_area: 20.0 * units.cm2, - intake_flow_rate: k_carb(400.0), - runner_flow_rate: k_carb(100.0), - runner_length: 12.0 * units.inch, - idle_flow_rate: k_carb(0.0), - idle_throttle_plate_position: 0.9978, - velocity_decay: 1.0 - ) - - exhaust_system_parameters es_params( - outlet_flow_rate: k_carb(1000.0), - primary_tube_length: 40.0 * units.inch, - primary_flow_rate: k_carb(400.0), - velocity_decay: 1.0 - ) - - exhaust_system exhaust0( - es_params, - length: 500 * units.mm, - audio_volume: 0.5 * 0.02, - impulse_response: ir_lib.minimal_muffling_02 - ) - - cylinder_bank_parameters bank_params( - bore: bore, - deck_height: stroke / 2 + rod_length + compression_height - ) - - cylinder_bank b0(bank_params, angle: 90.0 * units.deg) - cylinder_bank b1(bank_params, angle: -90.0 * units.deg) - b0 - .add_cylinder( - piston: piston(piston_params, blowby: k_28inH2O(0.001)), - connecting_rod: connecting_rod(cr_params), - rod_journal: rj0, - intake: intake, - exhaust_system: exhaust0, - ignition_wire: wires.wire1, - primary_length: 2.0 * units.inch, - sound_attenuation: 0.9 - ) - .add_cylinder( - piston: piston(piston_params, blowby: k_28inH2O(0.002)), - connecting_rod: connecting_rod(cr_params), - rod_journal: rj3, - intake: intake, - exhaust_system: exhaust0, - ignition_wire: wires.wire3, - primary_length: 3.0 * units.inch, - sound_attenuation: 1.0 - ) - .set_cylinder_head( - ej25_head( - flip_display: true, - intake_camshaft: camshaft.intake_cam_0, - exhaust_camshaft: camshaft.exhaust_cam_0) - ) - b1 - .add_cylinder( - piston: piston(piston_params, blowby: k_28inH2O(0.001)), - connecting_rod: connecting_rod(cr_params), - rod_journal: rj1, - intake: intake, - exhaust_system: exhaust0, - ignition_wire: wires.wire2, - primary_length: 3.0 * units.inch, - sound_attenuation: 1.1 - ) - .add_cylinder( - piston: piston(piston_params, blowby: k_28inH2O(0.002)), - connecting_rod: connecting_rod(cr_params), - rod_journal: rj2, - intake: intake, - exhaust_system: exhaust0, - ignition_wire: wires.wire4, - primary_length: 5.0 * units.inch, - sound_attenuation: 0.9 - ) - .set_cylinder_head( - ej25_head( - flip_display: false, - intake_camshaft: camshaft.intake_cam_1, - exhaust_camshaft: camshaft.exhaust_cam_1) - ) - - engine - .add_cylinder_bank(b0) - .add_cylinder_bank(b1) - - engine.add_crankshaft(c0) - - harmonic_cam_lobe intake_lobe( - duration_at_50_thou: 232 * units.deg, - gamma: 2.0, - lift: 9.78 * units.mm, - steps: 100 - ) - - harmonic_cam_lobe exhaust_lobe( - duration_at_50_thou: 236 * units.deg, - gamma: 2.0, - lift: 9.60 * units.mm, - steps: 100 - ) - - ej25_camshaft camshaft( - lobe_profile: "N/A", - - intake_lobe_profile: intake_lobe, - exhaust_lobe_profile: exhaust_lobe, - intake_lobe_center: 117 * units.deg, - exhaust_lobe_center: 112 * units.deg, - base_radius: (34.0 / 2) * units.mm - ) - - function timing_curve(1000 * units.rpm) - timing_curve - .add_sample(0000 * units.rpm, 25 * units.deg) - .add_sample(1000 * units.rpm, 25 * units.deg) - .add_sample(2000 * units.rpm, 30 * units.deg) - .add_sample(3000 * units.rpm, 40 * units.deg) - .add_sample(4000 * units.rpm, 40 * units.deg) - - ignition_module ignition_module( - timing_curve: timing_curve, - rev_limit: 6800 * units.rpm, - limiter_duration: 0.16) - ignition_module - .connect_wire(wires.wire1, (0.0 / 4.0) * cycle) - .connect_wire(wires.wire3, (1.0 / 4.0) * cycle) - .connect_wire(wires.wire2, (2.0 / 4.0) * cycle) - .connect_wire(wires.wire4, (3.0 / 4.0) * cycle) - - engine.add_ignition_module(ignition_module) -} - -label car_mass(2700 * units.lb) - -private node impreza { - alias output __out: - vehicle( - mass: 2700 * units.lb, - drag_coefficient: 0.3, - cross_sectional_area: (72 * units.inch) * (56 * units.inch), - diff_ratio: 3.9, - tire_radius: 10 * units.inch, - rolling_resistance: 0.015 * car_mass * 9.81 - ); -} - -private node impreza_transmission { - alias output __out: - transmission( - max_clutch_torque: 300 * units.lb_ft - ) - .add_gear(3.636) - .add_gear(2.375) - .add_gear(1.761) - .add_gear(1.346) - .add_gear(0.971) - .add_gear(0.756); -} - -public node main { - set_engine(subaru_ej25()) - set_vehicle(impreza()) - set_transmission(impreza_transmission()) -} diff --git a/es/engines/atg-video-2/02_subaru_ej25_uh.mr b/es/engines/atg-video-2/02_subaru_ej25_uh.mr deleted file mode 100644 index 934526f..0000000 --- a/es/engines/atg-video-2/02_subaru_ej25_uh.mr +++ /dev/null @@ -1,379 +0,0 @@ -import "engine_sim.mr" - -units units() -constants constants() -impulse_response_library ir_lib() -label cycle(2 * 360 * units.deg) - -private node turbulence_to_flame_speed_ratio { - alias output __out: - function(5.0) - .add_sample(0.0, 1.0 * 3.0) - .add_sample(5.0, 1.0 * 1.5 * 5.0) - .add_sample(10.0, 1.0 * 1.5 * 10.0) - .add_sample(15.0, 1.1 * 1.5 * 15.0) - .add_sample(20.0, 1.25 * 1.5 * 20.0) - .add_sample(25.0, 1.25 * 1.5 * 25.0) - .add_sample(30.0, 1.25 * 1.5 * 30.0) - .add_sample(35.0, 1.25 * 1.5 * 35.0) - .add_sample(40.0, 1.25 * 1.5 * 40.0) - .add_sample(45.0, 1.25 * 1.5 * 45.0); -} - -private node wires { - output wire1: ignition_wire(); - output wire2: ignition_wire(); - output wire3: ignition_wire(); - output wire4: ignition_wire(); -} - -private node ej25_head { - input intake_camshaft; - input exhaust_camshaft; - input chamber_volume: 67 * units.cc; - input intake_runner_volume: 149.6 * units.cc; - input intake_runner_cross_section_area: 1.75 * units.inch * 1.75 * units.inch; - input exhaust_runner_volume: 50.0 * units.cc; - input exhaust_runner_cross_section_area: 1.25 * units.inch * 1.25 * units.inch; - - input flow_attenuation: 1.0; - input lift_scale: 1.0; - input flip_display: false; - alias output __out: head; - - function intake_flow(50 * units.thou) - intake_flow - .add_flow_sample(0 * lift_scale, 0 * flow_attenuation) - .add_flow_sample(50 * lift_scale, 58 * flow_attenuation) - .add_flow_sample(100 * lift_scale, 103 * flow_attenuation) - .add_flow_sample(150 * lift_scale, 156 * flow_attenuation) - .add_flow_sample(200 * lift_scale, 214 * flow_attenuation) - .add_flow_sample(250 * lift_scale, 249 * flow_attenuation) - .add_flow_sample(300 * lift_scale, 268 * flow_attenuation) - .add_flow_sample(350 * lift_scale, 280 * flow_attenuation) - .add_flow_sample(400 * lift_scale, 280 * flow_attenuation) - .add_flow_sample(450 * lift_scale, 281 * flow_attenuation) - - function exhaust_flow(50 * units.thou) - exhaust_flow - .add_flow_sample(0 * lift_scale, 0 * flow_attenuation) - .add_flow_sample(50 * lift_scale, 37 * flow_attenuation) - .add_flow_sample(100 * lift_scale, 72 * flow_attenuation) - .add_flow_sample(150 * lift_scale, 113 * flow_attenuation) - .add_flow_sample(200 * lift_scale, 160 * flow_attenuation) - .add_flow_sample(250 * lift_scale, 196 * flow_attenuation) - .add_flow_sample(300 * lift_scale, 222 * flow_attenuation) - .add_flow_sample(350 * lift_scale, 235 * flow_attenuation) - .add_flow_sample(400 * lift_scale, 245 * flow_attenuation) - .add_flow_sample(450 * lift_scale, 246 * flow_attenuation) - - generic_cylinder_head head( - chamber_volume: chamber_volume, - intake_runner_volume: intake_runner_volume, - intake_runner_cross_section_area: intake_runner_cross_section_area, - exhaust_runner_volume: exhaust_runner_volume, - exhaust_runner_cross_section_area: exhaust_runner_cross_section_area, - - intake_port_flow: intake_flow, - exhaust_port_flow: exhaust_flow, - valvetrain: standard_valvetrain( - intake_camshaft: intake_camshaft, - exhaust_camshaft: exhaust_camshaft - ), - flip_display: flip_display - ) -} - -private node ej25_camshaft { - input lobe_profile; - input intake_lobe_profile: lobe_profile; - input exhaust_lobe_profile: lobe_profile; - input lobe_separation: 114 * units.deg; - input intake_lobe_center: lobe_separation; - input exhaust_lobe_center: lobe_separation; - input advance: 0 * units.deg; - input base_radius: 1.0 * units.inch; - - output intake_cam_0: _intake_cam_0; - output exhaust_cam_0: _exhaust_cam_0; - - output intake_cam_1: _intake_cam_1; - output exhaust_cam_1: _exhaust_cam_1; - - camshaft_parameters params ( - advance: advance, - base_radius: base_radius - ) - - camshaft _intake_cam_0(params, lobe_profile: intake_lobe_profile) - camshaft _exhaust_cam_0(params, lobe_profile: exhaust_lobe_profile) - camshaft _intake_cam_1(params, lobe_profile: intake_lobe_profile) - camshaft _exhaust_cam_1(params, lobe_profile: exhaust_lobe_profile) - - label rot180(180 * units.deg) - label rot360(360 * units.deg) - - _exhaust_cam_0 - .add_lobe(rot360 - exhaust_lobe_center + (0.0 / 4) * cycle) - .add_lobe(rot360 - exhaust_lobe_center + (1.0 / 4) * cycle) - _intake_cam_0 - .add_lobe(rot360 + intake_lobe_center + (0.0 / 4) * cycle) - .add_lobe(rot360 + intake_lobe_center + (1.0 / 4) * cycle) - - _exhaust_cam_1 - .add_lobe(rot360 - exhaust_lobe_center + (2.0 / 4) * cycle) - .add_lobe(rot360 - exhaust_lobe_center + (3.0 / 4) * cycle) - _intake_cam_1 - .add_lobe(rot360 + intake_lobe_center + (2.0 / 4) * cycle) - .add_lobe(rot360 + intake_lobe_center + (3.0 / 4) * cycle) -} - -public node subaru_ej25 { - alias output __out: engine; - - engine engine( - name: "Subaru EJ25", - starter_torque: 70 * units.lb_ft, - starter_speed: 500 * units.rpm, - redline: 6500 * units.rpm, - fuel: fuel( - max_burning_efficiency: 0.9, - turbulence_to_flame_speed_ratio: turbulence_to_flame_speed_ratio() - ), - throttle_gamma: 2.0, - hf_gain: 0.01, - noise: 1.0, - jitter: 0.5, - simulation_frequency: 20000 - ) - - wires wires() - - label stroke(79 * units.mm) - label bore(99.5 * units.mm) - label rod_length(5.142 * units.inch) - label rod_mass(535 * units.g) - label compression_height(1.0 * units.inch) - label crank_mass(9.39 * units.kg) - label flywheel_mass(6.8 * units.kg) - label flywheel_radius(6 * units.inch) - - label crank_moment( - disk_moment_of_inertia(mass: crank_mass, radius: stroke / 2) - ) - label flywheel_moment( - disk_moment_of_inertia(mass: flywheel_mass, radius: flywheel_radius) * 2 - ) - label other_moment( // Moment from cams, pulleys, etc [estimated] - disk_moment_of_inertia(mass: 10 * units.kg, radius: 6.0 * units.cm) - ) - - crankshaft c0( - throw: stroke / 2, - flywheel_mass: flywheel_mass, - mass: crank_mass, - friction_torque: 1.0 * units.lb_ft, - moment_of_inertia: - crank_moment + flywheel_moment + other_moment, - position_x: 0.0, - position_y: 0.0, - tdc: 180 * units.deg - ) - - rod_journal rj0(angle: 0.0 * units.deg) - rod_journal rj1(angle: 180.0 * units.deg) - rod_journal rj2(angle: 0.0 * units.deg) - rod_journal rj3(angle: 180.0 * units.deg) - c0 - .add_rod_journal(rj0) - .add_rod_journal(rj1) - .add_rod_journal(rj2) - .add_rod_journal(rj3) - - piston_parameters piston_params( - mass: (414 + 152) * units.g, // 414 - piston mass, 152 - pin weight - compression_height: compression_height, - wrist_pin_position: 0.0, - displacement: 0.0 - ) - - connecting_rod_parameters cr_params( - mass: rod_mass, - moment_of_inertia: rod_moment_of_inertia( - mass: rod_mass, - length: rod_length - ), - center_of_mass: 0.0, - length: rod_length - ) - - intake intake( - plenum_volume: 1.325 * units.L, - plenum_cross_section_area: 20.0 * units.cm2, - intake_flow_rate: k_carb(400.0), - runner_flow_rate: k_carb(100.0), - runner_length: 12.0 * units.inch, - idle_flow_rate: k_carb(0.0), - idle_throttle_plate_position: 0.9978, - velocity_decay: 1.0 - ) - - exhaust_system_parameters es_params( - outlet_flow_rate: k_carb(1000.0), - primary_tube_length: 24.0 * units.inch, - primary_flow_rate: k_carb(400.0), - velocity_decay: 1.0 - ) - - exhaust_system exhaust0( - es_params, - length: 500 * units.mm, - audio_volume: 0.5 * 0.02, - impulse_response: ir_lib.minimal_muffling_02 - ) - - cylinder_bank_parameters bank_params( - bore: bore, - deck_height: stroke / 2 + rod_length + compression_height - ) - - cylinder_bank b0(bank_params, angle: 90.0 * units.deg) - cylinder_bank b1(bank_params, angle: -90.0 * units.deg) - b0 - .add_cylinder( - piston: piston(piston_params, blowby: k_28inH2O(0.001)), - connecting_rod: connecting_rod(cr_params), - rod_journal: rj0, - intake: intake, - exhaust_system: exhaust0, - ignition_wire: wires.wire1, - primary_length: 2.0 * units.inch, - sound_attenuation: 0.9 - ) - .add_cylinder( - piston: piston(piston_params, blowby: k_28inH2O(0.002)), - connecting_rod: connecting_rod(cr_params), - rod_journal: rj3, - intake: intake, - exhaust_system: exhaust0, - ignition_wire: wires.wire3, - primary_length: 3.0 * units.inch, - sound_attenuation: 1.0 - ) - .set_cylinder_head( - ej25_head( - flip_display: true, - intake_camshaft: camshaft.intake_cam_0, - exhaust_camshaft: camshaft.exhaust_cam_0) - ) - b1 - .add_cylinder( - piston: piston(piston_params, blowby: k_28inH2O(0.001)), - connecting_rod: connecting_rod(cr_params), - rod_journal: rj1, - intake: intake, - exhaust_system: exhaust0, - ignition_wire: wires.wire2, - primary_length: 500 * units.mm, - sound_attenuation: 1.1 - ) - .add_cylinder( - piston: piston(piston_params, blowby: k_28inH2O(0.002)), - connecting_rod: connecting_rod(cr_params), - rod_journal: rj2, - intake: intake, - exhaust_system: exhaust0, - ignition_wire: wires.wire4, - primary_length: 550 * units.mm, - sound_attenuation: 0.9 - ) - .set_cylinder_head( - ej25_head( - flip_display: false, - intake_camshaft: camshaft.intake_cam_1, - exhaust_camshaft: camshaft.exhaust_cam_1) - ) - - engine - .add_cylinder_bank(b0) - .add_cylinder_bank(b1) - - engine.add_crankshaft(c0) - - harmonic_cam_lobe intake_lobe( - duration_at_50_thou: 232 * units.deg, - gamma: 2.0, - lift: 9.78 * units.mm, - steps: 100 - ) - - harmonic_cam_lobe exhaust_lobe( - duration_at_50_thou: 236 * units.deg, - gamma: 2.0, - lift: 9.60 * units.mm, - steps: 100 - ) - - ej25_camshaft camshaft( - lobe_profile: "N/A", - - intake_lobe_profile: intake_lobe, - exhaust_lobe_profile: exhaust_lobe, - intake_lobe_center: 117 * units.deg, - exhaust_lobe_center: 112 * units.deg, - base_radius: (34.0 / 2) * units.mm - ) - - function timing_curve(1000 * units.rpm) - timing_curve - .add_sample(0000 * units.rpm, 25 * units.deg) - .add_sample(1000 * units.rpm, 25 * units.deg) - .add_sample(2000 * units.rpm, 30 * units.deg) - .add_sample(3000 * units.rpm, 40 * units.deg) - .add_sample(4000 * units.rpm, 40 * units.deg) - - ignition_module ignition_module( - timing_curve: timing_curve, - rev_limit: 6800 * units.rpm, - limiter_duration: 0.16) - ignition_module - .connect_wire(wires.wire1, (0.0 / 4.0) * cycle) - .connect_wire(wires.wire3, (1.0 / 4.0) * cycle) - .connect_wire(wires.wire2, (2.0 / 4.0) * cycle) - .connect_wire(wires.wire4, (3.0 / 4.0) * cycle) - - engine.add_ignition_module(ignition_module) -} - -label car_mass(2700 * units.lb) - -private node impreza { - alias output __out: - vehicle( - mass: car_mass, - drag_coefficient: 0.3, - cross_sectional_area: (72 * units.inch) * (56 * units.inch), - diff_ratio: 3.9, - tire_radius: 10 * units.inch, - rolling_resistance: 0.015 * car_mass * 9.81 - ); -} - -private node impreza_transmission { - alias output __out: - transmission( - max_clutch_torque: 300 * units.lb_ft - ) - .add_gear(3.636) - .add_gear(2.375) - .add_gear(1.761) - .add_gear(1.346) - .add_gear(0.971) - .add_gear(0.756); -} - -public node main { - set_engine(subaru_ej25()) - set_vehicle(impreza()) - set_transmission(impreza_transmission()) -} diff --git a/es/engines/atg-video-2/03_2jz.mr b/es/engines/atg-video-2/03_2jz.mr deleted file mode 100644 index c7394c2..0000000 --- a/es/engines/atg-video-2/03_2jz.mr +++ /dev/null @@ -1,402 +0,0 @@ -import "engine_sim.mr" - -units units() -constants constants() -impulse_response_library ir_lib() - -private node wires { - output wire1: ignition_wire(); - output wire2: ignition_wire(); - output wire3: ignition_wire(); - output wire4: ignition_wire(); - output wire5: ignition_wire(); - output wire6: ignition_wire(); -} - -label cycle(2 * 360 * units.deg) -public node wb_ignition { - input wires; - input timing_curve; - input rev_limit: 7500 * units.rpm; - alias output __out: - ignition_module( - timing_curve: timing_curve, - rev_limit: rev_limit, - limiter_duration: 0.1 - ) - .connect_wire(wires.wire1, (0.0 / 6.0) * cycle) - .connect_wire(wires.wire5, (1.0 / 6.0) * cycle) - .connect_wire(wires.wire3, (2.0 / 6.0) * cycle) - .connect_wire(wires.wire6, (3.0 / 6.0) * cycle) - .connect_wire(wires.wire2, (4.0 / 6.0) * cycle) - .connect_wire(wires.wire4, (5.0 / 6.0) * cycle); -} - -public node t2jz_camshaft_builder { - input lobe_profile: comp_cams_magnum_11_450_8_lobe_profile(); - input intake_lobe_profile: lobe_profile; - input exhaust_lobe_profile: lobe_profile; - input lobe_separation: 110.0 * units.deg; - input intake_lobe_center: lobe_separation; - input exhaust_lobe_center: lobe_separation; - input advance: 0.0 * units.deg; - input base_radius: 0.75 * units.inch; - - output intake_cam: _intake_cam; - output exhaust_cam: _exhaust_cam; - - camshaft_parameters params( - advance: advance, - base_radius: base_radius - ) - - camshaft _intake_cam(params, lobe_profile: intake_lobe_profile) - camshaft _exhaust_cam(params, lobe_profile: exhaust_lobe_profile) - - label rot(2 * (360 / 6.0) * units.deg) - label rot360(360 * units.deg) - - // 1 5 3 6 2 4 - _exhaust_cam - .add_lobe((rot360 - exhaust_lobe_center) + 0 * rot) - .add_lobe((rot360 - exhaust_lobe_center) + 4 * rot) - .add_lobe((rot360 - exhaust_lobe_center) + 2 * rot) - .add_lobe((rot360 - exhaust_lobe_center) + 5 * rot) - .add_lobe((rot360 - exhaust_lobe_center) + 1 * rot) - .add_lobe((rot360 - exhaust_lobe_center) + 3 * rot) - - _intake_cam - .add_lobe(rot360 + intake_lobe_center + 0 * rot) - .add_lobe(rot360 + intake_lobe_center + 4 * rot) - .add_lobe(rot360 + intake_lobe_center + 2 * rot) - .add_lobe(rot360 + intake_lobe_center + 5 * rot) - .add_lobe(rot360 + intake_lobe_center + 1 * rot) - .add_lobe(rot360 + intake_lobe_center + 3 * rot) -} - -private node t2jz_head { - input intake_camshaft; - input exhaust_camshaft; - input chamber_volume: 50 * units.cc; - input intake_runner_volume: 149.6 * units.cc; - input intake_runner_cross_section_area: 1.9 * units.inch * 1.9 * units.inch; - input exhaust_runner_volume: 50.0 * units.cc; - input exhaust_runner_cross_section_area: 1.25 * units.inch * 1.25 * units.inch; - - input flow_attenuation: 1.0; - input lift_scale: 1.0; - input flip_display: false; - alias output __out: head; - - function intake_flow(50 * units.thou) - intake_flow - .add_flow_sample(0 * lift_scale, 0 * flow_attenuation) - .add_flow_sample(50 * lift_scale, 58 * flow_attenuation) - .add_flow_sample(100 * lift_scale, 103 * flow_attenuation) - .add_flow_sample(150 * lift_scale, 156 * flow_attenuation) - .add_flow_sample(200 * lift_scale, 214 * flow_attenuation) - .add_flow_sample(250 * lift_scale, 249 * flow_attenuation) - .add_flow_sample(300 * lift_scale, 268 * flow_attenuation) - .add_flow_sample(350 * lift_scale, 280 * flow_attenuation) - .add_flow_sample(400 * lift_scale, 280 * flow_attenuation) - .add_flow_sample(450 * lift_scale, 281 * flow_attenuation) - - function exhaust_flow(50 * units.thou) - exhaust_flow - .add_flow_sample(0 * lift_scale, 0 * flow_attenuation) - .add_flow_sample(50 * lift_scale, 37 * flow_attenuation) - .add_flow_sample(100 * lift_scale, 72 * flow_attenuation) - .add_flow_sample(150 * lift_scale, 113 * flow_attenuation) - .add_flow_sample(200 * lift_scale, 160 * flow_attenuation) - .add_flow_sample(250 * lift_scale, 196 * flow_attenuation) - .add_flow_sample(300 * lift_scale, 222 * flow_attenuation) - .add_flow_sample(350 * lift_scale, 235 * flow_attenuation) - .add_flow_sample(400 * lift_scale, 245 * flow_attenuation) - .add_flow_sample(450 * lift_scale, 246 * flow_attenuation) - - generic_cylinder_head head( - chamber_volume: chamber_volume, - intake_runner_volume: intake_runner_volume, - intake_runner_cross_section_area: intake_runner_cross_section_area, - exhaust_runner_volume: exhaust_runner_volume, - exhaust_runner_cross_section_area: exhaust_runner_cross_section_area, - - intake_port_flow: intake_flow, - exhaust_port_flow: exhaust_flow, - valvetrain: standard_valvetrain( - intake_camshaft: intake_camshaft, - exhaust_camshaft: exhaust_camshaft - ), - flip_display: flip_display - ) -} - -public node t2jz { - alias output __out: engine; - - wires wires() - - engine engine( - name: "2JZ [I6]", - starter_torque: 200 * units.lb_ft, - redline: 6000 * units.rpm, - fuel: fuel( - max_burning_efficiency: 1.0 - ), - hf_gain: 0.01, - noise: 1.0, - jitter: 0.23, - simulation_frequency: 10000 - ) - - label stroke(86.0 * units.mm) - label bore(86.0 * units.mm) - label rod_length(142 * units.mm) - label rod_mass(500 * units.g) - label compression_height(32.8 * units.mm) - label crank_mass(15 * units.kg) - label flywheel_mass(10 * units.kg) - label flywheel_radius(7 * units.inch) - - label crank_moment( - disk_moment_of_inertia(mass: crank_mass, radius: stroke / 2) - ) - label flywheel_moment( - disk_moment_of_inertia(mass: flywheel_mass, radius: flywheel_radius) - ) - label other_moment( // Moment from cams, pulleys, etc [estimated] - disk_moment_of_inertia(mass: 20 * units.kg, radius: 8.0 * units.cm) - ) - - crankshaft c0( - throw: stroke / 2, - flywheel_mass: flywheel_mass, - mass: crank_mass, - friction_torque: 5.0 * units.lb_ft, - moment_of_inertia: - crank_moment + flywheel_moment + other_moment, - position_x: 0.0, - position_y: 0.0, - tdc: constants.pi / 2 - ) - - // 1 5 3 6 2 4 - rod_journal rj0(angle: 0 * units.deg) - rod_journal rj1(angle: 480 * units.deg) - rod_journal rj2(angle: 240 * units.deg) - rod_journal rj3(angle: 600 * units.deg) - rod_journal rj4(angle: 120 * units.deg) - rod_journal rj5(angle: 360 * units.deg) - - c0 - .add_rod_journal(rj0) - .add_rod_journal(rj1) - .add_rod_journal(rj2) - .add_rod_journal(rj3) - .add_rod_journal(rj4) - .add_rod_journal(rj5) - - piston_parameters piston_params( - mass: (200 + 50) * units.g, - blowby: 0, - compression_height: compression_height, - wrist_pin_position: 0 * units.mm, - displacement: 0.0 - ) - - connecting_rod_parameters cr_params( - mass: rod_mass, - moment_of_inertia: rod_moment_of_inertia( - mass: rod_mass, - length: rod_length - ), - center_of_mass: 0.0, - length: rod_length - ) - - cylinder_bank_parameters bank_params( - bore: bore, - deck_height: stroke / 2 + rod_length + compression_height - ) - - intake intake( - plenum_volume: 1.0 * units.L, - plenum_cross_section_area: 10.0 * units.cm2, - intake_flow_rate: k_carb(500.0), - runner_flow_rate: k_carb(200.0), - runner_length: 40.0 * units.inch, - idle_flow_rate: k_carb(0.0), - idle_throttle_plate_position: 0.9965 - ) - - exhaust_system_parameters es_params( - outlet_flow_rate: k_carb(1000.0), - primary_tube_length: 40.0 * units.inch, - primary_flow_rate: k_carb(400.0), - velocity_decay: 1.0 - ) - - exhaust_system exhaust0( - es_params, - length: 100.0 * units.inch, - audio_volume: 0.2, - impulse_response: ir_lib.mild_exhaust_0_reverb) - exhaust_system exhaust1( - es_params, - length: 100.0 * units.inch, - audio_volume: 0.2, - impulse_response: ir_lib.mild_exhaust_0_reverb) - - label spacing(0.5 * units.inch) - - cylinder_bank b0(bank_params, angle: 0) - b0 - .add_cylinder( - piston: piston(piston_params, blowby: k_28inH2O(0.1)), - connecting_rod: connecting_rod(cr_params), - rod_journal: rj0, - intake: intake, - exhaust_system: exhaust0, - ignition_wire: wires.wire1, - primary_length: spacing * 5, - sound_attenuation: 0.9 - ) - .add_cylinder( - piston: piston(piston_params, blowby: k_28inH2O(0.05)), - connecting_rod: connecting_rod(cr_params), - rod_journal: rj1, - intake: intake, - exhaust_system: exhaust0, - ignition_wire: wires.wire2, - primary_length: spacing * 4, - sound_attenuation: 0.95 - ) - .add_cylinder( - piston: piston(piston_params, blowby: k_28inH2O(0.1)), - connecting_rod: connecting_rod(cr_params), - rod_journal: rj2, - intake: intake, - exhaust_system: exhaust0, - ignition_wire: wires.wire3, - primary_length: spacing * 3, - sound_attenuation: 0.9 - ) - .add_cylinder( - piston: piston(piston_params, blowby: k_28inH2O(0.05)), - connecting_rod: connecting_rod(cr_params), - rod_journal: rj3, - intake: intake, - exhaust_system: exhaust1, - ignition_wire: wires.wire4, - primary_length: spacing * 3, - sound_attenuation: 0.97 - ) - .add_cylinder( - piston: piston(piston_params, blowby: k_28inH2O(0.1)), - connecting_rod: connecting_rod(cr_params), - rod_journal: rj4, - intake: intake, - exhaust_system: exhaust1, - ignition_wire: wires.wire5, - primary_length: spacing * 4, - sound_attenuation: 0.98 - ) - .add_cylinder( - piston: piston(piston_params, blowby: k_28inH2O(0.05)), - connecting_rod: connecting_rod(cr_params), - rod_journal: rj5, - intake: intake, - exhaust_system: exhaust1, - ignition_wire: wires.wire6, - primary_length: spacing * 5, - sound_attenuation: 0.93 - ) - - engine - .add_cylinder_bank(b0) - - engine.add_crankshaft(c0) - - harmonic_cam_lobe intake_lobe( - duration_at_50_thou: 220 * units.deg, - gamma: 1.1, - lift: 9.78 * units.mm, - steps: 100 - ) - - harmonic_cam_lobe exhaust_lobe( - duration_at_50_thou: 220 * units.deg, - gamma: 1.1, - lift: 9.60 * units.mm, - steps: 100 - ) - - t2jz_camshaft_builder camshaft( - lobe_profile: "N/A", - - intake_lobe_profile: intake_lobe, - exhaust_lobe_profile: exhaust_lobe, - intake_lobe_center: 116 * units.deg, - exhaust_lobe_center: 116 * units.deg, - base_radius: (34.0 / 2) * units.mm - ) - - b0.set_cylinder_head ( - t2jz_head( - chamber_volume: 50 * units.cc, - intake_camshaft: camshaft.intake_cam, - exhaust_camshaft: camshaft.exhaust_cam, - flow_attenuation: 0.9 - ) - ) - - function timing_curve(1000 * units.rpm) - timing_curve - .add_sample(0000 * units.rpm, 12 * units.deg) - .add_sample(1000 * units.rpm, 12 * units.deg) - .add_sample(2000 * units.rpm, 20 * units.deg) - .add_sample(3000 * units.rpm, 26 * units.deg) - .add_sample(4000 * units.rpm, 30 * units.deg) - .add_sample(5000 * units.rpm, 34 * units.deg) - .add_sample(6000 * units.rpm, 38 * units.deg) - .add_sample(7000 * units.rpm, 38 * units.deg) - - engine.add_ignition_module( - wb_ignition( - wires: wires, - timing_curve: timing_curve, - rev_limit: 6500 * units.rpm - ) - ) -} - -private node supra_vehicle { - alias output __out: - vehicle( - mass: 3400 * units.lb, - drag_coefficient: 0.4, - cross_sectional_area: (66 * units.inch) * (50 * units.inch), - diff_ratio: 3.15, - tire_radius: 10 * units.inch, - rolling_resistance: 500 * units.N - ); -} - -private node supra_transmission { - alias output __out: - transmission( - max_clutch_torque: 500 * units.lb_ft - ) - .add_gear(5.25) - .add_gear(3.36) - .add_gear(2.17) - .add_gear(1.72) - .add_gear(1.32) - .add_gear(1.0); -} - -public node main { - set_engine(t2jz()) - set_vehicle(supra_vehicle()) - set_transmission(supra_transmission()) -} diff --git a/es/engines/atg-video-2/04_60_degree_v6.mr b/es/engines/atg-video-2/04_60_degree_v6.mr deleted file mode 100644 index 8e05143..0000000 --- a/es/engines/atg-video-2/04_60_degree_v6.mr +++ /dev/null @@ -1,394 +0,0 @@ -import "engine_sim.mr" - -units units() -constants constants() -impulse_response_library ir_lib() -label cycle(2 * 360 * units.deg) - -private node wires { - output wire1: ignition_wire(); - output wire2: ignition_wire(); - output wire3: ignition_wire(); - output wire4: ignition_wire(); - output wire5: ignition_wire(); - output wire6: ignition_wire(); -} - -private node v6_60_head { - input intake_camshaft; - input exhaust_camshaft; - input chamber_volume: 67 * units.cc; - input intake_runner_volume: 149.6 * units.cc; - input intake_runner_cross_section_area: 1.35 * units.inch * 1.35 * units.inch; - input exhaust_runner_volume: 50.0 * units.cc; - input exhaust_runner_cross_section_area: 2.0 * units.inch * 2.0 * units.inch; - - input flow_attenuation: 1.0; - input lift_scale: 1.0; - input flip_display: false; - alias output __out: head; - - function intake_flow(50 * units.thou) - intake_flow - .add_flow_sample(0 * lift_scale, 0 * flow_attenuation) - .add_flow_sample(50 * lift_scale, 58 * flow_attenuation) - .add_flow_sample(100 * lift_scale, 103 * flow_attenuation) - .add_flow_sample(150 * lift_scale, 156 * flow_attenuation) - .add_flow_sample(200 * lift_scale, 214 * flow_attenuation) - .add_flow_sample(250 * lift_scale, 249 * flow_attenuation) - .add_flow_sample(300 * lift_scale, 268 * flow_attenuation) - .add_flow_sample(350 * lift_scale, 280 * flow_attenuation) - .add_flow_sample(400 * lift_scale, 280 * flow_attenuation) - .add_flow_sample(450 * lift_scale, 281 * flow_attenuation) - - function exhaust_flow(50 * units.thou) - exhaust_flow - .add_flow_sample(0 * lift_scale, 0 * flow_attenuation) - .add_flow_sample(50 * lift_scale, 37 * flow_attenuation) - .add_flow_sample(100 * lift_scale, 72 * flow_attenuation) - .add_flow_sample(150 * lift_scale, 113 * flow_attenuation) - .add_flow_sample(200 * lift_scale, 160 * flow_attenuation) - .add_flow_sample(250 * lift_scale, 196 * flow_attenuation) - .add_flow_sample(300 * lift_scale, 222 * flow_attenuation) - .add_flow_sample(350 * lift_scale, 235 * flow_attenuation) - .add_flow_sample(400 * lift_scale, 245 * flow_attenuation) - .add_flow_sample(450 * lift_scale, 246 * flow_attenuation) - - generic_cylinder_head head( - chamber_volume: chamber_volume, - intake_runner_volume: intake_runner_volume, - intake_runner_cross_section_area: intake_runner_cross_section_area, - exhaust_runner_volume: exhaust_runner_volume, - exhaust_runner_cross_section_area: exhaust_runner_cross_section_area, - - intake_port_flow: intake_flow, - exhaust_port_flow: exhaust_flow, - valvetrain: standard_valvetrain( - intake_camshaft: intake_camshaft, - exhaust_camshaft: exhaust_camshaft - ), - flip_display: flip_display - ) -} - -private node v6_60_camshaft { - input lobe_profile; - input intake_lobe_profile: lobe_profile; - input exhaust_lobe_profile: lobe_profile; - input lobe_separation: 114 * units.deg; - input intake_lobe_center: lobe_separation; - input exhaust_lobe_center: lobe_separation; - input advance: 0 * units.deg; - input base_radius: 0.5 * units.inch; - - output intake_cam_0: _intake_cam_0; - output exhaust_cam_0: _exhaust_cam_0; - - output intake_cam_1: _intake_cam_1; - output exhaust_cam_1: _exhaust_cam_1; - - camshaft_parameters params ( - advance: advance, - base_radius: base_radius - ) - - camshaft _intake_cam_0(params, lobe_profile: intake_lobe_profile) - camshaft _exhaust_cam_0(params, lobe_profile: exhaust_lobe_profile) - camshaft _intake_cam_1(params, lobe_profile: intake_lobe_profile) - camshaft _exhaust_cam_1(params, lobe_profile: exhaust_lobe_profile) - - label rot180(180 * units.deg) - label rot360(360 * units.deg) - - // 1 2 3 4 5 6 - _exhaust_cam_0 - .add_lobe(rot360 - exhaust_lobe_center + 0 * units.deg) - .add_lobe(rot360 - exhaust_lobe_center + 240 * units.deg) - .add_lobe(rot360 - exhaust_lobe_center + 480 * units.deg) - _intake_cam_0 - .add_lobe(rot360 + intake_lobe_center + 0 * units.deg) - .add_lobe(rot360 + intake_lobe_center + 240 * units.deg) - .add_lobe(rot360 + intake_lobe_center + 480 * units.deg) - - _exhaust_cam_1 - .add_lobe(rot360 - exhaust_lobe_center + 120 * units.deg) - .add_lobe(rot360 - exhaust_lobe_center + 360 * units.deg) - .add_lobe(rot360 - exhaust_lobe_center + 600 * units.deg) - _intake_cam_1 - .add_lobe(rot360 + intake_lobe_center + 120 * units.deg) - .add_lobe(rot360 + intake_lobe_center + 360 * units.deg) - .add_lobe(rot360 + intake_lobe_center + 600 * units.deg) -} - -public node v6_60 { - alias output __out: engine; - - engine engine( - name: "Generic 60 deg. V6", - starter_torque: 70 * units.lb_ft, - starter_speed: 500 * units.rpm, - redline: 5500 * units.rpm, - throttle_gamma: 2.0 - ) - - wires wires() - - label stroke(3.48 * units.inch) - label bore(3.5 * units.inch) - label rod_length(5.142 * units.inch) - label rod_mass(535 * units.g) - label compression_height(1.0 * units.inch) - label crank_mass(50 * units.lb) - label flywheel_mass(30 * units.lb) - label flywheel_radius(7 * units.inch) - - label crank_moment( - disk_moment_of_inertia(mass: crank_mass, radius: stroke) - ) - label flywheel_moment( - disk_moment_of_inertia(mass: flywheel_mass, radius: flywheel_radius) - ) - label other_moment( // Moment from cams, pulleys, etc [estimated] - disk_moment_of_inertia(mass: 10 * units.kg, radius: 1.0 * units.cm) - ) - - crankshaft c0( - throw: stroke / 2, - flywheel_mass: flywheel_mass, - mass: crank_mass, - friction_torque: 20.0 * units.lb_ft, - moment_of_inertia: - crank_moment + flywheel_moment + other_moment, - position_x: 0.0, - position_y: 0.0, - tdc: (90 + 30) * units.deg - ) - - rod_journal rj0(angle: 0.0 * units.deg) - rod_journal rj1(angle: (0 + 60) * units.deg) - rod_journal rj2(angle: 240.0 * units.deg) - rod_journal rj3(angle: (240.0 + 60) * units.deg) - rod_journal rj4(angle: 120.0 * units.deg) - rod_journal rj5(angle: (120.0 + 60) * units.deg) - c0 - .add_rod_journal(rj0) - .add_rod_journal(rj1) - .add_rod_journal(rj2) - .add_rod_journal(rj3) - .add_rod_journal(rj4) - .add_rod_journal(rj5) - - piston_parameters piston_params( - mass: (414 + 152) * units.g, // 414 - piston mass, 152 - pin weight - compression_height: compression_height, - wrist_pin_position: 0.0, - displacement: 0.0 - ) - - connecting_rod_parameters cr_params( - mass: rod_mass, - moment_of_inertia: rod_moment_of_inertia( - mass: rod_mass, - length: rod_length - ), - center_of_mass: 0.0, - length: rod_length - ) - - intake intake( - plenum_volume: 1.325 * units.L, - plenum_cross_section_area: 20.0 * units.cm2, - intake_flow_rate: k_carb(400.0), - runner_flow_rate: k_carb(250.0), - runner_length: 4.0 * units.inch, - idle_flow_rate: k_carb(0.0), - idle_throttle_plate_position: 0.994, - velocity_decay: 0.5 - ) - - exhaust_system_parameters es_params( - outlet_flow_rate: k_carb(1000.0), - primary_tube_length: 20.0 * units.inch, - primary_flow_rate: k_carb(500.0), - velocity_decay: 1.0, - length: 100.0 * units.inch - ) - - exhaust_system exhaust0( - es_params, - audio_volume: 1.0, - impulse_response: ir_lib.mild_exhaust_0_reverb - ) - exhaust_system exhaust1( - es_params, - audio_volume: 1.0, - impulse_response: ir_lib.mild_exhaust_0_reverb - ) - - cylinder_bank_parameters bank_params( - bore: bore, - deck_height: stroke / 2 + rod_length + compression_height - ) - - label spacing(5.0 * units.inch) - - cylinder_bank b0(bank_params, angle: 30.0 * units.deg) - cylinder_bank b1(bank_params, angle: -30.0 * units.deg) - b0 - .add_cylinder( - piston: piston(piston_params, blowby: k_28inH2O(0.1)), - connecting_rod: connecting_rod(cr_params), - rod_journal: rj0, - intake: intake, - exhaust_system: exhaust0, - ignition_wire: wires.wire1, - sound_attenuation: 0.9, - primary_length: spacing * 2 - ) - .add_cylinder( - piston: piston(piston_params, blowby: k_28inH2O(0.2)), - connecting_rod: connecting_rod(cr_params), - rod_journal: rj2, - intake: intake, - exhaust_system: exhaust0, - ignition_wire: wires.wire3, - sound_attenuation: 0.95, - primary_length: spacing * 1 - ) - .add_cylinder( - piston: piston(piston_params, blowby: k_28inH2O(0.2)), - connecting_rod: connecting_rod(cr_params), - rod_journal: rj4, - intake: intake, - exhaust_system: exhaust0, - ignition_wire: wires.wire5, - primary_length: spacing * 0 - ) - .set_cylinder_head( - v6_60_head( - flip_display: true, - intake_camshaft: camshaft.intake_cam_0, - exhaust_camshaft: camshaft.exhaust_cam_0) - ) - b1 - .add_cylinder( - piston: piston(piston_params, blowby: k_28inH2O(0.1)), - connecting_rod: connecting_rod(cr_params), - rod_journal: rj1, - intake: intake, - exhaust_system: exhaust1, - ignition_wire: wires.wire2, - sound_attenuation: 0.95, - primary_length: spacing * 2 - ) - .add_cylinder( - piston: piston(piston_params, blowby: k_28inH2O(0.2)), - connecting_rod: connecting_rod(cr_params), - rod_journal: rj3, - intake: intake, - exhaust_system: exhaust1, - ignition_wire: wires.wire4, - sound_attenuation: 0.9, - primary_length: spacing * 1 - ) - .add_cylinder( - piston: piston(piston_params, blowby: k_28inH2O(0.2)), - connecting_rod: connecting_rod(cr_params), - rod_journal: rj5, - intake: intake, - exhaust_system: exhaust1, - ignition_wire: wires.wire6, - sound_attenuation: 1.0, - primary_length: spacing * 0 - ) - .set_cylinder_head( - v6_60_head( - intake_camshaft: camshaft.intake_cam_1, - exhaust_camshaft: camshaft.exhaust_cam_1, - flip_display: false) - ) - - engine - .add_cylinder_bank(b0) - .add_cylinder_bank(b1) - - engine.add_crankshaft(c0) - - harmonic_cam_lobe intake_lobe( - duration_at_50_thou: 222 * units.deg, - gamma: 1.0, - lift: 400 * units.thou, - steps: 100 - ) - - harmonic_cam_lobe exhaust_lobe( - duration_at_50_thou: 226 * units.deg, - gamma: 1.0, - lift: 300 * units.thou, - steps: 100 - ) - - v6_60_camshaft camshaft( - lobe_profile: "N/A", - - intake_lobe_profile: intake_lobe, - exhaust_lobe_profile: exhaust_lobe, - intake_lobe_center: 117 * units.deg, - exhaust_lobe_center: 112 * units.deg, - base_radius: 0.75 * units.inch - ) - - function timing_curve(1000 * units.rpm) - timing_curve - .add_sample(0000 * units.rpm, 12 * units.deg) - .add_sample(1000 * units.rpm, 20 * units.deg) - .add_sample(2000 * units.rpm, 25 * units.deg) - .add_sample(3000 * units.rpm, 30 * units.deg) - .add_sample(4000 * units.rpm, 30 * units.deg) - - ignition_module ignition_module( - timing_curve: timing_curve, - rev_limit: 5600 * units.rpm, - limiter_duration: 0.2) - ignition_module - .connect_wire(wires.wire1, 0 * units.deg) - .connect_wire(wires.wire2, 120 * units.deg) - .connect_wire(wires.wire3, 240 * units.deg) - .connect_wire(wires.wire4, 360 * units.deg) - .connect_wire(wires.wire5, 480 * units.deg) - .connect_wire(wires.wire6, 600 * units.deg) - - engine.add_ignition_module(ignition_module) -} - -label car_mass(2700 * units.lb) -private node random_car { - alias output __out: - vehicle( - mass: car_mass, - drag_coefficient: 0.3, - cross_sectional_area: (72 * units.inch) * (56 * units.inch), - diff_ratio: 3.9, - tire_radius: 10 * units.inch, - rolling_resistance: 0.015 * car_mass * 9.81 - ); -} - -private node random_transmission { - alias output __out: - transmission( - max_clutch_torque: 300 * units.lb_ft - ) - .add_gear(3.636) - .add_gear(2.375) - .add_gear(1.761) - .add_gear(1.346) - .add_gear(0.971) - .add_gear(0.756); -} - -public node main { - set_engine(v6_60()) - set_vehicle(random_car()) - set_transmission(random_transmission()) -} diff --git a/es/engines/atg-video-2/05_odd_fire_v6.mr b/es/engines/atg-video-2/05_odd_fire_v6.mr deleted file mode 100644 index e189fd4..0000000 --- a/es/engines/atg-video-2/05_odd_fire_v6.mr +++ /dev/null @@ -1,394 +0,0 @@ -import "engine_sim.mr" - -units units() -constants constants() -impulse_response_library ir_lib() -label cycle(2 * 360 * units.deg) - -private node wires { - output wire1: ignition_wire(); - output wire2: ignition_wire(); - output wire3: ignition_wire(); - output wire4: ignition_wire(); - output wire5: ignition_wire(); - output wire6: ignition_wire(); -} - -private node odd_fire_v6_head { - input intake_camshaft; - input exhaust_camshaft; - input chamber_volume: 67 * units.cc; - input intake_runner_volume: 149.6 * units.cc; - input intake_runner_cross_section_area: 1.35 * units.inch * 1.35 * units.inch; - input exhaust_runner_volume: 50.0 * units.cc; - input exhaust_runner_cross_section_area: 2.0 * units.inch * 2.0 * units.inch; - - input flow_attenuation: 1.0; - input lift_scale: 1.0; - input flip_display: false; - alias output __out: head; - - function intake_flow(50 * units.thou) - intake_flow - .add_flow_sample(0 * lift_scale, 0 * flow_attenuation) - .add_flow_sample(50 * lift_scale, 58 * flow_attenuation) - .add_flow_sample(100 * lift_scale, 103 * flow_attenuation) - .add_flow_sample(150 * lift_scale, 156 * flow_attenuation) - .add_flow_sample(200 * lift_scale, 214 * flow_attenuation) - .add_flow_sample(250 * lift_scale, 249 * flow_attenuation) - .add_flow_sample(300 * lift_scale, 268 * flow_attenuation) - .add_flow_sample(350 * lift_scale, 280 * flow_attenuation) - .add_flow_sample(400 * lift_scale, 280 * flow_attenuation) - .add_flow_sample(450 * lift_scale, 281 * flow_attenuation) - - function exhaust_flow(50 * units.thou) - exhaust_flow - .add_flow_sample(0 * lift_scale, 0 * flow_attenuation) - .add_flow_sample(50 * lift_scale, 37 * flow_attenuation) - .add_flow_sample(100 * lift_scale, 72 * flow_attenuation) - .add_flow_sample(150 * lift_scale, 113 * flow_attenuation) - .add_flow_sample(200 * lift_scale, 160 * flow_attenuation) - .add_flow_sample(250 * lift_scale, 196 * flow_attenuation) - .add_flow_sample(300 * lift_scale, 222 * flow_attenuation) - .add_flow_sample(350 * lift_scale, 235 * flow_attenuation) - .add_flow_sample(400 * lift_scale, 245 * flow_attenuation) - .add_flow_sample(450 * lift_scale, 246 * flow_attenuation) - - generic_cylinder_head head( - chamber_volume: chamber_volume, - intake_runner_volume: intake_runner_volume, - intake_runner_cross_section_area: intake_runner_cross_section_area, - exhaust_runner_volume: exhaust_runner_volume, - exhaust_runner_cross_section_area: exhaust_runner_cross_section_area, - - intake_port_flow: intake_flow, - exhaust_port_flow: exhaust_flow, - valvetrain: standard_valvetrain( - intake_camshaft: intake_camshaft, - exhaust_camshaft: exhaust_camshaft - ), - flip_display: flip_display - ) -} - -private node odd_fire_v6_camshaft { - input lobe_profile; - input intake_lobe_profile: lobe_profile; - input exhaust_lobe_profile: lobe_profile; - input lobe_separation: 114 * units.deg; - input intake_lobe_center: lobe_separation; - input exhaust_lobe_center: lobe_separation; - input advance: 0 * units.deg; - input base_radius: 0.5 * units.inch; - - output intake_cam_0: _intake_cam_0; - output exhaust_cam_0: _exhaust_cam_0; - - output intake_cam_1: _intake_cam_1; - output exhaust_cam_1: _exhaust_cam_1; - - camshaft_parameters params ( - advance: advance, - base_radius: base_radius - ) - - camshaft _intake_cam_0(params, lobe_profile: intake_lobe_profile) - camshaft _exhaust_cam_0(params, lobe_profile: exhaust_lobe_profile) - camshaft _intake_cam_1(params, lobe_profile: intake_lobe_profile) - camshaft _exhaust_cam_1(params, lobe_profile: exhaust_lobe_profile) - - label rot180(180 * units.deg) - label rot360(360 * units.deg) - - // 1 6 5 4 3 2 - _exhaust_cam_0 - .add_lobe(rot360 - exhaust_lobe_center + 0 * units.deg) - .add_lobe(rot360 - exhaust_lobe_center + 480 * units.deg) - .add_lobe(rot360 - exhaust_lobe_center + 240 * units.deg) - _intake_cam_0 - .add_lobe(rot360 + intake_lobe_center + 0 * units.deg) - .add_lobe(rot360 + intake_lobe_center + 480 * units.deg) - .add_lobe(rot360 + intake_lobe_center + 240 * units.deg) - - _exhaust_cam_1 - .add_lobe(rot360 - exhaust_lobe_center + 630 * units.deg) - .add_lobe(rot360 - exhaust_lobe_center + 390 * units.deg) - .add_lobe(rot360 - exhaust_lobe_center + 150 * units.deg) - _intake_cam_1 - .add_lobe(rot360 + intake_lobe_center + 630 * units.deg) - .add_lobe(rot360 + intake_lobe_center + 390 * units.deg) - .add_lobe(rot360 + intake_lobe_center + 150 * units.deg) -} - -public node odd_fire_v6_90 { - alias output __out: engine; - - engine engine( - name: "Generic Odd-fire V6 (Common Rod Jnl.)", - starter_torque: 70 * units.lb_ft, - starter_speed: 500 * units.rpm, - redline: 5500 * units.rpm, - fuel: fuel( - //max_turbulence_effect: 2.5, - //burning_efficiency_randomness: 0.5, - //max_burning_efficiency: 0.75 - ), - throttle_gamma: 2.0 - ) - - wires wires() - - label stroke(3.48 * units.inch) - label bore(3.5 * units.inch) - label rod_length(5.142 * units.inch) - label rod_mass(535 * units.g) - label compression_height(1.0 * units.inch) - label crank_mass(50 * units.lb) - label flywheel_mass(30 * units.lb) - label flywheel_radius(6 * units.inch) - - label crank_moment( - disk_moment_of_inertia(mass: crank_mass, radius: stroke) - ) - label flywheel_moment( - disk_moment_of_inertia(mass: flywheel_mass, radius: flywheel_radius) - ) - label other_moment( // Moment from cams, pulleys, etc [estimated] - disk_moment_of_inertia(mass: 10 * units.kg, radius: 1.0 * units.cm) - ) - - crankshaft c0( - throw: stroke / 2, - flywheel_mass: flywheel_mass, - mass: crank_mass, - friction_torque: 5.0 * units.lb_ft, - moment_of_inertia: - crank_moment + flywheel_moment + other_moment, - position_x: 0.0, - position_y: 0.0, - tdc: 45 * units.deg - ) - - rod_journal rj0(angle: 0.0 * units.deg) - rod_journal rj1(angle: 120.0 * units.deg) - rod_journal rj2(angle: 240.0 * units.deg) - c0 - .add_rod_journal(rj0) - .add_rod_journal(rj1) - .add_rod_journal(rj2) - - piston_parameters piston_params( - mass: (414 + 152) * units.g, // 414 - piston mass, 152 - pin weight - compression_height: compression_height, - wrist_pin_position: 0.0, - displacement: 0.0 - ) - - connecting_rod_parameters cr_params( - mass: rod_mass, - moment_of_inertia: rod_moment_of_inertia( - mass: rod_mass, - length: rod_length - ), - center_of_mass: 0.0, - length: rod_length - ) - - intake intake( - plenum_volume: 1.325 * units.L, - plenum_cross_section_area: 20.0 * units.cm2, - intake_flow_rate: k_carb(400.0), - runner_flow_rate: k_carb(250.0), - runner_length: 4.0 * units.inch, - idle_flow_rate: k_carb(0.0), - idle_throttle_plate_position: 0.995, - throttle_gamma: 2.0, - velocity_decay: 0.5 - ) - - exhaust_system_parameters es_params( - outlet_flow_rate: k_carb(1000.0), - primary_tube_length: 20.0 * units.inch, - primary_flow_rate: k_carb(600.0), - velocity_decay: 1.0 - ) - - exhaust_system exhaust0( - es_params, - length: 100 * units.inch, - audio_volume: 1.0, - impulse_response: ir_lib.mild_exhaust_0_reverb - ) - exhaust_system exhaust1( - es_params, - length: 172 * units.inch, - audio_volume: 1.0, - impulse_response: ir_lib.mild_exhaust_0_reverb - ) - - cylinder_bank_parameters bank_params( - bore: bore, - deck_height: stroke / 2 + rod_length + compression_height - ) - - label spacing(5.0 * units.inch) - - cylinder_bank b0(bank_params, angle: -45.0 * units.deg) - cylinder_bank b1(bank_params, angle: 45.0 * units.deg) - b0 - .add_cylinder( - piston: piston(piston_params, blowby: k_28inH2O(0.1)), - connecting_rod: connecting_rod(cr_params), - rod_journal: rj0, - intake: intake, - exhaust_system: exhaust0, - ignition_wire: wires.wire1, - sound_attenuation: 1.0, - primary_length: spacing * 2 - ) - .add_cylinder( - piston: piston(piston_params, blowby: k_28inH2O(0.05)), - connecting_rod: connecting_rod(cr_params), - rod_journal: rj1, - intake: intake, - exhaust_system: exhaust0, - ignition_wire: wires.wire3, - sound_attenuation: 1.0, - primary_length: spacing * 1 - ) - .add_cylinder( - piston: piston(piston_params, blowby: k_28inH2O(0.1)), - connecting_rod: connecting_rod(cr_params), - rod_journal: rj2, - intake: intake, - exhaust_system: exhaust0, - ignition_wire: wires.wire5, - primary_length: spacing * 0 - ) - .set_cylinder_head( - odd_fire_v6_head( - intake_camshaft: camshaft.intake_cam_0, - exhaust_camshaft: camshaft.exhaust_cam_0) - ) - b1 - .add_cylinder( - piston: piston(piston_params, blowby: k_28inH2O(0.1)), - connecting_rod: connecting_rod(cr_params), - rod_journal: rj0, - intake: intake, - exhaust_system: exhaust1, - ignition_wire: wires.wire2, - sound_attenuation: 1.0, - primary_length: spacing * 2 - ) - .add_cylinder( - piston: piston(piston_params, blowby: k_28inH2O(0.1)), - connecting_rod: connecting_rod(cr_params), - rod_journal: rj1, - intake: intake, - exhaust_system: exhaust1, - ignition_wire: wires.wire4, - sound_attenuation: 1.0, - primary_length: spacing * 1 - ) - .add_cylinder( - piston: piston(piston_params, blowby: k_28inH2O(0.1)), - connecting_rod: connecting_rod(cr_params), - rod_journal: rj2, - intake: intake, - exhaust_system: exhaust1, - ignition_wire: wires.wire6, - sound_attenuation: 1.0, - primary_length: spacing * 0 - ) - .set_cylinder_head( - odd_fire_v6_head( - intake_camshaft: camshaft.intake_cam_1, - exhaust_camshaft: camshaft.exhaust_cam_1, - flip_display: true) - ) - - engine - .add_cylinder_bank(b0) - .add_cylinder_bank(b1) - - engine.add_crankshaft(c0) - - harmonic_cam_lobe intake_lobe( - duration_at_50_thou: 222 * units.deg, - gamma: 1.0, - lift: 400 * units.thou, - steps: 100 - ) - - harmonic_cam_lobe exhaust_lobe( - duration_at_50_thou: 226 * units.deg, - gamma: 1.0, - lift: 300 * units.thou, - steps: 100 - ) - - odd_fire_v6_camshaft camshaft( - lobe_profile: "N/A", - - intake_lobe_profile: intake_lobe, - exhaust_lobe_profile: exhaust_lobe, - intake_lobe_center: 117 * units.deg, - exhaust_lobe_center: 112 * units.deg, - base_radius: 0.75 * units.inch - ) - - function timing_curve(1000 * units.rpm) - timing_curve - .add_sample(0000 * units.rpm, 12 * units.deg) - .add_sample(1000 * units.rpm, 20 * units.deg) - .add_sample(2000 * units.rpm, 25 * units.deg) - .add_sample(3000 * units.rpm, 30 * units.deg) - .add_sample(4000 * units.rpm, 30 * units.deg) - - ignition_module ignition_module( - timing_curve: timing_curve, - rev_limit: 5600 * units.rpm, - limiter_duration: 0.2) - ignition_module - .connect_wire(wires.wire1, 0 * units.deg) - .connect_wire(wires.wire6, 150 * units.deg) - .connect_wire(wires.wire5, 240 * units.deg) - .connect_wire(wires.wire4, 390 * units.deg) - .connect_wire(wires.wire3, 480 * units.deg) - .connect_wire(wires.wire2, 630 * units.deg) - - engine.add_ignition_module(ignition_module) -} - -label car_mass(2700 * units.lb) -private node random_car { - alias output __out: - vehicle( - mass: car_mass, - drag_coefficient: 0.3, - cross_sectional_area: (72 * units.inch) * (56 * units.inch), - diff_ratio: 3.9, - tire_radius: 10 * units.inch, - rolling_resistance: 0.015 * car_mass * 9.81 - ); -} - -private node random_transmission { - alias output __out: - transmission( - max_clutch_torque: 300 * units.lb_ft - ) - .add_gear(3.636) - .add_gear(2.375) - .add_gear(1.761) - .add_gear(1.346) - .add_gear(0.971) - .add_gear(0.756); -} - -public node main { - set_engine(odd_fire_v6_90()) - set_vehicle(random_car()) - set_transmission(random_transmission()) -} diff --git a/es/engines/atg-video-2/06_even_fire_v6.mr b/es/engines/atg-video-2/06_even_fire_v6.mr deleted file mode 100644 index d4e23f0..0000000 --- a/es/engines/atg-video-2/06_even_fire_v6.mr +++ /dev/null @@ -1,400 +0,0 @@ -import "engine_sim.mr" - -units units() -constants constants() -impulse_response_library ir_lib() -label cycle(2 * 360 * units.deg) - -private node wires { - output wire1: ignition_wire(); - output wire2: ignition_wire(); - output wire3: ignition_wire(); - output wire4: ignition_wire(); - output wire5: ignition_wire(); - output wire6: ignition_wire(); -} - -private node even_fire_v6_head { - input intake_camshaft; - input exhaust_camshaft; - input chamber_volume: 67 * units.cc; - input intake_runner_volume: 149.6 * units.cc; - input intake_runner_cross_section_area: 1.35 * units.inch * 1.35 * units.inch; - input exhaust_runner_volume: 50.0 * units.cc; - input exhaust_runner_cross_section_area: 2.0 * units.inch * 2.0 * units.inch; - - input flow_attenuation: 1.0; - input lift_scale: 1.0; - input flip_display: false; - alias output __out: head; - - function intake_flow(50 * units.thou) - intake_flow - .add_flow_sample(0 * lift_scale, 0 * flow_attenuation) - .add_flow_sample(50 * lift_scale, 58 * flow_attenuation) - .add_flow_sample(100 * lift_scale, 103 * flow_attenuation) - .add_flow_sample(150 * lift_scale, 156 * flow_attenuation) - .add_flow_sample(200 * lift_scale, 214 * flow_attenuation) - .add_flow_sample(250 * lift_scale, 249 * flow_attenuation) - .add_flow_sample(300 * lift_scale, 268 * flow_attenuation) - .add_flow_sample(350 * lift_scale, 280 * flow_attenuation) - .add_flow_sample(400 * lift_scale, 280 * flow_attenuation) - .add_flow_sample(450 * lift_scale, 281 * flow_attenuation) - - function exhaust_flow(50 * units.thou) - exhaust_flow - .add_flow_sample(0 * lift_scale, 0 * flow_attenuation) - .add_flow_sample(50 * lift_scale, 37 * flow_attenuation) - .add_flow_sample(100 * lift_scale, 72 * flow_attenuation) - .add_flow_sample(150 * lift_scale, 113 * flow_attenuation) - .add_flow_sample(200 * lift_scale, 160 * flow_attenuation) - .add_flow_sample(250 * lift_scale, 196 * flow_attenuation) - .add_flow_sample(300 * lift_scale, 222 * flow_attenuation) - .add_flow_sample(350 * lift_scale, 235 * flow_attenuation) - .add_flow_sample(400 * lift_scale, 245 * flow_attenuation) - .add_flow_sample(450 * lift_scale, 246 * flow_attenuation) - - generic_cylinder_head head( - chamber_volume: chamber_volume, - intake_runner_volume: intake_runner_volume, - intake_runner_cross_section_area: intake_runner_cross_section_area, - exhaust_runner_volume: exhaust_runner_volume, - exhaust_runner_cross_section_area: exhaust_runner_cross_section_area, - - intake_port_flow: intake_flow, - exhaust_port_flow: exhaust_flow, - valvetrain: standard_valvetrain( - intake_camshaft: intake_camshaft, - exhaust_camshaft: exhaust_camshaft - ), - flip_display: flip_display - ) -} - -private node even_fire_v6_camshaft { - input lobe_profile; - input intake_lobe_profile: lobe_profile; - input exhaust_lobe_profile: lobe_profile; - input lobe_separation: 114 * units.deg; - input intake_lobe_center: lobe_separation; - input exhaust_lobe_center: lobe_separation; - input advance: 0 * units.deg; - input base_radius: 0.5 * units.inch; - - output intake_cam_0: _intake_cam_0; - output exhaust_cam_0: _exhaust_cam_0; - - output intake_cam_1: _intake_cam_1; - output exhaust_cam_1: _exhaust_cam_1; - - camshaft_parameters params ( - advance: advance, - base_radius: base_radius - ) - - camshaft _intake_cam_0(params, lobe_profile: intake_lobe_profile) - camshaft _exhaust_cam_0(params, lobe_profile: exhaust_lobe_profile) - camshaft _intake_cam_1(params, lobe_profile: intake_lobe_profile) - camshaft _exhaust_cam_1(params, lobe_profile: exhaust_lobe_profile) - - label rot180(180 * units.deg) - label rot360(360 * units.deg) - - // 1 6 5 4 3 2 - _exhaust_cam_0 - .add_lobe(rot360 - exhaust_lobe_center + 0 * units.deg) - .add_lobe(rot360 - exhaust_lobe_center + 480 * units.deg) - .add_lobe(rot360 - exhaust_lobe_center + 240 * units.deg) - _intake_cam_0 - .add_lobe(rot360 + intake_lobe_center + 0 * units.deg) - .add_lobe(rot360 + intake_lobe_center + 480 * units.deg) - .add_lobe(rot360 + intake_lobe_center + 240 * units.deg) - - _exhaust_cam_1 - .add_lobe(rot360 - exhaust_lobe_center + 600 * units.deg) - .add_lobe(rot360 - exhaust_lobe_center + 360 * units.deg) - .add_lobe(rot360 - exhaust_lobe_center + 120 * units.deg) - _intake_cam_1 - .add_lobe(rot360 + intake_lobe_center + 600 * units.deg) - .add_lobe(rot360 + intake_lobe_center + 360 * units.deg) - .add_lobe(rot360 + intake_lobe_center + 120 * units.deg) -} - -public node even_fire_v6_90 { - alias output __out: engine; - - engine engine( - name: "Generic Even-fire V6 (Split Rod Jnl.)", - starter_torque: 70 * units.lb_ft, - starter_speed: 500 * units.rpm, - redline: 5500 * units.rpm, - fuel: fuel( - //max_turbulence_effect: 2.5, - //burning_efficiency_randomness: 0.5, - //max_burning_efficiency: 0.75 - ), - throttle_gamma: 2.0 - ) - - wires wires() - - label stroke(3.48 * units.inch) - label bore(3.5 * units.inch) - label rod_length(5.142 * units.inch) - label rod_mass(535 * units.g) - label compression_height(1.0 * units.inch) - label crank_mass(50 * units.lb) - label flywheel_mass(30 * units.lb) - label flywheel_radius(6 * units.inch) - - label crank_moment( - disk_moment_of_inertia(mass: crank_mass, radius: stroke) - ) - label flywheel_moment( - disk_moment_of_inertia(mass: flywheel_mass, radius: flywheel_radius) - ) - label other_moment( // Moment from cams, pulleys, etc [estimated] - disk_moment_of_inertia(mass: 10 * units.kg, radius: 1.0 * units.cm) - ) - - crankshaft c0( - throw: stroke / 2, - flywheel_mass: flywheel_mass, - mass: crank_mass, - friction_torque: 5.0 * units.lb_ft, - moment_of_inertia: - crank_moment + flywheel_moment + other_moment, - position_x: 0.0, - position_y: 0.0, - tdc: 45 * units.deg - ) - - rod_journal rj0(angle: 0.0 * units.deg) - rod_journal rj1(angle: (0.0 - 30) * units.deg) - rod_journal rj2(angle: 120.0 * units.deg) - rod_journal rj3(angle: (120.0 - 30) * units.deg) - rod_journal rj4(angle: 240.0 * units.deg) - rod_journal rj5(angle: (240.0 - 30) * units.deg) - c0 - .add_rod_journal(rj0) - .add_rod_journal(rj1) - .add_rod_journal(rj2) - .add_rod_journal(rj3) - .add_rod_journal(rj4) - .add_rod_journal(rj5) - - piston_parameters piston_params( - mass: (414 + 152) * units.g, // 414 - piston mass, 152 - pin weight - compression_height: compression_height, - wrist_pin_position: 0.0, - displacement: 0.0 - ) - - connecting_rod_parameters cr_params( - mass: rod_mass, - moment_of_inertia: rod_moment_of_inertia( - mass: rod_mass, - length: rod_length - ), - center_of_mass: 0.0, - length: rod_length - ) - - intake intake( - plenum_volume: 1.325 * units.L, - plenum_cross_section_area: 20.0 * units.cm2, - intake_flow_rate: k_carb(400.0), - runner_flow_rate: k_carb(250.0), - runner_length: 4.0 * units.inch, - idle_flow_rate: k_carb(0.0), - idle_throttle_plate_position: 0.995, - velocity_decay: 0.5 - ) - - exhaust_system_parameters es_params( - outlet_flow_rate: k_carb(1000.0), - primary_tube_length: 20.0 * units.inch, - primary_flow_rate: k_carb(300.0), - velocity_decay: 1.0, - length: 100.0 * units.inch - ) - - exhaust_system exhaust0( - es_params, - length: 100.0 * units.inch, - audio_volume: 1.0, - impulse_response: ir_lib.mild_exhaust_0_reverb - ) - exhaust_system exhaust1( - es_params, - length: 172.0 * units.inch, - audio_volume: 1.0, - impulse_response: ir_lib.mild_exhaust_0_reverb - ) - - cylinder_bank_parameters bank_params( - bore: bore, - deck_height: stroke / 2 + rod_length + compression_height - ) - - label spacing(5.0 * units.inch) - - cylinder_bank b0(bank_params, angle: -45.0 * units.deg) - cylinder_bank b1(bank_params, angle: 45.0 * units.deg) - b0 - .add_cylinder( - piston: piston(piston_params, blowby: k_28inH2O(0.1)), - connecting_rod: connecting_rod(cr_params), - rod_journal: rj0, - intake: intake, - exhaust_system: exhaust0, - ignition_wire: wires.wire1, - sound_attenuation: 0.8, - primary_length: spacing * 2 - ) - .add_cylinder( - piston: piston(piston_params, blowby: k_28inH2O(0.2)), - connecting_rod: connecting_rod(cr_params), - rod_journal: rj2, - intake: intake, - exhaust_system: exhaust0, - ignition_wire: wires.wire3, - sound_attenuation: 0.9, - primary_length: spacing * 1 - ) - .add_cylinder( - piston: piston(piston_params, blowby: k_28inH2O(0.2)), - connecting_rod: connecting_rod(cr_params), - rod_journal: rj4, - intake: intake, - exhaust_system: exhaust0, - ignition_wire: wires.wire5, - primary_length: spacing * 0 - ) - .set_cylinder_head( - even_fire_v6_head( - intake_camshaft: camshaft.intake_cam_0, - exhaust_camshaft: camshaft.exhaust_cam_0) - ) - b1 - .add_cylinder( - piston: piston(piston_params, blowby: k_28inH2O(0.1)), - connecting_rod: connecting_rod(cr_params), - rod_journal: rj1, - intake: intake, - exhaust_system: exhaust1, - ignition_wire: wires.wire2, - sound_attenuation: 0.6, - primary_length: spacing * 2 - ) - .add_cylinder( - piston: piston(piston_params, blowby: k_28inH2O(0.2)), - connecting_rod: connecting_rod(cr_params), - rod_journal: rj3, - intake: intake, - exhaust_system: exhaust1, - ignition_wire: wires.wire4, - sound_attenuation: 0.3, - primary_length: spacing * 1 - ) - .add_cylinder( - piston: piston(piston_params, blowby: k_28inH2O(0.2)), - connecting_rod: connecting_rod(cr_params), - rod_journal: rj5, - intake: intake, - exhaust_system: exhaust1, - ignition_wire: wires.wire6, - sound_attenuation: 1.1, - primary_length: spacing * 0 - ) - .set_cylinder_head( - even_fire_v6_head( - intake_camshaft: camshaft.intake_cam_1, - exhaust_camshaft: camshaft.exhaust_cam_1, - flip_display: true) - ) - - engine - .add_cylinder_bank(b0) - .add_cylinder_bank(b1) - - engine.add_crankshaft(c0) - - harmonic_cam_lobe intake_lobe( - duration_at_50_thou: 222 * units.deg, - gamma: 1.0, - lift: 400 * units.thou, - steps: 100 - ) - - harmonic_cam_lobe exhaust_lobe( - duration_at_50_thou: 226 * units.deg, - gamma: 1.0, - lift: 300 * units.thou, - steps: 100 - ) - - even_fire_v6_camshaft camshaft( - lobe_profile: "N/A", - - intake_lobe_profile: intake_lobe, - exhaust_lobe_profile: exhaust_lobe, - intake_lobe_center: 117 * units.deg, - exhaust_lobe_center: 112 * units.deg, - base_radius: 0.75 * units.inch - ) - - function timing_curve(1000 * units.rpm) - timing_curve - .add_sample(0000 * units.rpm, 12 * units.deg) - .add_sample(1000 * units.rpm, 20 * units.deg) - .add_sample(2000 * units.rpm, 25 * units.deg) - .add_sample(3000 * units.rpm, 30 * units.deg) - .add_sample(4000 * units.rpm, 30 * units.deg) - - ignition_module ignition_module( - timing_curve: timing_curve, - rev_limit: 5600 * units.rpm, - limiter_duration: 0.2) - ignition_module - .connect_wire(wires.wire1, 0 * units.deg) - .connect_wire(wires.wire6, 120 * units.deg) - .connect_wire(wires.wire5, 240 * units.deg) - .connect_wire(wires.wire4, 360 * units.deg) - .connect_wire(wires.wire3, 480 * units.deg) - .connect_wire(wires.wire2, 600 * units.deg) - - engine.add_ignition_module(ignition_module) -} - -label car_mass(2700 * units.lb) -private node random_car { - alias output __out: - vehicle( - mass: car_mass, - drag_coefficient: 0.3, - cross_sectional_area: (72 * units.inch) * (56 * units.inch), - diff_ratio: 3.9, - tire_radius: 10 * units.inch, - rolling_resistance: 0.015 * car_mass * 9.81 - ); -} - -private node random_transmission { - alias output __out: - transmission( - max_clutch_torque: 300 * units.lb_ft - ) - .add_gear(3.636) - .add_gear(2.375) - .add_gear(1.761) - .add_gear(1.346) - .add_gear(0.971) - .add_gear(0.756); -} - -public node main { - set_engine(even_fire_v6_90()) - set_vehicle(random_car()) - set_transmission(random_transmission()) -} diff --git a/es/engines/atg-video-2/07_gm_ls.mr b/es/engines/atg-video-2/07_gm_ls.mr deleted file mode 100644 index 06b0984..0000000 --- a/es/engines/atg-video-2/07_gm_ls.mr +++ /dev/null @@ -1,455 +0,0 @@ -import "engine_sim.mr" - -units units() -constants constants() -impulse_response_library ir_lib() -label cycle(2 * 360 * units.deg) - -private node wires { - output wire1: ignition_wire(); - output wire2: ignition_wire(); - output wire3: ignition_wire(); - output wire4: ignition_wire(); - output wire5: ignition_wire(); - output wire6: ignition_wire(); - output wire7: ignition_wire(); - output wire8: ignition_wire(); -} - -private node ls_v8_head { - input intake_camshaft; - input exhaust_camshaft; - input chamber_volume: 90 * units.cc; - input intake_runner_volume: 149.6 * units.cc; - input intake_runner_cross_section_area: 2.2 * units.inch * 2.2 * units.inch; - input exhaust_runner_volume: 50.0 * units.cc; - input exhaust_runner_cross_section_area: 1.75 * units.inch * 1.75 * units.inch; - - input flow_attenuation: 1.0; - input lift_scale: 1.0; - input flip_display: false; - alias output __out: head; - - function intake_flow(50 * units.thou) - intake_flow - .add_flow_sample(0 * lift_scale, 0 * flow_attenuation) - .add_flow_sample(50 * lift_scale, 1 * flow_attenuation) - .add_flow_sample(100 * lift_scale, 103 * flow_attenuation) - .add_flow_sample(150 * lift_scale, 156 * flow_attenuation) - .add_flow_sample(200 * lift_scale, 214 * flow_attenuation) - .add_flow_sample(250 * lift_scale, 249 * flow_attenuation) - .add_flow_sample(300 * lift_scale, 268 * flow_attenuation) - .add_flow_sample(350 * lift_scale, 280 * flow_attenuation) - .add_flow_sample(400 * lift_scale, 280 * flow_attenuation) - .add_flow_sample(450 * lift_scale, 281 * flow_attenuation) - - function exhaust_flow(50 * units.thou) - exhaust_flow - .add_flow_sample(0 * lift_scale, 0 * flow_attenuation) - .add_flow_sample(50 * lift_scale, 1 * flow_attenuation) - .add_flow_sample(100 * lift_scale, 72 * flow_attenuation) - .add_flow_sample(150 * lift_scale, 113 * flow_attenuation) - .add_flow_sample(200 * lift_scale, 160 * flow_attenuation) - .add_flow_sample(250 * lift_scale, 196 * flow_attenuation) - .add_flow_sample(300 * lift_scale, 222 * flow_attenuation) - .add_flow_sample(350 * lift_scale, 235 * flow_attenuation) - .add_flow_sample(400 * lift_scale, 245 * flow_attenuation) - .add_flow_sample(450 * lift_scale, 246 * flow_attenuation) - - generic_cylinder_head head( - chamber_volume: chamber_volume, - intake_runner_volume: intake_runner_volume, - intake_runner_cross_section_area: intake_runner_cross_section_area, - exhaust_runner_volume: exhaust_runner_volume, - exhaust_runner_cross_section_area: exhaust_runner_cross_section_area, - - intake_port_flow: intake_flow, - exhaust_port_flow: exhaust_flow, - valvetrain: standard_valvetrain( - intake_camshaft: intake_camshaft, - exhaust_camshaft: exhaust_camshaft - ), - flip_display: flip_display - ) -} - -private node ls_v8_camshaft { - input lobe_profile; - input intake_lobe_profile: lobe_profile; - input exhaust_lobe_profile: lobe_profile; - input lobe_separation: 114 * units.deg; - input intake_lobe_center: lobe_separation; - input exhaust_lobe_center: lobe_separation; - input advance: 0 * units.deg; - input base_radius: 0.5 * units.inch; - - output intake_cam_0: _intake_cam_0; - output exhaust_cam_0: _exhaust_cam_0; - - output intake_cam_1: _intake_cam_1; - output exhaust_cam_1: _exhaust_cam_1; - - camshaft_parameters params ( - advance: advance, - base_radius: base_radius - ) - - camshaft _intake_cam_0(params, lobe_profile: intake_lobe_profile) - camshaft _exhaust_cam_0(params, lobe_profile: exhaust_lobe_profile) - camshaft _intake_cam_1(params, lobe_profile: intake_lobe_profile) - camshaft _exhaust_cam_1(params, lobe_profile: exhaust_lobe_profile) - - label rot(90 * units.deg) - label rot360(360 * units.deg) - - // 1 8 7 2 6 5 4 3 - _exhaust_cam_0 - .add_lobe(rot360 - exhaust_lobe_center + 0 * rot) // 1 - .add_lobe(rot360 - exhaust_lobe_center + 7 * rot) // 3 - .add_lobe(rot360 - exhaust_lobe_center + 5 * rot) // 5 - .add_lobe(rot360 - exhaust_lobe_center + 2 * rot) // 7 - _intake_cam_0 - .add_lobe(rot360 + intake_lobe_center + 0 * rot) // 1 - .add_lobe(rot360 + intake_lobe_center + 7 * rot) // 3 - .add_lobe(rot360 + intake_lobe_center + 5 * rot) // 5 - .add_lobe(rot360 + intake_lobe_center + 2 * rot) // 7 - - _exhaust_cam_1 - .add_lobe(rot360 - exhaust_lobe_center + 3 * rot) // 2 - .add_lobe(rot360 - exhaust_lobe_center + 6 * rot) // 4 - .add_lobe(rot360 - exhaust_lobe_center + 4 * rot) // 6 - .add_lobe(rot360 - exhaust_lobe_center + 1 * rot) // 8 - _intake_cam_1 - .add_lobe(rot360 + intake_lobe_center + 3 * rot) // 2 - .add_lobe(rot360 + intake_lobe_center + 6 * rot) // 4 - .add_lobe(rot360 + intake_lobe_center + 4 * rot) // 6 - .add_lobe(rot360 + intake_lobe_center + 1 * rot) // 8 -} - -private node turbulence_to_flame_speed_ratio { - alias output __out: - function(5.0) - .add_sample(0.0, 3.0) - .add_sample(5.0, 1.5 * 5.0) - .add_sample(10.0, 1.75 * 10.0) - .add_sample(15.0, 2.0 * 15.0) - .add_sample(20.0, 2.0 * 20.0) - .add_sample(25.0, 2.0 * 25.0) - .add_sample(30.0, 2.0 * 30.0) - .add_sample(35.0, 2.0 * 35.0) - .add_sample(40.0, 2.0 * 40.0) - .add_sample(45.0, 2.0 * 45.0); -} - -public node ls_v8 { - alias output __out: engine; - - engine engine( - name: "GM LS", - starter_torque: 200 * units.lb_ft, - starter_speed: 200 * units.rpm, - redline: 6500 * units.rpm, - throttle_gamma: 2.0, - fuel: fuel( - //max_turbulence_effect: 10.0, - //max_dilution_effect: 20.0,R - //burning_efficiency_randomness: 0.5, - max_burning_efficiency: 1.0, - turbulence_to_flame_speed_ratio: turbulence_to_flame_speed_ratio() - ), - hf_gain: 0.01, - noise: 1.0, - jitter: 0.6, - simulation_frequency: 10000 - ) - - wires wires() - - label stroke(3.622 * units.inch) - label bore(3.78 * units.inch) - label rod_length(160 * units.mm) - label rod_mass(50 * units.g) - label compression_height(1.0 * units.inch) - label crank_mass(60 * units.lb) - label flywheel_mass(30 * units.lb) - label flywheel_radius(8 * units.inch) - - label crank_moment( - 1.5 * disk_moment_of_inertia(mass: crank_mass, radius: stroke) - ) - label flywheel_moment( - disk_moment_of_inertia(mass: flywheel_mass, radius: flywheel_radius) - ) - label other_moment( // Moment from cams, pulleys, etc [estimated] - disk_moment_of_inertia(mass: 1 * units.kg, radius: 1.0 * units.cm) - ) - - label v_angle(90 * units.deg) - crankshaft c0( - throw: stroke / 2, - flywheel_mass: flywheel_mass, - mass: crank_mass, - friction_torque: 20.0 * units.lb_ft, - moment_of_inertia: - crank_moment + flywheel_moment + other_moment, - position_x: 0.0, - position_y: 0.0, - tdc: 90 * units.deg - (v_angle / 2.0) - ) - - // 1 8 7 2 6 5 4 3 - rod_journal rj0(angle: 0 * units.deg) - rod_journal rj1(angle: 270 * units.deg) - rod_journal rj2(angle: 90 * units.deg) - rod_journal rj3(angle: 180 * units.deg) - c0 - .add_rod_journal(rj0) - .add_rod_journal(rj1) - .add_rod_journal(rj2) - .add_rod_journal(rj3) - - piston_parameters piston_params( - // 414 - piston mass, 152 - pin weight - mass: (100) * units.g, - compression_height: compression_height, - wrist_pin_position: 0.0, - displacement: 0.0 - ) - - connecting_rod_parameters cr_params( - mass: rod_mass, - moment_of_inertia: rod_moment_of_inertia( - mass: rod_mass, - length: rod_length - ), - center_of_mass: 0.0, - length: rod_length - ) - - intake intake( - plenum_volume: 1.325 * units.L, - plenum_cross_section_area: 20.0 * units.cm2, - intake_flow_rate: k_carb(700.0), - runner_flow_rate: k_carb(100.0), - runner_length: 12.0 * units.inch, - idle_flow_rate: k_carb(0.0), - idle_throttle_plate_position: 0.996, - velocity_decay: 0.5 - ) - - exhaust_system_parameters es_params( - outlet_flow_rate: k_carb(1000.0), - primary_tube_length: 29.0 * units.inch, - primary_flow_rate: k_carb(500.0), - velocity_decay: 1.0 - ) - - exhaust_system exhaust0( - es_params, - audio_volume: 4.0, - length: 100 * units.inch, - impulse_response: ir_lib.default_0 - - ) - exhaust_system exhaust1( - es_params, - audio_volume: 4.0, - length: 172 * units.inch, - impulse_response: ir_lib.default_0 - ) - - cylinder_bank_parameters bank_params( - bore: bore, - deck_height: stroke / 2 + rod_length + compression_height - ) - - label spacing(2 * units.inch) - - cylinder_bank b0(bank_params, angle: -v_angle / 2.0) - cylinder_bank b1(bank_params, angle: v_angle / 2.0) - b0 - .add_cylinder( - piston: piston(piston_params, blowby: k_28inH2O(0.0)), - connecting_rod: connecting_rod(cr_params), - rod_journal: rj0, - intake: intake, - exhaust_system: exhaust0, - ignition_wire: wires.wire1, - sound_attenuation: 1.0, - primary_length: 3 * spacing + 2 * units.cm - ) - .add_cylinder( - piston: piston(piston_params, blowby: k_28inH2O(0.0)), - connecting_rod: connecting_rod(cr_params), - rod_journal: rj1, - intake: intake, - exhaust_system: exhaust0, - ignition_wire: wires.wire3, - sound_attenuation: 1.0, - primary_length: 2 * spacing + 1 * units.cm - ) - .add_cylinder( - piston: piston(piston_params, blowby: k_28inH2O(0.0)), - connecting_rod: connecting_rod(cr_params), - rod_journal: rj2, - intake: intake, - exhaust_system: exhaust0, - ignition_wire: wires.wire5, - sound_attenuation: 1.0, - primary_length: 1 * spacing + 3 * units.cm - ) - .add_cylinder( - piston: piston(piston_params, blowby: k_28inH2O(0.0)), - connecting_rod: connecting_rod(cr_params), - rod_journal: rj3, - intake: intake, - exhaust_system: exhaust0, - ignition_wire: wires.wire7, - sound_attenuation: 1.0, - primary_length: 0 * spacing + 5 * units.cm - ) - .set_cylinder_head( - ls_v8_head( - intake_camshaft: camshaft.intake_cam_0, - exhaust_camshaft: camshaft.exhaust_cam_0, - flip_display: false, - flow_attenuation: 1.0) - ) - b1 - .add_cylinder( - piston: piston(piston_params, blowby: k_28inH2O(0.0)), - connecting_rod: connecting_rod(cr_params), - rod_journal: rj0, - intake: intake, - exhaust_system: exhaust1, - ignition_wire: wires.wire2, - sound_attenuation: 1.0, - primary_length: 3 * spacing + 1 * units.cm - ) - .add_cylinder( - piston: piston(piston_params, blowby: k_28inH2O(0.0)), - connecting_rod: connecting_rod(cr_params), - rod_journal: rj1, - intake: intake, - exhaust_system: exhaust1, - ignition_wire: wires.wire4, - sound_attenuation: 1.0, - primary_length: 2 * spacing + 5 * units.cm - ) - .add_cylinder( - piston: piston(piston_params, blowby: k_28inH2O(0.0)), - connecting_rod: connecting_rod(cr_params), - rod_journal: rj2, - intake: intake, - exhaust_system: exhaust1, - ignition_wire: wires.wire6, - sound_attenuation: 1.0, - primary_length: 1 * spacing + 7 * units.cm - ) - .add_cylinder( - piston: piston(piston_params, blowby: k_28inH2O(0.0)), - connecting_rod: connecting_rod(cr_params), - rod_journal: rj3, - intake: intake, - exhaust_system: exhaust1, - ignition_wire: wires.wire8, - sound_attenuation: 1.0, - primary_length: 0 * spacing + 0 * units.cm - ) - .set_cylinder_head( - ls_v8_head( - intake_camshaft: camshaft.intake_cam_1, - exhaust_camshaft: camshaft.exhaust_cam_1, - flow_attenuation: 1.0, - flip_display: true) - ) - - engine - .add_cylinder_bank(b0) - .add_cylinder_bank(b1) - - engine.add_crankshaft(c0) - - harmonic_cam_lobe intake_lobe( - duration_at_50_thou: 234 * units.deg, - gamma: 1.1, - lift: 551 * units.thou, - steps: 256 - ) - - harmonic_cam_lobe exhaust_lobe( - duration_at_50_thou: 235 * units.deg, - gamma: 1.1, - lift: 551 * units.thou, - steps: 256 - ) - - ls_v8_camshaft camshaft( - lobe_profile: "N/A", - - intake_lobe_profile: intake_lobe, - exhaust_lobe_profile: exhaust_lobe, - intake_lobe_center: 116 * units.deg, - exhaust_lobe_center: 116 * units.deg, - base_radius: 1.0 * units.inch - ) - - function timing_curve(1000 * units.rpm) - timing_curve - .add_sample(0000 * units.rpm, 12 * units.deg) - .add_sample(1000 * units.rpm, 12 * units.deg) - .add_sample(2000 * units.rpm, 20 * units.deg) - .add_sample(3000 * units.rpm, 30 * units.deg) - .add_sample(4000 * units.rpm, 40 * units.deg) - .add_sample(5000 * units.rpm, 40 * units.deg) - .add_sample(6000 * units.rpm, 40 * units.deg) - .add_sample(7000 * units.rpm, 40 * units.deg) - .add_sample(8000 * units.rpm, 40 * units.deg) - - ignition_module ignition_module( - timing_curve: timing_curve, - rev_limit: 6800 * units.rpm, - limiter_duration: 0.2) - ignition_module - .connect_wire(wires.wire1, 0 * 90 * units.deg) - .connect_wire(wires.wire8, 1 * 90 * units.deg) - .connect_wire(wires.wire7, 2 * 90 * units.deg) - .connect_wire(wires.wire2, 3 * 90 * units.deg) - .connect_wire(wires.wire6, 4 * 90 * units.deg) - .connect_wire(wires.wire5, 5 * 90 * units.deg) - .connect_wire(wires.wire4, 6 * 90 * units.deg) - .connect_wire(wires.wire3, 7 * 90 * units.deg) - - engine.add_ignition_module(ignition_module) -} - -private node corvette { - alias output __out: - vehicle( - mass: 1614 * units.kg, - drag_coefficient: 0.3, - cross_sectional_area: (72 * units.inch) * (50 * units.inch), - diff_ratio: 3.42, - tire_radius: 10 * units.inch, - rolling_resistance: 200 * units.N - ); -} - -private node corvette_transmission { - alias output __out: - transmission( - max_clutch_torque: 500 * units.lb_ft - ) - .add_gear(2.97) - .add_gear(2.07) - .add_gear(1.43) - .add_gear(1.00) - .add_gear(0.71) - .add_gear(0.57); -} - -public node main { - set_engine(ls_v8()) - set_vehicle(corvette()) - set_transmission(corvette_transmission()) -} diff --git a/es/engines/atg-video-2/08_ferrari_f136_v8.mr b/es/engines/atg-video-2/08_ferrari_f136_v8.mr deleted file mode 100644 index 781b70a..0000000 --- a/es/engines/atg-video-2/08_ferrari_f136_v8.mr +++ /dev/null @@ -1,451 +0,0 @@ -import "engine_sim.mr" - -units units() -constants constants() -impulse_response_library ir_lib() -label cycle(2 * 360 * units.deg) - -private node wires { - output wire1: ignition_wire(); - output wire2: ignition_wire(); - output wire3: ignition_wire(); - output wire4: ignition_wire(); - output wire5: ignition_wire(); - output wire6: ignition_wire(); - output wire7: ignition_wire(); - output wire8: ignition_wire(); -} - -private node f136_head { - input intake_camshaft; - input exhaust_camshaft; - input chamber_volume: 90 * units.cc; - input intake_runner_volume: 149.6 * units.cc; - input intake_runner_cross_section_area: 2.2 * units.inch * 2.2 * units.inch; - input exhaust_runner_volume: 50.0 * units.cc; - input exhaust_runner_cross_section_area: 1.75 * units.inch * 1.75 * units.inch; - - input flow_attenuation: 1.0; - input lift_scale: 1.0; - input flip_display: false; - alias output __out: head; - - function intake_flow(50 * units.thou) - intake_flow - .add_flow_sample(0 * lift_scale, 0 * flow_attenuation) - .add_flow_sample(50 * lift_scale, 58 * flow_attenuation) - .add_flow_sample(100 * lift_scale, 103 * flow_attenuation) - .add_flow_sample(150 * lift_scale, 156 * flow_attenuation) - .add_flow_sample(200 * lift_scale, 214 * flow_attenuation) - .add_flow_sample(250 * lift_scale, 249 * flow_attenuation) - .add_flow_sample(300 * lift_scale, 268 * flow_attenuation) - .add_flow_sample(350 * lift_scale, 280 * flow_attenuation) - .add_flow_sample(400 * lift_scale, 280 * flow_attenuation) - .add_flow_sample(450 * lift_scale, 281 * flow_attenuation) - - function exhaust_flow(50 * units.thou) - exhaust_flow - .add_flow_sample(0 * lift_scale, 0 * flow_attenuation) - .add_flow_sample(50 * lift_scale, 37 * flow_attenuation) - .add_flow_sample(100 * lift_scale, 72 * flow_attenuation) - .add_flow_sample(150 * lift_scale, 113 * flow_attenuation) - .add_flow_sample(200 * lift_scale, 160 * flow_attenuation) - .add_flow_sample(250 * lift_scale, 196 * flow_attenuation) - .add_flow_sample(300 * lift_scale, 222 * flow_attenuation) - .add_flow_sample(350 * lift_scale, 235 * flow_attenuation) - .add_flow_sample(400 * lift_scale, 245 * flow_attenuation) - .add_flow_sample(450 * lift_scale, 246 * flow_attenuation) - - generic_cylinder_head head( - chamber_volume: chamber_volume, - intake_runner_volume: intake_runner_volume, - intake_runner_cross_section_area: intake_runner_cross_section_area, - exhaust_runner_volume: exhaust_runner_volume, - exhaust_runner_cross_section_area: exhaust_runner_cross_section_area, - - intake_port_flow: intake_flow, - exhaust_port_flow: exhaust_flow, - valvetrain: standard_valvetrain( - intake_camshaft: intake_camshaft, - exhaust_camshaft: exhaust_camshaft - ), - flip_display: flip_display - ) -} - -private node f136_camshaft { - input lobe_profile; - input intake_lobe_profile: lobe_profile; - input exhaust_lobe_profile: lobe_profile; - input lobe_separation: 114 * units.deg; - input intake_lobe_center: lobe_separation; - input exhaust_lobe_center: lobe_separation; - input advance: 0 * units.deg; - input base_radius: 0.5 * units.inch; - - output intake_cam_0: _intake_cam_0; - output exhaust_cam_0: _exhaust_cam_0; - - output intake_cam_1: _intake_cam_1; - output exhaust_cam_1: _exhaust_cam_1; - - camshaft_parameters params ( - advance: advance, - base_radius: base_radius - ) - - camshaft _intake_cam_0(params, lobe_profile: intake_lobe_profile) - camshaft _exhaust_cam_0(params, lobe_profile: exhaust_lobe_profile) - camshaft _intake_cam_1(params, lobe_profile: intake_lobe_profile) - camshaft _exhaust_cam_1(params, lobe_profile: exhaust_lobe_profile) - - label rot(90 * units.deg) - label rot360(360 * units.deg) - - // 1 5 3 7 4 8 2 6 - _exhaust_cam_0 - .add_lobe(rot360 - exhaust_lobe_center + 0 * rot) // 1 - .add_lobe(rot360 - exhaust_lobe_center + 6 * rot) // 2 - .add_lobe(rot360 - exhaust_lobe_center + 2 * rot) // 3 - .add_lobe(rot360 - exhaust_lobe_center + 4 * rot) // 4 - _intake_cam_0 - .add_lobe(rot360 + intake_lobe_center + 0 * rot) // 1 - .add_lobe(rot360 + intake_lobe_center + 6 * rot) // 2 - .add_lobe(rot360 + intake_lobe_center + 2 * rot) // 3 - .add_lobe(rot360 + intake_lobe_center + 4 * rot) // 4 - - _exhaust_cam_1 - .add_lobe(rot360 - exhaust_lobe_center + 1 * rot) // 5 - .add_lobe(rot360 - exhaust_lobe_center + 7 * rot) // 6 - .add_lobe(rot360 - exhaust_lobe_center + 3 * rot) // 7 - .add_lobe(rot360 - exhaust_lobe_center + 5 * rot) // 8 - _intake_cam_1 - .add_lobe(rot360 + intake_lobe_center + 1 * rot) // 5 - .add_lobe(rot360 + intake_lobe_center + 7 * rot) // 6 - .add_lobe(rot360 + intake_lobe_center + 3 * rot) // 7 - .add_lobe(rot360 + intake_lobe_center + 5 * rot) // 8 -} - -private node turbulence_to_flame_speed_ratio { - alias output __out: - function(5.0) - .add_sample(0.0, 3.0) - .add_sample(5.0, 1.5 * 5.0) - .add_sample(10.0, 1.75 * 10.0) - .add_sample(15.0, 2.0 * 15.0) - .add_sample(20.0, 2.0 * 20.0) - .add_sample(25.0, 2.0 * 25.0) - .add_sample(30.0, 2.0 * 30.0) - .add_sample(35.0, 2.0 * 35.0) - .add_sample(40.0, 2.0 * 40.0) - .add_sample(45.0, 2.0 * 45.0); -} - -public node f136_v8 { - alias output __out: engine; - - engine engine( - name: "Ferrari F136", - starter_torque: 200 * units.lb_ft, - starter_speed: 200 * units.rpm, - redline: 9000 * units.rpm, - throttle_gamma: 2.0, - fuel: fuel( - max_burning_efficiency: 1.0, - turbulence_to_flame_speed_ratio: turbulence_to_flame_speed_ratio() - ), - hf_gain: 0.01, - noise: 1.0, - jitter: 0.15, - simulation_frequency: 10000 - ) - - wires wires() - - label stroke(81 * units.mm) - label bore(94 * units.mm) - label rod_length(160 * units.mm) - label rod_mass(50 * units.g) - label compression_height(1.0 * units.inch) - label crank_mass(60 * units.lb) - label flywheel_mass(30 * units.lb) - label flywheel_radius(8 * units.inch) - - label crank_moment( - 1.5 * disk_moment_of_inertia(mass: crank_mass, radius: stroke) - ) - label flywheel_moment( - disk_moment_of_inertia(mass: flywheel_mass, radius: flywheel_radius) - ) - label other_moment( // Moment from cams, pulleys, etc [estimated] - disk_moment_of_inertia(mass: 1 * units.kg, radius: 1.0 * units.cm) - ) - - label v_angle(90 * units.deg) - crankshaft c0( - throw: stroke / 2, - flywheel_mass: flywheel_mass, - mass: crank_mass, - friction_torque: 20.0 * units.lb_ft, - moment_of_inertia: - crank_moment + flywheel_moment + other_moment, - position_x: 0.0, - position_y: 0.0, - tdc: 90 * units.deg + (v_angle / 2.0) - ) - - // 1 5 3 7 4 8 2 6 - rod_journal rj0(angle: 0 * units.deg) - rod_journal rj1(angle: 180 * units.deg) - rod_journal rj2(angle: 180 * units.deg) - rod_journal rj3(angle: 0 * units.deg) - c0 - .add_rod_journal(rj0) - .add_rod_journal(rj1) - .add_rod_journal(rj2) - .add_rod_journal(rj3) - - piston_parameters piston_params( - // 414 - piston mass, 152 - pin weight - mass: (100) * units.g, - compression_height: compression_height, - wrist_pin_position: 0.0, - displacement: 0.0 - ) - - connecting_rod_parameters cr_params( - mass: rod_mass, - moment_of_inertia: rod_moment_of_inertia( - mass: rod_mass, - length: rod_length - ), - center_of_mass: 0.0, - length: rod_length - ) - - intake intake( - plenum_volume: 1.325 * units.L, - plenum_cross_section_area: 20.0 * units.cm2, - intake_flow_rate: k_carb(700.0), - runner_flow_rate: k_carb(100.0), - runner_length: 12.0 * units.inch, - idle_flow_rate: k_carb(0.0), - idle_throttle_plate_position: 0.995, - velocity_decay: 0.5 - ) - - exhaust_system_parameters es_params( - outlet_flow_rate: k_carb(1000.0), - primary_tube_length: 29.0 * units.inch, - primary_flow_rate: k_carb(600.0), - velocity_decay: 0.5 - ) - - exhaust_system exhaust0( - es_params, - audio_volume: 2.0 * 0.1, - length: 100 * units.inch, - impulse_response: ir_lib.mild_exhaust_0_reverb - - ) - exhaust_system exhaust1( - es_params, - audio_volume: 2.0 * 0.09, - length: 100 * units.inch, - impulse_response: ir_lib.mild_exhaust_0_reverb - ) - - cylinder_bank_parameters bank_params( - bore: bore, - deck_height: stroke / 2 + rod_length + compression_height - ) - - label spacing(5 * units.inch) - - cylinder_bank b0(bank_params, angle: v_angle / 2.0) - cylinder_bank b1(bank_params, angle: -v_angle / 2.0) - b0 - .add_cylinder( - piston: piston(piston_params, blowby: k_28inH2O(0.0)), - connecting_rod: connecting_rod(cr_params), - rod_journal: rj0, - intake: intake, - exhaust_system: exhaust0, - ignition_wire: wires.wire1, - sound_attenuation: 0.9, - primary_length: 2 * units.cm - ) - .add_cylinder( - piston: piston(piston_params, blowby: k_28inH2O(0.0)), - connecting_rod: connecting_rod(cr_params), - rod_journal: rj1, - intake: intake, - exhaust_system: exhaust0, - ignition_wire: wires.wire2, - sound_attenuation: 0.8, - primary_length: 1 * units.cm - ) - .add_cylinder( - piston: piston(piston_params, blowby: k_28inH2O(0.0)), - connecting_rod: connecting_rod(cr_params), - rod_journal: rj2, - intake: intake, - exhaust_system: exhaust0, - ignition_wire: wires.wire3, - sound_attenuation: 1.1, - primary_length: 3 * units.cm - ) - .add_cylinder( - piston: piston(piston_params, blowby: k_28inH2O(0.0)), - connecting_rod: connecting_rod(cr_params), - rod_journal: rj3, - intake: intake, - exhaust_system: exhaust0, - ignition_wire: wires.wire4, - sound_attenuation: 1.0, - primary_length: 5 * units.cm - ) - .set_cylinder_head( - f136_head( - intake_camshaft: camshaft.intake_cam_0, - exhaust_camshaft: camshaft.exhaust_cam_0, - flip_display: true, - flow_attenuation: 1.0) - ) - b1 - .add_cylinder( - piston: piston(piston_params, blowby: k_28inH2O(0.0)), - connecting_rod: connecting_rod(cr_params), - rod_journal: rj0, - intake: intake, - exhaust_system: exhaust1, - ignition_wire: wires.wire5, - sound_attenuation: 1.0, - primary_length: 1 * units.cm - ) - .add_cylinder( - piston: piston(piston_params, blowby: k_28inH2O(0.0)), - connecting_rod: connecting_rod(cr_params), - rod_journal: rj1, - intake: intake, - exhaust_system: exhaust1, - ignition_wire: wires.wire6, - sound_attenuation: 0.8, - primary_length: 5 * units.cm - ) - .add_cylinder( - piston: piston(piston_params, blowby: k_28inH2O(0.0)), - connecting_rod: connecting_rod(cr_params), - rod_journal: rj2, - intake: intake, - exhaust_system: exhaust1, - ignition_wire: wires.wire7, - sound_attenuation: 0.9, - primary_length: 7 * units.cm - ) - .add_cylinder( - piston: piston(piston_params, blowby: k_28inH2O(0.0)), - connecting_rod: connecting_rod(cr_params), - rod_journal: rj3, - intake: intake, - exhaust_system: exhaust1, - ignition_wire: wires.wire8, - sound_attenuation: 0.7, - primary_length: 0 * units.cm - ) - .set_cylinder_head( - f136_head( - intake_camshaft: camshaft.intake_cam_1, - exhaust_camshaft: camshaft.exhaust_cam_1, - flow_attenuation: 1.0) - ) - - engine - .add_cylinder_bank(b0) - .add_cylinder_bank(b1) - - engine.add_crankshaft(c0) - - harmonic_cam_lobe intake_lobe( - duration_at_50_thou: 230 * units.deg, - gamma: 0.9, - lift: 551 * units.thou, - steps: 256 - ) - - harmonic_cam_lobe exhaust_lobe( - duration_at_50_thou: 230 * units.deg, - gamma: 0.9, - lift: 551 * units.thou, - steps: 256 - ) - - f136_camshaft camshaft( - lobe_profile: "N/A", - - intake_lobe_profile: intake_lobe, - exhaust_lobe_profile: exhaust_lobe, - intake_lobe_center: 116 * units.deg, - exhaust_lobe_center: 116 * units.deg, - base_radius: 1.0 * units.inch - ) - - function timing_curve(1000 * units.rpm) - timing_curve - .add_sample(0000 * units.rpm, 12 * units.deg) - .add_sample(1000 * units.rpm, 12 * units.deg) - .add_sample(2000 * units.rpm, 20 * units.deg) - .add_sample(3000 * units.rpm, 30 * units.deg) - .add_sample(4000 * units.rpm, 40 * units.deg) - .add_sample(5000 * units.rpm, 40 * units.deg) - .add_sample(6000 * units.rpm, 40 * units.deg) - .add_sample(7000 * units.rpm, 40 * units.deg) - .add_sample(8000 * units.rpm, 40 * units.deg) - - ignition_module ignition_module( - timing_curve: timing_curve, - rev_limit: 9300 * units.rpm, - limiter_duration: 0.1) - ignition_module - .connect_wire(wires.wire1, 0 * 90 * units.deg) - .connect_wire(wires.wire5, 1 * 90 * units.deg) - .connect_wire(wires.wire3, 2 * 90 * units.deg) - .connect_wire(wires.wire7, 3 * 90 * units.deg) - .connect_wire(wires.wire4, 4 * 90 * units.deg) - .connect_wire(wires.wire8, 5 * 90 * units.deg) - .connect_wire(wires.wire2, 6 * 90 * units.deg) - .connect_wire(wires.wire6, 7 * 90 * units.deg) - - engine.add_ignition_module(ignition_module) -} - -private node mustang_vehicle { - alias output __out: - vehicle( - mass: 1614 * units.kg, - drag_coefficient: 0.3, - cross_sectional_area: (72 * units.inch) * (50 * units.inch), - diff_ratio: 3.42, - tire_radius: 10 * units.inch, - rolling_resistance: 200 * units.N - ); -} - -private node mustang_transmission { - alias output __out: - transmission( - max_clutch_torque: 500 * units.lb_ft - ) - .add_gear(3.23) - .add_gear(2.19) - .add_gear(1.61) - .add_gear(1.23) - .add_gear(0.97) - .add_gear(0.8); -} - -public node main { - set_engine(f136_v8()) - set_vehicle(mustang_vehicle()) - set_transmission(mustang_transmission()) -} diff --git a/es/engines/atg-video-2/09_radial_9.mr b/es/engines/atg-video-2/09_radial_9.mr deleted file mode 100644 index 52d9883..0000000 --- a/es/engines/atg-video-2/09_radial_9.mr +++ /dev/null @@ -1,402 +0,0 @@ -import "engine_sim.mr" - -import "radial.mr" - -units units() -constants constants() -impulse_response_library ir_lib() - -private node wires { - output wire1: ignition_wire(); - output wire2: ignition_wire(); - output wire3: ignition_wire(); - output wire4: ignition_wire(); - output wire5: ignition_wire(); - output wire6: ignition_wire(); - output wire7: ignition_wire(); - output wire8: ignition_wire(); - output wire9: ignition_wire(); -} - -label cycle(2 * 360 * units.deg) -public node radial_9_distributor { - input wires; - input timing_curve; - input rev_limit: 5500 * units.rpm; - alias output __out: - ignition_module( - timing_curve: timing_curve, - rev_limit: rev_limit, - limiter_duration: 0.2 - ) - .connect_wire(wires.wire1, (0 / 9.0) * cycle) - .connect_wire(wires.wire3, (1 / 9.0) * cycle) - .connect_wire(wires.wire5, (2 / 9.0) * cycle) - .connect_wire(wires.wire7, (3 / 9.0) * cycle) - .connect_wire(wires.wire9, (4 / 9.0) * cycle) - .connect_wire(wires.wire2, (5 / 9.0) * cycle) - .connect_wire(wires.wire4, (6 / 9.0) * cycle) - .connect_wire(wires.wire6, (7 / 9.0) * cycle) - .connect_wire(wires.wire8, (8 / 9.0) * cycle); -} - -public node radial_9 { - alias output __out: engine; - - engine engine( - name: "Radial 9", - starter_torque: 80 * units.lb_ft, - starter_speed: 400 * units.rpm, - redline: 3000 * units.rpm, - fuel: fuel( - //max_turbulence_effect: 0.5, - //max_burning_efficiency: 1.0 - ), - simulation_frequency: 7500 - ) - - wires wires() - - label slave_throw(3.5 * units.inch) - label stroke(5.5 * units.inch) - label bore(5 * units.inch) - label rod_length(16 * units.inch) - label compression_height(1.0 * units.inch) - label rod_mass(535 * units.g) - label crank_mass(20.39 * units.kg) - label flywheel_mass(50 * units.kg) - label flywheel_radius(12 * units.inch) - - label crank_moment( - disk_moment_of_inertia(mass: crank_mass, radius: stroke / 2) - ) - label flywheel_moment( - disk_moment_of_inertia(mass: flywheel_mass, radius: flywheel_radius) - ) - label other_moment( // Moment from cams, pulleys, etc [estimated] - disk_moment_of_inertia(mass: 10 * units.kg, radius: 2.0 * units.cm) - ) - - crankshaft c0( - throw: stroke / 2, - flywheel_mass: 10 * units.lb, - mass: 10 * units.lb, - friction_torque: 10.0 * units.lb_ft, - moment_of_inertia: - crank_moment + flywheel_moment + other_moment, - position_x: 0.0, - position_y: 0.0, - tdc: (90 - 0.5 * 45) * units.deg - ) - - rod_journal rj0(angle: 0.0) - c0 - .add_rod_journal(rj0) - - piston_parameters piston_params( - mass: 10 * units.g, - compression_height: compression_height, - wrist_pin_position: 0.0, - displacement: 0.0 - ) - - connecting_rod_parameters cr_params( - mass: 100.0 * units.g, - moment_of_inertia: 0.0015884918028487504, - center_of_mass: 0.0, - length: rod_length - slave_throw - ) - - intake intake( - plenum_volume: 10.5 * units.L, - plenum_cross_section_area: 10.0 * units.cm2, - intake_flow_rate: k_carb(1000.0), - idle_flow_rate: k_carb(0.0), - idle_throttle_plate_position: 0.993, - throttle_gamma: 1.0, - velocity_decay: 1.0 - ) - - exhaust_system_parameters es_params( - outlet_flow_rate: k_carb(2000.0), - primary_tube_length: 70.0 * units.inch, - primary_flow_rate: k_carb(1000.0), - velocity_decay: 0.75, - length: 100 * units.inch - ) - - exhaust_system exhaust0( - es_params, - audio_volume: 1.0, - impulse_response: ir_lib.mild_exhaust_0_reverb - ) - - exhaust_system exhaust1( - es_params, - audio_volume: 1.0, - impulse_response: ir_lib.mild_exhaust_0_reverb - ) - - cylinder_bank_parameters bank_params( - bore: bore, - deck_height: stroke / 2 + rod_length + compression_height - ) - - connecting_rod master( - connecting_rod_parameters( - cr_params, - slave_throw: slave_throw, - length: rod_length - ) - ) - - rod_journal sj0(angle: (0 / 9.0) * 360 * units.deg) - rod_journal sj1(angle: (1 / 9.0) * 360 * units.deg) - rod_journal sj2(angle: (2 / 9.0) * 360 * units.deg) - rod_journal sj3(angle: (3 / 9.0) * 360 * units.deg) - rod_journal sj4(angle: (4 / 9.0) * 360 * units.deg) - rod_journal sj5(angle: (5 / 9.0) * 360 * units.deg) - rod_journal sj6(angle: (6 / 9.0) * 360 * units.deg) - rod_journal sj7(angle: (7 / 9.0) * 360 * units.deg) - rod_journal sj8(angle: (8 / 9.0) * 360 * units.deg) - master - .add_slave_journal(sj0) - .add_slave_journal(sj1) - .add_slave_journal(sj2) - .add_slave_journal(sj3) - .add_slave_journal(sj4) - .add_slave_journal(sj5) - .add_slave_journal(sj6) - .add_slave_journal(sj7) - .add_slave_journal(sj8) - - label spacing(10 * units.inch) - - cylinder_bank b0(bank_params, angle: (0 / 9.0) * 360 * units.deg) - b0 - .add_cylinder( - piston: piston(piston_params, blowby: k_28inH2O(0.2)), - connecting_rod: master, - rod_journal: rj0, - intake: intake, - exhaust_system: exhaust0, - ignition_wire: wires.wire1, - primary_length: 6.11 * units.foot - ) - - cylinder_bank b1(bank_params, angle: (1 / 9.0) * 360 * units.deg) - b1 - .add_cylinder( - piston: piston(piston_params, blowby: k_28inH2O(0.03)), - connecting_rod: connecting_rod(cr_params), - rod_journal: sj1, - intake: intake, - exhaust_system: exhaust0, - ignition_wire: wires.wire9, - primary_length: 7.46 * units.foot - ) - - cylinder_bank b2(bank_params, angle: (2 / 9.0) * 360 * units.deg) - b2 - .add_cylinder( - piston: piston(piston_params, blowby: k_28inH2O(0.1)), - connecting_rod: connecting_rod(cr_params), - rod_journal: sj2, - intake: intake, - exhaust_system: exhaust0, - ignition_wire: wires.wire8, - primary_length: 8.31 * units.foot - ) - - cylinder_bank b3(bank_params, angle: (3 / 9.0) * 360 * units.deg) - b3 - .add_cylinder( - piston: piston(piston_params, blowby: k_28inH2O(0.1)), - connecting_rod: connecting_rod(cr_params), - rod_journal: sj3, - intake: intake, - exhaust_system: exhaust0, - ignition_wire: wires.wire7, - primary_length: 8.45 * units.foot - ) - cylinder_bank b4(bank_params, angle: (4 / 9.0) * 360 * units.deg) - b4 - .add_cylinder( - piston: piston(piston_params, blowby: k_28inH2O(0.5)), - connecting_rod: connecting_rod(cr_params), - rod_journal: sj4, - intake: intake, - exhaust_system: exhaust1, - ignition_wire: wires.wire6, - primary_length: 7.84 * units.foot - ) - cylinder_bank b5(bank_params, angle: (5 / 9.0) * 360 * units.deg) - b5 - .add_cylinder( - piston: piston(piston_params, blowby: k_28inH2O(0.5)), - connecting_rod: connecting_rod(cr_params), - rod_journal: sj5, - intake: intake, - exhaust_system: exhaust1, - ignition_wire: wires.wire5, - primary_length: 6.63 * units.foot - ) - cylinder_bank b6(bank_params, angle: (6 / 9.0) * 360 * units.deg) - b6 - .add_cylinder( - piston: piston(piston_params, blowby: k_28inH2O(0.5)), - connecting_rod: connecting_rod(cr_params), - rod_journal: sj6, - intake: intake, - exhaust_system: exhaust1, - ignition_wire: wires.wire4, - primary_length: 5.2 * units.foot - ) - cylinder_bank b7(bank_params, angle: (7 / 9.0) * 360 * units.deg) - b7 - .add_cylinder( - piston: piston(piston_params, blowby: k_28inH2O(0.5)), - connecting_rod: connecting_rod(cr_params), - rod_journal: sj7, - intake: intake, - exhaust_system: exhaust1, - ignition_wire: wires.wire3, - primary_length: 4.33 * units.foot - ) - cylinder_bank b8(bank_params, angle: (8 / 9.0) * 360 * units.deg) - b8 - .add_cylinder( - piston: piston(piston_params, blowby: k_28inH2O(0.5)), - connecting_rod: connecting_rod(cr_params), - rod_journal: sj8, - intake: intake, - exhaust_system: exhaust1, - ignition_wire: wires.wire2, - primary_length: 4.77 * units.foot - ) - - engine - .add_cylinder_bank(b0) - .add_cylinder_bank(b1) - .add_cylinder_bank(b2) - .add_cylinder_bank(b3) - .add_cylinder_bank(b4) - .add_cylinder_bank(b5) - .add_cylinder_bank(b6) - .add_cylinder_bank(b7) - .add_cylinder_bank(b8) - - engine.add_crankshaft(c0) - - harmonic_cam_lobe lobe( - duration_at_50_thou: 260 * units.deg, - gamma: 0.9, - lift: 800 * units.thou, - steps: 100 - ) - - b0.set_cylinder_head ( - radial_head( - offset: 0 / 9.0, - lobe_profile: lobe - ) - ) - - b1.set_cylinder_head ( - radial_head( - offset: 4 / 9.0, - lobe_profile: lobe - ) - ) - - b2.set_cylinder_head ( - radial_head( - offset: 8 / 9.0, - lobe_profile: lobe - ) - ) - - b3.set_cylinder_head ( - radial_head( - offset: 3 / 9.0, - lobe_profile: lobe - ) - ) - - b4.set_cylinder_head ( - radial_head( - offset: 7 / 9.0, - lobe_profile: lobe - ) - ) - - b5.set_cylinder_head ( - radial_head( - offset: 2 / 9.0, - lobe_profile: lobe - ) - ) - - b6.set_cylinder_head ( - radial_head( - offset: 6 / 9.0, - lobe_profile: lobe - ) - ) - - b7.set_cylinder_head ( - radial_head( - offset: 1 / 9.0, - lobe_profile: lobe - ) - ) - - b8.set_cylinder_head ( - radial_head( - offset: 5 / 9.0, - lobe_profile: lobe - ) - ) - - function timing_curve(1000 * units.rpm) - timing_curve - .add_sample(0000 * units.rpm, 18 * units.deg) - .add_sample(1000 * units.rpm, 18 * units.deg) - .add_sample(2000 * units.rpm, 30 * units.deg) - .add_sample(3000 * units.rpm, 40 * units.deg) - .add_sample(4000 * units.rpm, 40 * units.deg) - - engine.add_ignition_module( - radial_9_distributor( - wires: wires, - timing_curve: timing_curve, - rev_limit: 3500 * units.rpm - )) -} - -label car_mass(2700 * units.lb) -private node random_car { - alias output __out: - vehicle( - mass: car_mass, - drag_coefficient: 0.3, - cross_sectional_area: (72 * units.inch) * (56 * units.inch), - diff_ratio: 3.9, - tire_radius: 10 * units.inch, - rolling_resistance: 10000 - ); -} - -private node random_transmission { - alias output __out: - transmission( - max_clutch_torque: 2000 * units.lb_ft - ) - .add_gear(0.01); -} - -public node main { - set_engine(radial_9()) - set_vehicle(random_car()) - set_transmission(random_transmission()) -} diff --git a/es/engines/atg-video-2/10_lfa_v10.mr b/es/engines/atg-video-2/10_lfa_v10.mr deleted file mode 100644 index e4958e4..0000000 --- a/es/engines/atg-video-2/10_lfa_v10.mr +++ /dev/null @@ -1,460 +0,0 @@ -import "engine_sim.mr" - -units units() -constants constants() -impulse_response_library ir_lib() -label cycle(2 * 360 * units.deg) - -private node wires { - output wire1: ignition_wire(); - output wire2: ignition_wire(); - output wire3: ignition_wire(); - output wire4: ignition_wire(); - output wire5: ignition_wire(); - output wire6: ignition_wire(); - output wire7: ignition_wire(); - output wire8: ignition_wire(); - output wire9: ignition_wire(); - output wire10: ignition_wire(); -} - -private node v10_72_head { - input intake_camshaft; - input exhaust_camshaft; - input chamber_volume: 1.5 * 25 * units.cc; - input intake_runner_volume: 149.6 * units.cc; - input intake_runner_cross_section_area: 1.75 * units.inch * 1.75 * units.inch; - input exhaust_runner_volume: 50.0 * units.cc; - input exhaust_runner_cross_section_area: 2.5 * units.inch * 2.5 * units.inch; - - input flow_attenuation: 1.0; - input lift_scale: 1.0; - input flip_display: false; - alias output __out: head; - - function intake_flow(50 * units.thou) - intake_flow - .add_flow_sample(0 * lift_scale, 0 * flow_attenuation) - .add_flow_sample(50 * lift_scale, 58 * flow_attenuation) - .add_flow_sample(100 * lift_scale, 103 * flow_attenuation) - .add_flow_sample(150 * lift_scale, 156 * flow_attenuation) - .add_flow_sample(200 * lift_scale, 214 * flow_attenuation) - .add_flow_sample(250 * lift_scale, 249 * flow_attenuation) - .add_flow_sample(300 * lift_scale, 268 * flow_attenuation) - .add_flow_sample(350 * lift_scale, 280 * flow_attenuation) - .add_flow_sample(400 * lift_scale, 280 * flow_attenuation) - .add_flow_sample(450 * lift_scale, 281 * flow_attenuation) - - function exhaust_flow(50 * units.thou) - exhaust_flow - .add_flow_sample(0 * lift_scale, 0 * flow_attenuation) - .add_flow_sample(50 * lift_scale, 37 * flow_attenuation) - .add_flow_sample(100 * lift_scale, 72 * flow_attenuation) - .add_flow_sample(150 * lift_scale, 113 * flow_attenuation) - .add_flow_sample(200 * lift_scale, 160 * flow_attenuation) - .add_flow_sample(250 * lift_scale, 196 * flow_attenuation) - .add_flow_sample(300 * lift_scale, 222 * flow_attenuation) - .add_flow_sample(350 * lift_scale, 235 * flow_attenuation) - .add_flow_sample(400 * lift_scale, 245 * flow_attenuation) - .add_flow_sample(450 * lift_scale, 246 * flow_attenuation) - - generic_cylinder_head head( - chamber_volume: chamber_volume, - intake_runner_volume: intake_runner_volume, - intake_runner_cross_section_area: intake_runner_cross_section_area, - exhaust_runner_volume: exhaust_runner_volume, - exhaust_runner_cross_section_area: exhaust_runner_cross_section_area, - - intake_port_flow: intake_flow, - exhaust_port_flow: exhaust_flow, - valvetrain: standard_valvetrain( - intake_camshaft: intake_camshaft, - exhaust_camshaft: exhaust_camshaft - ), - flip_display: flip_display - ) -} - -private node v10_72_camshaft { - input lobe_profile; - input intake_lobe_profile: lobe_profile; - input exhaust_lobe_profile: lobe_profile; - input lobe_separation: 114 * units.deg; - input intake_lobe_center: lobe_separation; - input exhaust_lobe_center: lobe_separation; - input advance: 0 * units.deg; - input base_radius: 0.5 * units.inch; - - output intake_cam_0: _intake_cam_0; - output exhaust_cam_0: _exhaust_cam_0; - - output intake_cam_1: _intake_cam_1; - output exhaust_cam_1: _exhaust_cam_1; - - camshaft_parameters params ( - advance: advance, - base_radius: base_radius - ) - - camshaft _intake_cam_0(params, lobe_profile: intake_lobe_profile) - camshaft _exhaust_cam_0(params, lobe_profile: exhaust_lobe_profile) - camshaft _intake_cam_1(params, lobe_profile: intake_lobe_profile) - camshaft _exhaust_cam_1(params, lobe_profile: exhaust_lobe_profile) - - label rot(72 * units.deg) - label rot360(360 * units.deg) - - // 1 2 3 4 7 8 9 10 5 6 - _exhaust_cam_0 - .add_lobe(rot360 - exhaust_lobe_center + 0 * rot) // 1 - .add_lobe(rot360 - exhaust_lobe_center + 2 * rot) // 3 - .add_lobe(rot360 - exhaust_lobe_center + 8 * rot) // 5 - .add_lobe(rot360 - exhaust_lobe_center + 4 * rot) // 7 - .add_lobe(rot360 - exhaust_lobe_center + 6 * rot) // 9 - _intake_cam_0 - .add_lobe(rot360 + intake_lobe_center + 0 * rot) // 1 - .add_lobe(rot360 + intake_lobe_center + 2 * rot) // 3 - .add_lobe(rot360 + intake_lobe_center + 8 * rot) // 5 - .add_lobe(rot360 + intake_lobe_center + 4 * rot) // 7 - .add_lobe(rot360 + intake_lobe_center + 6 * rot) // 9 - - _exhaust_cam_1 - .add_lobe(rot360 - exhaust_lobe_center + 1 * rot) // 2 - .add_lobe(rot360 - exhaust_lobe_center + 3 * rot) // 4 - .add_lobe(rot360 - exhaust_lobe_center + 9 * rot) // 6 - .add_lobe(rot360 - exhaust_lobe_center + 5 * rot) // 8 - .add_lobe(rot360 - exhaust_lobe_center + 7 * rot) // 10 - _intake_cam_1 - .add_lobe(rot360 + intake_lobe_center + 1 * rot) // 2 - .add_lobe(rot360 + intake_lobe_center + 3 * rot) // 4 - .add_lobe(rot360 + intake_lobe_center + 9 * rot) // 6 - .add_lobe(rot360 + intake_lobe_center + 5 * rot) // 8 - .add_lobe(rot360 + intake_lobe_center + 7 * rot) // 10 -} - -public node lr_gue_v10 { - alias output __out: engine; - - engine engine( - name: "1LR-GUE [V10]", - starter_torque: 100 * units.lb_ft, - starter_speed: 200 * units.rpm, - redline: 9000 * units.rpm, - throttle_gamma: 2.0, - fuel: fuel( - max_turbulence_effect: 10.0, - max_dilution_effect: 20.0, - burning_efficiency_randomness: 0.25, - max_burning_efficiency: 1.0 - ), - hf_gain: 0.01, - noise: 1.0, - jitter: 0.1, - simulation_frequency: 6500 - ) - - wires wires() - - label stroke(79 * units.mm) - label bore(88 * units.mm) - label rod_length(130 * units.mm) - label rod_mass(50 * units.g) - label compression_height(1.0 * units.inch) - label crank_mass(40 * units.lb) - label flywheel_mass(30 * units.lb) - label flywheel_radius(6.5 * units.inch) - - label crank_moment( - disk_moment_of_inertia(mass: crank_mass, radius: stroke) - ) - label flywheel_moment( - disk_moment_of_inertia(mass: flywheel_mass, radius: flywheel_radius) - ) - label other_moment( // Moment from cams, pulleys, etc [estimated] - disk_moment_of_inertia(mass: 1 * units.kg, radius: 1.0 * units.cm) - ) - - label v_angle(72 * units.deg) - crankshaft c0( - throw: stroke / 2, - flywheel_mass: flywheel_mass, - mass: crank_mass, - friction_torque: 0.0 * units.lb_ft, - moment_of_inertia: - crank_moment + flywheel_moment + other_moment, - position_x: 0.0, - position_y: 0.0, - tdc: 90 * units.deg + (v_angle / 2.0) - ) - - // 72 degrees - rod_journal rj0(angle: 0 * v_angle) - rod_journal rj1(angle: 2 * v_angle) - rod_journal rj2(angle: 3 * v_angle) - rod_journal rj3(angle: 4 * v_angle) - rod_journal rj4(angle: 1 * v_angle) - c0 - .add_rod_journal(rj0) - .add_rod_journal(rj1) - .add_rod_journal(rj2) - .add_rod_journal(rj3) - .add_rod_journal(rj4) - - piston_parameters piston_params( - mass: (100) * units.g, // 414 - piston mass, 152 - pin weight - compression_height: compression_height, - wrist_pin_position: 0.0, - displacement: 0.0 - ) - - connecting_rod_parameters cr_params( - mass: rod_mass, - moment_of_inertia: rod_moment_of_inertia( - mass: rod_mass, - length: rod_length - ), - center_of_mass: 0.0, - length: rod_length - ) - - intake intake( - plenum_volume: 1.325 * units.L, - plenum_cross_section_area: 20.0 * units.cm2, - intake_flow_rate: k_carb(1000.0), - runner_flow_rate: k_carb(200.0), - runner_length: 4.0 * units.inch, - idle_flow_rate: k_carb(0.0), - idle_throttle_plate_position: 0.998, - velocity_decay: 0.5 - ) - - exhaust_system_parameters es_params( - outlet_flow_rate: k_carb(2000.0), - primary_tube_length: 50.0 * units.inch, - primary_flow_rate: k_carb(1000.0), - velocity_decay: 1.0 - ) - - exhaust_system exhaust0( - es_params, - audio_volume: 2.0, - length: 100 * units.inch, - impulse_response: ir_lib.mild_exhaust_0_reverb - ) - exhaust_system exhaust1( - es_params, - audio_volume: 2.0, - length: 100.5 * units.inch, - impulse_response: ir_lib.mild_exhaust_0_reverb - ) - - cylinder_bank_parameters bank_params( - bore: bore, - deck_height: stroke / 2 + rod_length + compression_height - ) - - cylinder_bank b0(bank_params, angle: v_angle / 2.0) - cylinder_bank b1(bank_params, angle: -v_angle / 2.0) - b0 - .add_cylinder( - piston: piston(piston_params, blowby: k_28inH2O(0.0)), - connecting_rod: connecting_rod(cr_params), - rod_journal: rj0, - intake: intake, - exhaust_system: exhaust1, - ignition_wire: wires.wire1, - sound_attenuation: 0.8, - primary_length: 5 * units.cm - ) - .add_cylinder( - piston: piston(piston_params, blowby: k_28inH2O(0.0)), - connecting_rod: connecting_rod(cr_params), - rod_journal: rj1, - intake: intake, - exhaust_system: exhaust1, - ignition_wire: wires.wire3, - sound_attenuation: 1.0, - primary_length: 4 * units.cm - ) - .add_cylinder( - piston: piston(piston_params, blowby: k_28inH2O(0.0)), - connecting_rod: connecting_rod(cr_params), - rod_journal: rj2, - intake: intake, - exhaust_system: exhaust1, - ignition_wire: wires.wire5, - sound_attenuation: 1.1, - primary_length: 3 * units.cm - ) - .add_cylinder( - piston: piston(piston_params, blowby: k_28inH2O(0.0)), - connecting_rod: connecting_rod(cr_params), - rod_journal: rj3, - intake: intake, - exhaust_system: exhaust1, - ignition_wire: wires.wire7, - sound_attenuation: 0.9, - primary_length: 2 * units.cm - ) - .add_cylinder( - piston: piston(piston_params, blowby: k_28inH2O(0.0)), - connecting_rod: connecting_rod(cr_params), - rod_journal: rj4, - intake: intake, - exhaust_system: exhaust1, - ignition_wire: wires.wire9, - sound_attenuation: 0.7, - primary_length: 1 * units.cm - ) - .set_cylinder_head( - v10_72_head( - intake_camshaft: camshaft.intake_cam_0, - exhaust_camshaft: camshaft.exhaust_cam_0, - flip_display: true, - flow_attenuation: 1.5) - ) - b1 - .add_cylinder( - piston: piston(piston_params, blowby: k_28inH2O(0.0)), - connecting_rod: connecting_rod(cr_params), - rod_journal: rj0, - intake: intake, - exhaust_system: exhaust0, - ignition_wire: wires.wire2, - sound_attenuation: 0.7, - primary_length: 5 * units.cm - ) - .add_cylinder( - piston: piston(piston_params, blowby: k_28inH2O(0.0)), - connecting_rod: connecting_rod(cr_params), - rod_journal: rj1, - intake: intake, - exhaust_system: exhaust0, - ignition_wire: wires.wire4, - sound_attenuation: 0.8, - primary_length: 4 * units.cm - ) - .add_cylinder( - piston: piston(piston_params, blowby: k_28inH2O(0.0)), - connecting_rod: connecting_rod(cr_params), - rod_journal: rj2, - intake: intake, - exhaust_system: exhaust0, - ignition_wire: wires.wire6, - primary_length: 3 * units.cm - ) - .add_cylinder( - piston: piston(piston_params, blowby: k_28inH2O(0.0)), - connecting_rod: connecting_rod(cr_params), - rod_journal: rj3, - intake: intake, - exhaust_system: exhaust0, - ignition_wire: wires.wire8, - sound_attenuation: 1.1, - primary_length: 2 * units.cm - ) - .add_cylinder( - piston: piston(piston_params, blowby: k_28inH2O(0.0)), - connecting_rod: connecting_rod(cr_params), - rod_journal: rj4, - intake: intake, - exhaust_system: exhaust0, - ignition_wire: wires.wire10, - sound_attenuation: 0.7, - primary_length: 1 * units.cm - ) - .set_cylinder_head( - v10_72_head( - intake_camshaft: camshaft.intake_cam_1, - exhaust_camshaft: camshaft.exhaust_cam_1, - flow_attenuation: 1.5) - ) - - engine - .add_cylinder_bank(b0) - .add_cylinder_bank(b1) - - engine.add_crankshaft(c0) - - harmonic_cam_lobe intake_lobe( - duration_at_50_thou: 230 * units.deg, - gamma: 1.1, - lift: 15.95 * units.mm, - steps: 100 - ) - - harmonic_cam_lobe exhaust_lobe( - duration_at_50_thou: 230 * units.deg, - gamma: 1.1, - lift: 15.95 * units.mm, - steps: 100 - ) - - v10_72_camshaft camshaft( - lobe_profile: "N/A", - - intake_lobe_profile: intake_lobe, - exhaust_lobe_profile: exhaust_lobe, - intake_lobe_center: 90 * units.deg, - exhaust_lobe_center: 112 * units.deg, - base_radius: 0.9 * units.inch - ) - - function timing_curve(4000 * units.rpm) - timing_curve - .add_sample(0000 * units.rpm, 12 * units.deg) - .add_sample(4000 * units.rpm, 40 * units.deg) - .add_sample(8000 * units.rpm, 40 * units.deg) - .add_sample(12000 * units.rpm, 40 * units.deg) - .add_sample(14000 * units.rpm, 40 * units.deg) - .add_sample(18000 * units.rpm, 40 * units.deg) - - ignition_module ignition_module( - timing_curve: timing_curve, - rev_limit: 9500 * units.rpm, - limiter_duration: 0.1) - ignition_module - .connect_wire(wires.wire1, 0 * 72 * units.deg) - .connect_wire(wires.wire2, 1 * 72 * units.deg) - .connect_wire(wires.wire3, 2 * 72 * units.deg) - .connect_wire(wires.wire4, 3 * 72 * units.deg) - .connect_wire(wires.wire7, 4 * 72 * units.deg) - .connect_wire(wires.wire8, 5 * 72 * units.deg) - .connect_wire(wires.wire9, 6 * 72 * units.deg) - .connect_wire(wires.wire10, 7 * 72 * units.deg) - .connect_wire(wires.wire5, 8 * 72 * units.deg) - .connect_wire(wires.wire6, 9 * 72 * units.deg) - - engine.add_ignition_module(ignition_module) -} - -private node lfa_vehicle { - alias output __out: - vehicle( - mass: 1614 * units.kg, - drag_coefficient: 0.3, - cross_sectional_area: (72 * units.inch) * (50 * units.inch), - diff_ratio: 3.42, - tire_radius: 10 * units.inch, - rolling_resistance: 200 * units.N - ); -} - -private node lfa_transmission { - alias output __out: - transmission( - max_clutch_torque: 500 * units.lb_ft - ) - .add_gear(3.23) - .add_gear(2.19) - .add_gear(1.61) - .add_gear(1.23) - .add_gear(0.97) - .add_gear(0.8); -} - -public node main { - set_engine(lr_gue_v10()) - set_vehicle(lfa_vehicle()) - set_transmission(lfa_transmission()) -} diff --git a/es/engines/atg-video-2/11_merlin_v12.mr b/es/engines/atg-video-2/11_merlin_v12.mr deleted file mode 100644 index 3555d8d..0000000 --- a/es/engines/atg-video-2/11_merlin_v12.mr +++ /dev/null @@ -1,481 +0,0 @@ -import "engine_sim.mr" - -units units() -constants constants() -impulse_response_library ir_lib() -label cycle(2 * 360 * units.deg) - -private node wires { - output wire1a: ignition_wire(); - output wire2a: ignition_wire(); - output wire3a: ignition_wire(); - output wire4a: ignition_wire(); - output wire5a: ignition_wire(); - output wire6a: ignition_wire(); - output wire1b: ignition_wire(); - output wire2b: ignition_wire(); - output wire3b: ignition_wire(); - output wire4b: ignition_wire(); - output wire5b: ignition_wire(); - output wire6b: ignition_wire(); -} - -private node v12_60_head { - input intake_camshaft; - input exhaust_camshaft; - input chamber_volume: 450 * units.cc; - input intake_runner_volume: 149.6 * units.cc; - input intake_runner_cross_section_area: 2.0 * units.inch * 2.0 * units.inch; - input exhaust_runner_volume: 50.0 * units.cc; - input exhaust_runner_cross_section_area: 5.0 * units.inch * 3.0 * units.inch; - - input flow_attenuation: 1.0; - input lift_scale: 1.0; - input flip_display: false; - alias output __out: head; - - function intake_flow(50 * units.thou) - intake_flow - .add_flow_sample(0 * lift_scale, 0 * flow_attenuation) - .add_flow_sample(50 * lift_scale, 58 * flow_attenuation) - .add_flow_sample(100 * lift_scale, 103 * flow_attenuation) - .add_flow_sample(150 * lift_scale, 156 * flow_attenuation) - .add_flow_sample(200 * lift_scale, 214 * flow_attenuation) - .add_flow_sample(250 * lift_scale, 249 * flow_attenuation) - .add_flow_sample(300 * lift_scale, 268 * flow_attenuation) - .add_flow_sample(350 * lift_scale, 280 * flow_attenuation) - .add_flow_sample(400 * lift_scale, 280 * flow_attenuation) - .add_flow_sample(450 * lift_scale, 281 * flow_attenuation) - - function exhaust_flow(50 * units.thou) - exhaust_flow - .add_flow_sample(0 * lift_scale, 0 * flow_attenuation) - .add_flow_sample(50 * lift_scale, 37 * flow_attenuation) - .add_flow_sample(100 * lift_scale, 72 * flow_attenuation) - .add_flow_sample(150 * lift_scale, 113 * flow_attenuation) - .add_flow_sample(200 * lift_scale, 160 * flow_attenuation) - .add_flow_sample(250 * lift_scale, 196 * flow_attenuation) - .add_flow_sample(300 * lift_scale, 222 * flow_attenuation) - .add_flow_sample(350 * lift_scale, 235 * flow_attenuation) - .add_flow_sample(400 * lift_scale, 245 * flow_attenuation) - .add_flow_sample(450 * lift_scale, 246 * flow_attenuation) - - generic_cylinder_head head( - chamber_volume: chamber_volume, - intake_runner_volume: intake_runner_volume, - intake_runner_cross_section_area: intake_runner_cross_section_area, - exhaust_runner_volume: exhaust_runner_volume, - exhaust_runner_cross_section_area: exhaust_runner_cross_section_area, - - intake_port_flow: intake_flow, - exhaust_port_flow: exhaust_flow, - valvetrain: standard_valvetrain( - intake_camshaft: intake_camshaft, - exhaust_camshaft: exhaust_camshaft - ), - flip_display: flip_display - ) -} - -private node v12_60_camshaft { - input lobe_profile; - input intake_lobe_profile: lobe_profile; - input exhaust_lobe_profile: lobe_profile; - input lobe_separation: 114 * units.deg; - input intake_lobe_center: lobe_separation; - input exhaust_lobe_center: lobe_separation; - input advance: 0 * units.deg; - input base_radius: 0.5 * units.inch; - - output intake_cam_0: _intake_cam_0; - output exhaust_cam_0: _exhaust_cam_0; - - output intake_cam_1: _intake_cam_1; - output exhaust_cam_1: _exhaust_cam_1; - - camshaft_parameters params ( - advance: advance, - base_radius: base_radius - ) - - camshaft _intake_cam_0(params, lobe_profile: intake_lobe_profile) - camshaft _exhaust_cam_0(params, lobe_profile: exhaust_lobe_profile) - camshaft _intake_cam_1(params, lobe_profile: intake_lobe_profile) - camshaft _exhaust_cam_1(params, lobe_profile: exhaust_lobe_profile) - - label rot180(180 * units.deg) - label rot360(360 * units.deg) - - // 1a 6b 4a 3b 2a 5b 6a 1b 3a 4b 5a 2b - _exhaust_cam_0 - .add_lobe(rot360 - exhaust_lobe_center + 0 * units.deg) - .add_lobe(rot360 - exhaust_lobe_center + 240 * units.deg) - .add_lobe(rot360 - exhaust_lobe_center + 480 * units.deg) - .add_lobe(rot360 - exhaust_lobe_center + 120 * units.deg) - .add_lobe(rot360 - exhaust_lobe_center + 600 * units.deg) - .add_lobe(rot360 - exhaust_lobe_center + 360 * units.deg) - _intake_cam_0 - .add_lobe(rot360 + intake_lobe_center + 0 * units.deg) - .add_lobe(rot360 + intake_lobe_center + 240 * units.deg) - .add_lobe(rot360 + intake_lobe_center + 480 * units.deg) - .add_lobe(rot360 + intake_lobe_center + 120 * units.deg) - .add_lobe(rot360 + intake_lobe_center + 600 * units.deg) - .add_lobe(rot360 + intake_lobe_center + 360 * units.deg) - - _exhaust_cam_1 - .add_lobe(rot360 - exhaust_lobe_center + (360 + 60) * units.deg) - .add_lobe(rot360 - exhaust_lobe_center + (600 + 60) * units.deg) - .add_lobe(rot360 - exhaust_lobe_center + (120 + 60) * units.deg) - .add_lobe(rot360 - exhaust_lobe_center + (480 + 60) * units.deg) - .add_lobe(rot360 - exhaust_lobe_center + (240 + 60) * units.deg) - .add_lobe(rot360 - exhaust_lobe_center + (0 + 60) * units.deg) - _intake_cam_1 - .add_lobe(rot360 + intake_lobe_center + (360 + 60) * units.deg) - .add_lobe(rot360 + intake_lobe_center + (600 + 60) * units.deg) - .add_lobe(rot360 + intake_lobe_center + (120 + 60) * units.deg) - .add_lobe(rot360 + intake_lobe_center + (480 + 60) * units.deg) - .add_lobe(rot360 + intake_lobe_center + (240 + 60) * units.deg) - .add_lobe(rot360 + intake_lobe_center + (0 + 60) * units.deg) -} - -public node merlin_v12 { - alias output __out: engine; - - engine engine( - name: "Merlin V-1650-9 [V12] (NA)", - starter_torque: 190 * units.lb_ft, - starter_speed: 200 * units.rpm, - redline: 3000 * units.rpm, - fuel: fuel( - max_turbulence_effect: 10.0, - max_dilution_effect: 5.0, - burning_efficiency_randomness: 0.1, - max_burning_efficiency: 1.0 - ), - throttle_gamma: 2.0, - simulation_frequency: 7000, - hf_gain: 0.004, - noise: 0.35, - jitter: 0.229 - ) - - wires wires() - - label stroke(6 * units.inch) - label bore(5.4 * units.inch) - label rod_length(14 * units.inch) - label rod_mass(2000 * units.g) - label compression_height(1.0 * units.inch) - label crank_mass(400 * units.lb) - label flywheel_mass(200 * units.lb) - label flywheel_radius(12 * units.inch) - - label crank_moment( - disk_moment_of_inertia(mass: crank_mass, radius: stroke) - ) - label flywheel_moment( - disk_moment_of_inertia(mass: flywheel_mass, radius: flywheel_radius) - ) - label other_moment( // Moment from cams, pulleys, etc [estimated] - disk_moment_of_inertia(mass: 1 * units.kg, radius: 1.0 * units.cm) - ) - - crankshaft c0( - throw: stroke / 2, - flywheel_mass: flywheel_mass, - mass: crank_mass, - friction_torque: 50.0 * units.lb_ft, - moment_of_inertia: - crank_moment + flywheel_moment + other_moment, - position_x: 0.0, - position_y: 0.0, - tdc: (90 + 30) * units.deg - ) - - rod_journal rj0(angle: 0 * units.deg) - rod_journal rj1(angle: 240 * units.deg) - rod_journal rj2(angle: 120 * units.deg) - rod_journal rj3(angle: 120 * units.deg) - rod_journal rj4(angle: 240 * units.deg) - rod_journal rj5(angle: 0 * units.deg) - c0 - .add_rod_journal(rj0) - .add_rod_journal(rj1) - .add_rod_journal(rj2) - .add_rod_journal(rj3) - .add_rod_journal(rj4) - .add_rod_journal(rj5) - - piston_parameters piston_params( - mass: (1000) * units.g, - compression_height: compression_height, - wrist_pin_position: 0.0, - displacement: 0.0 - ) - - connecting_rod_parameters cr_params( - mass: rod_mass, - moment_of_inertia: rod_moment_of_inertia( - mass: rod_mass, - length: rod_length - ), - center_of_mass: 0.0, - length: rod_length - ) - - intake intake( - plenum_volume: 1.325 * units.L, - plenum_cross_section_area: 20.0 * units.cm2, - intake_flow_rate: k_carb(1400.0), - runner_flow_rate: k_carb(200.0), - runner_length: 16.0 * units.inch, - idle_flow_rate: k_carb(0.0), - idle_throttle_plate_position: 0.99, - velocity_decay: 0.5 - ) - - exhaust_system_parameters es_params( - outlet_flow_rate: k_carb(2000.0), - primary_tube_length: 50.0 * units.inch, - primary_flow_rate: k_carb(400.0), - velocity_decay: 1.0 - ) - - exhaust_system exhaust0( - es_params, - length: 30 * units.inch, - audio_volume: 1.0 * 0.5, - impulse_response: ir_lib.minimal_muffling_01 - ) - exhaust_system exhaust1( - es_params, - length: 70 * units.inch, - audio_volume: 1.0 * 0.5, - impulse_response: ir_lib.minimal_muffling_01 - ) - - cylinder_bank_parameters bank_params( - bore: bore, - deck_height: stroke / 2 + rod_length + compression_height - ) - - label spacing(6 * units.inch) - - cylinder_bank b0(bank_params, angle: (60 / 2.0) * units.deg) - cylinder_bank b1(bank_params, angle: -(60 / 2.0) * units.deg) - b0 - .add_cylinder( - piston: piston(piston_params, blowby: k_28inH2O(0.7)), - connecting_rod: connecting_rod(cr_params), - rod_journal: rj0, - intake: intake, - exhaust_system: exhaust1, - ignition_wire: wires.wire1a, - sound_attenuation: 0.9, - primary_length: spacing * 6 - ) - .add_cylinder( - piston: piston(piston_params, blowby: k_28inH2O(0.1)), - connecting_rod: connecting_rod(cr_params), - rod_journal: rj1, - intake: intake, - exhaust_system: exhaust1, - ignition_wire: wires.wire2a, - sound_attenuation: 1.0, - primary_length: spacing * 5 - ) - .add_cylinder( - piston: piston(piston_params, blowby: k_28inH2O(0.4)), - connecting_rod: connecting_rod(cr_params), - rod_journal: rj2, - intake: intake, - exhaust_system: exhaust1, - ignition_wire: wires.wire3a, - sound_attenuation: 1.5, - primary_length: spacing * 4 - ) - .add_cylinder( - piston: piston(piston_params, blowby: k_28inH2O(0.3)), - connecting_rod: connecting_rod(cr_params), - rod_journal: rj3, - intake: intake, - exhaust_system: exhaust1, - ignition_wire: wires.wire4a, - sound_attenuation: 0.9, - primary_length: spacing * 3 - ) - .add_cylinder( - piston: piston(piston_params, blowby: k_28inH2O(0.2)), - connecting_rod: connecting_rod(cr_params), - rod_journal: rj4, - intake: intake, - exhaust_system: exhaust1, - ignition_wire: wires.wire5a, - sound_attenuation: 0.8, - primary_length: spacing * 2 - ) - .add_cylinder( - piston: piston(piston_params, blowby: k_28inH2O(0.1)), - connecting_rod: connecting_rod(cr_params), - rod_journal: rj5, - intake: intake, - exhaust_system: exhaust1, - ignition_wire: wires.wire6a, - sound_attenuation: 1.0, - primary_length: spacing * 1 - ) - .set_cylinder_head( - v12_60_head( - intake_camshaft: camshaft.intake_cam_0, - exhaust_camshaft: camshaft.exhaust_cam_0, - flip_display: true, - flow_attenuation: 1.0) - ) - b1 - .add_cylinder( - piston: piston(piston_params, blowby: k_28inH2O(0.5)), - connecting_rod: connecting_rod(cr_params), - rod_journal: rj0, - intake: intake, - exhaust_system: exhaust0, - ignition_wire: wires.wire1b, - sound_attenuation: 0.9, - primary_length: spacing * 6 - ) - .add_cylinder( - piston: piston(piston_params, blowby: k_28inH2O(0.2)), - connecting_rod: connecting_rod(cr_params), - rod_journal: rj1, - intake: intake, - exhaust_system: exhaust0, - ignition_wire: wires.wire2b, - sound_attenuation: 1.1, - primary_length: spacing * 5 - ) - .add_cylinder( - piston: piston(piston_params, blowby: k_28inH2O(0.1)), - connecting_rod: connecting_rod(cr_params), - rod_journal: rj2, - intake: intake, - exhaust_system: exhaust0, - ignition_wire: wires.wire3b, - primary_length: spacing * 4 - ) - .add_cylinder( - piston: piston(piston_params, blowby: k_28inH2O(0.3)), - connecting_rod: connecting_rod(cr_params), - rod_journal: rj3, - intake: intake, - exhaust_system: exhaust0, - ignition_wire: wires.wire4b, - sound_attenuation: 1.1, - primary_length: spacing * 3 - ) - .add_cylinder( - piston: piston(piston_params, blowby: k_28inH2O(0.2)), - connecting_rod: connecting_rod(cr_params), - rod_journal: rj4, - intake: intake, - exhaust_system: exhaust0, - ignition_wire: wires.wire5b, - sound_attenuation: 0.7, - primary_length: spacing * 2 - ) - .add_cylinder( - piston: piston(piston_params, blowby: k_28inH2O(0.1)), - connecting_rod: connecting_rod(cr_params), - rod_journal: rj5, - intake: intake, - exhaust_system: exhaust0, - ignition_wire: wires.wire6b, - primary_length: spacing * 1 - ) - .set_cylinder_head( - v12_60_head( - intake_camshaft: camshaft.intake_cam_1, - exhaust_camshaft: camshaft.exhaust_cam_1, - flow_attenuation: 1.0) - ) - - engine - .add_cylinder_bank(b0) - .add_cylinder_bank(b1) - - engine.add_crankshaft(c0) - - harmonic_cam_lobe intake_lobe( - duration_at_50_thou: 242 * units.deg, - gamma: 0.8, - lift: 15.95 * units.mm, - steps: 100 - ) - - harmonic_cam_lobe exhaust_lobe( - duration_at_50_thou: 246 * units.deg, - gamma: 0.8, - lift: 590 * units.thou, - steps: 100 - ) - - v12_60_camshaft camshaft( - lobe_profile: "N/A", - - intake_lobe_profile: intake_lobe, - exhaust_lobe_profile: exhaust_lobe, - intake_lobe_center: 100.5 * units.deg, - exhaust_lobe_center: 120 * units.deg, - base_radius: 1.0 * units.inch - ) - - function timing_curve(4000 * units.rpm) - timing_curve - .add_sample(0000 * units.rpm, 12 * units.deg) - .add_sample(4000 * units.rpm, 50 * units.deg) - - ignition_module ignition_module( - timing_curve: timing_curve, - rev_limit: 3500 * units.rpm, - limiter_duration: 0.05) - ignition_module - .connect_wire(wires.wire1a, (0) * units.deg) - .connect_wire(wires.wire6b, (0 + 60) * units.deg) - .connect_wire(wires.wire4a, (120) * units.deg) - .connect_wire(wires.wire3b, (120 + 60) * units.deg) - .connect_wire(wires.wire2a, (240) * units.deg) - .connect_wire(wires.wire5b, (240 + 60) * units.deg) - .connect_wire(wires.wire6a, (360) * units.deg) - .connect_wire(wires.wire1b, (360 + 60) * units.deg) - .connect_wire(wires.wire3a, (480) * units.deg) - .connect_wire(wires.wire4b, (480 + 60) * units.deg) - .connect_wire(wires.wire5a, (600) * units.deg) - .connect_wire(wires.wire2b, (600 + 60) * units.deg) - - engine.add_ignition_module(ignition_module) -} - -label car_mass(2700 * units.lb) -private node random_car { - alias output __out: - vehicle( - mass: car_mass, - drag_coefficient: 0.3, - cross_sectional_area: (72 * units.inch) * (56 * units.inch), - diff_ratio: 3.9, - tire_radius: 10 * units.inch, - rolling_resistance: 10000 - ); -} - -private node random_transmission { - alias output __out: - transmission( - max_clutch_torque: 2000 * units.lb_ft - ) - .add_gear(0.01); -} - -public node main { - set_engine(merlin_v12()) - set_vehicle(random_car()) - set_transmission(random_transmission()) -} diff --git a/es/engines/atg-video-2/12_ferrari_412_t2.mr b/es/engines/atg-video-2/12_ferrari_412_t2.mr deleted file mode 100644 index 2af6ebf..0000000 --- a/es/engines/atg-video-2/12_ferrari_412_t2.mr +++ /dev/null @@ -1,507 +0,0 @@ -import "engine_sim.mr" - -units units() -constants constants() -impulse_response_library ir_lib() -label cycle(2 * 360 * units.deg) - -private node wires { - output wire1: ignition_wire(); - output wire2: ignition_wire(); - output wire3: ignition_wire(); - output wire4: ignition_wire(); - output wire5: ignition_wire(); - output wire6: ignition_wire(); - output wire7: ignition_wire(); - output wire8: ignition_wire(); - output wire9: ignition_wire(); - output wire10: ignition_wire(); - output wire11: ignition_wire(); - output wire12: ignition_wire(); -} - -private node v12_75_head { - input intake_camshaft; - input exhaust_camshaft; - input chamber_volume: 1.5 * 25 * units.cc; - input intake_runner_volume: 149.6 * units.cc; - input intake_runner_cross_section_area: 1.75 * units.inch * 1.75 * units.inch; - input exhaust_runner_volume: 50.0 * units.cc; - input exhaust_runner_cross_section_area: 1.75 * units.inch * 1.75 * units.inch; - - input flow_attenuation: 1.0; - input lift_scale: 1.0; - input flip_display: false; - alias output __out: head; - - function intake_flow(50 * units.thou) - intake_flow - .add_flow_sample(0 * lift_scale, 0 * flow_attenuation) - .add_flow_sample(50 * lift_scale, 58 * flow_attenuation) - .add_flow_sample(100 * lift_scale, 103 * flow_attenuation) - .add_flow_sample(150 * lift_scale, 156 * flow_attenuation) - .add_flow_sample(200 * lift_scale, 214 * flow_attenuation) - .add_flow_sample(250 * lift_scale, 249 * flow_attenuation) - .add_flow_sample(300 * lift_scale, 268 * flow_attenuation) - .add_flow_sample(350 * lift_scale, 280 * flow_attenuation) - .add_flow_sample(400 * lift_scale, 280 * flow_attenuation) - .add_flow_sample(450 * lift_scale, 281 * flow_attenuation) - - function exhaust_flow(50 * units.thou) - exhaust_flow - .add_flow_sample(0 * lift_scale, 0 * flow_attenuation) - .add_flow_sample(50 * lift_scale, 37 * flow_attenuation) - .add_flow_sample(100 * lift_scale, 72 * flow_attenuation) - .add_flow_sample(150 * lift_scale, 113 * flow_attenuation) - .add_flow_sample(200 * lift_scale, 160 * flow_attenuation) - .add_flow_sample(250 * lift_scale, 196 * flow_attenuation) - .add_flow_sample(300 * lift_scale, 222 * flow_attenuation) - .add_flow_sample(350 * lift_scale, 235 * flow_attenuation) - .add_flow_sample(400 * lift_scale, 245 * flow_attenuation) - .add_flow_sample(450 * lift_scale, 246 * flow_attenuation) - - generic_cylinder_head head( - chamber_volume: chamber_volume, - intake_runner_volume: intake_runner_volume, - intake_runner_cross_section_area: intake_runner_cross_section_area, - exhaust_runner_volume: exhaust_runner_volume, - exhaust_runner_cross_section_area: exhaust_runner_cross_section_area, - - intake_port_flow: intake_flow, - exhaust_port_flow: exhaust_flow, - valvetrain: standard_valvetrain( - intake_camshaft: intake_camshaft, - exhaust_camshaft: exhaust_camshaft - ), - flip_display: flip_display - ) -} - -private node v12_75_camshaft { - input lobe_profile; - input intake_lobe_profile: lobe_profile; - input exhaust_lobe_profile: lobe_profile; - input lobe_separation: 114 * units.deg; - input intake_lobe_center: lobe_separation; - input exhaust_lobe_center: lobe_separation; - input advance: 0 * units.deg; - input base_radius: 0.5 * units.inch; - - output intake_cam_0: _intake_cam_0; - output exhaust_cam_0: _exhaust_cam_0; - - output intake_cam_1: _intake_cam_1; - output exhaust_cam_1: _exhaust_cam_1; - - camshaft_parameters params ( - advance: advance, - base_radius: base_radius - ) - - camshaft _intake_cam_0(params, lobe_profile: intake_lobe_profile) - camshaft _exhaust_cam_0(params, lobe_profile: exhaust_lobe_profile) - camshaft _intake_cam_1(params, lobe_profile: intake_lobe_profile) - camshaft _exhaust_cam_1(params, lobe_profile: exhaust_lobe_profile) - - label rot180(180 * units.deg) - label rot360(360 * units.deg) - - // 1 12 5 8 3 10 6 7 2 11 4 9 - _exhaust_cam_0 - .add_lobe(rot360 - exhaust_lobe_center + 0 * units.deg) - .add_lobe(rot360 - exhaust_lobe_center + 480 * units.deg) - .add_lobe(rot360 - exhaust_lobe_center + 240 * units.deg) - .add_lobe(rot360 - exhaust_lobe_center + 600 * units.deg) - .add_lobe(rot360 - exhaust_lobe_center + 120 * units.deg) - .add_lobe(rot360 - exhaust_lobe_center + 360 * units.deg) - _intake_cam_0 - .add_lobe(rot360 + intake_lobe_center + 0 * units.deg) - .add_lobe(rot360 + intake_lobe_center + 480 * units.deg) - .add_lobe(rot360 + intake_lobe_center + 240 * units.deg) - .add_lobe(rot360 + intake_lobe_center + 600 * units.deg) - .add_lobe(rot360 + intake_lobe_center + 120 * units.deg) - .add_lobe(rot360 + intake_lobe_center + 360 * units.deg) - - _exhaust_cam_1 - .add_lobe(rot360 - exhaust_lobe_center + (0 + 75) * units.deg) - .add_lobe(rot360 - exhaust_lobe_center + (480 + 75) * units.deg) - .add_lobe(rot360 - exhaust_lobe_center + (240 + 75) * units.deg) - .add_lobe(rot360 - exhaust_lobe_center + (600 + 75) * units.deg) - .add_lobe(rot360 - exhaust_lobe_center + (120 + 75) * units.deg) - .add_lobe(rot360 - exhaust_lobe_center + (360 + 75) * units.deg) - _intake_cam_1 - .add_lobe(rot360 + intake_lobe_center + (0 + 75) * units.deg) - .add_lobe(rot360 + intake_lobe_center + (480 + 75) * units.deg) - .add_lobe(rot360 + intake_lobe_center + (240 + 75) * units.deg) - .add_lobe(rot360 + intake_lobe_center + (600 + 75) * units.deg) - .add_lobe(rot360 + intake_lobe_center + (120 + 75) * units.deg) - .add_lobe(rot360 + intake_lobe_center + (360 + 75) * units.deg) -} - -private node turbulence_to_flame_speed_ratio { - alias output __out: - function(5.0) - .add_sample(0.0, 2.0 * 3.0) - .add_sample(5.0, 2.0 * 1.5 * 5.0) - .add_sample(10.0, 2.5 * 1.5 * 10.0) - .add_sample(15.0, 3.0 * 1.5 * 15.0) - .add_sample(20.0, 3.0 * 1.5 * 20.0) - .add_sample(25.0, 3.0 * 1.5 * 25.0) - .add_sample(30.0, 3.0 * 1.5 * 30.0) - .add_sample(35.0, 3.0 * 1.5 * 35.0) - .add_sample(40.0, 3.0 * 1.5 * 40.0) - .add_sample(45.0, 3.0 * 1.5 * 45.0); -} - -public node ferrari_412_t2_v12 { - alias output __out: engine; - - engine engine( - name: "Ferrari 412 T2 [V12]", - starter_torque: 70 * units.lb_ft, - starter_speed: 500 * units.rpm, - redline: 18000 * units.rpm, - throttle_gamma: 2.0, - fuel: fuel( - max_turbulence_effect: 10.0, - max_dilution_effect: 5.0, - burning_efficiency_randomness: 1.0, - max_burning_efficiency: 1.0, - turbulence_to_flame_speed_ratio: turbulence_to_flame_speed_ratio() - ), - hf_gain: 0.01, - noise: 1.0, - jitter: 0.1, - simulation_frequency: 5000 - ) - - wires wires() - - label stroke(43 * units.mm) - label bore(86 * units.mm) - label rod_length(120 * units.mm) - label rod_mass(50 * units.g) - label compression_height(1.0 * units.inch) - label crank_mass(20 * units.lb) - label flywheel_mass(10 * units.lb) - label flywheel_radius(5 * units.inch) - - label crank_moment( - disk_moment_of_inertia(mass: crank_mass, radius: stroke) - ) - label flywheel_moment( - disk_moment_of_inertia(mass: flywheel_mass, radius: flywheel_radius) - ) - label other_moment( // Moment from cams, pulleys, etc [estimated] - disk_moment_of_inertia(mass: 1 * units.kg, radius: 1.0 * units.cm) - ) - - crankshaft c0( - throw: stroke / 2, - flywheel_mass: flywheel_mass, - mass: crank_mass, - friction_torque: 1.0 * units.lb_ft, - moment_of_inertia: - crank_moment + flywheel_moment + other_moment, - position_x: 0.0, - position_y: 0.0, - tdc: (90 + (75 / 2.0)) * units.deg - ) - - // 1 12 5 8 3 10 6 7 2 11 4 9 - rod_journal rj0(angle: 0 * units.deg) - rod_journal rj1(angle: 120 * units.deg) - rod_journal rj2(angle: 240 * units.deg) - rod_journal rj3(angle: 240 * units.deg) - rod_journal rj4(angle: 120 * units.deg) - rod_journal rj5(angle: 0 * units.deg) - c0 - .add_rod_journal(rj0) - .add_rod_journal(rj1) - .add_rod_journal(rj2) - .add_rod_journal(rj3) - .add_rod_journal(rj4) - .add_rod_journal(rj5) - - piston_parameters piston_params( - mass: (50) * units.g, // 414 - piston mass, 152 - pin weight - compression_height: compression_height, - wrist_pin_position: 0.0, - displacement: 0.0 - ) - - connecting_rod_parameters cr_params( - mass: rod_mass, - moment_of_inertia: rod_moment_of_inertia( - mass: rod_mass, - length: rod_length - ), - center_of_mass: 0.0, - length: rod_length - ) - - intake intake( - plenum_volume: 1.325 * units.L, - plenum_cross_section_area: 20.0 * units.cm2, - intake_flow_rate: k_carb(1400.0), - runner_flow_rate: k_carb(200.0), - runner_length: 4.0 * units.inch, - idle_flow_rate: k_carb(0.0), - idle_throttle_plate_position: 0.992, - velocity_decay: 0.5 - ) - - exhaust_system_parameters es_params( - outlet_flow_rate: k_carb(2000.0), - primary_tube_length: 20.0 * units.inch, - primary_flow_rate: k_carb(200.0), - velocity_decay: 0.5 - ) - - exhaust_system exhaust0( - es_params, - audio_volume: 1.0 * 0.004, - length: 20 * units.inch, - impulse_response: ir_lib.minimal_muffling_01 - ) - exhaust_system exhaust1( - es_params, - audio_volume: 1.0 * 0.004, - length: 56 * units.inch, - impulse_response: ir_lib.minimal_muffling_01 - ) - - cylinder_bank_parameters bank_params( - bore: bore, - deck_height: stroke / 2 + rod_length + compression_height - ) - - label spacing(0.1) - - cylinder_bank b0(bank_params, angle: (75 / 2.0) * units.deg) - cylinder_bank b1(bank_params, angle: -(75 / 2.0) * units.deg) - b0 - .add_cylinder( - piston: piston(piston_params, blowby: k_28inH2O(0.0)), - connecting_rod: connecting_rod(cr_params), - rod_journal: rj0, - intake: intake, - exhaust_system: exhaust1, - ignition_wire: wires.wire1, - sound_attenuation: 0.5, - primary_length: spacing * 0.5 * units.cm - ) - .add_cylinder( - piston: piston(piston_params, blowby: k_28inH2O(0.0)), - connecting_rod: connecting_rod(cr_params), - rod_journal: rj1, - intake: intake, - exhaust_system: exhaust1, - ignition_wire: wires.wire2, - sound_attenuation: 1.0, - primary_length: spacing * 0.0 * units.cm - ) - .add_cylinder( - piston: piston(piston_params, blowby: k_28inH2O(0.0)), - connecting_rod: connecting_rod(cr_params), - rod_journal: rj2, - intake: intake, - exhaust_system: exhaust1, - ignition_wire: wires.wire3, - sound_attenuation: 0.75, - primary_length: spacing * 0.2 * units.cm - ) - .add_cylinder( - piston: piston(piston_params, blowby: k_28inH2O(0.0)), - connecting_rod: connecting_rod(cr_params), - rod_journal: rj3, - intake: intake, - exhaust_system: exhaust1, - ignition_wire: wires.wire4, - sound_attenuation: 0.9, - primary_length: spacing * 1.5 * units.cm - ) - .add_cylinder( - piston: piston(piston_params, blowby: k_28inH2O(0.0)), - connecting_rod: connecting_rod(cr_params), - rod_journal: rj4, - intake: intake, - exhaust_system: exhaust1, - ignition_wire: wires.wire5, - sound_attenuation: 0.7, - primary_length: spacing * 2.5 * units.cm - ) - .add_cylinder( - piston: piston(piston_params, blowby: k_28inH2O(0.0)), - connecting_rod: connecting_rod(cr_params), - rod_journal: rj5, - intake: intake, - exhaust_system: exhaust1, - ignition_wire: wires.wire6, - sound_attenuation: 1.0, - primary_length: spacing * 0.5 * units.cm - ) - .set_cylinder_head( - v12_75_head( - intake_camshaft: camshaft.intake_cam_0, - exhaust_camshaft: camshaft.exhaust_cam_0, - flip_display: true, - flow_attenuation: 1.0) - ) - b1 - .add_cylinder( - piston: piston(piston_params, blowby: k_28inH2O(0.0)), - connecting_rod: connecting_rod(cr_params), - rod_journal: rj0, - intake: intake, - exhaust_system: exhaust0, - ignition_wire: wires.wire12, - sound_attenuation: 0.5, - primary_length: spacing * 0.5 * units.cm - ) - .add_cylinder( - piston: piston(piston_params, blowby: k_28inH2O(0.0)), - connecting_rod: connecting_rod(cr_params), - rod_journal: rj1, - intake: intake, - exhaust_system: exhaust0, - ignition_wire: wires.wire11, - sound_attenuation: 0.3, - primary_length: spacing * 0.25 * units.cm - ) - .add_cylinder( - piston: piston(piston_params, blowby: k_28inH2O(0.0)), - connecting_rod: connecting_rod(cr_params), - rod_journal: rj2, - intake: intake, - exhaust_system: exhaust0, - ignition_wire: wires.wire10, - primary_length: spacing * 3.5 * units.cm - ) - .add_cylinder( - piston: piston(piston_params, blowby: k_28inH2O(0.0)), - connecting_rod: connecting_rod(cr_params), - rod_journal: rj3, - intake: intake, - exhaust_system: exhaust0, - ignition_wire: wires.wire9, - sound_attenuation: 1.2, - primary_length: spacing * 1.5 * units.cm - ) - .add_cylinder( - piston: piston(piston_params, blowby: k_28inH2O(0.0)), - connecting_rod: connecting_rod(cr_params), - rod_journal: rj4, - intake: intake, - exhaust_system: exhaust0, - ignition_wire: wires.wire8, - sound_attenuation: 0.7, - primary_length: spacing * 0.5 * units.cm - ) - .add_cylinder( - piston: piston(piston_params, blowby: k_28inH2O(0.0)), - connecting_rod: connecting_rod(cr_params), - rod_journal: rj5, - intake: intake, - exhaust_system: exhaust0, - ignition_wire: wires.wire7, - sound_attenuation: 1.2, - primary_length: spacing * 1.5 * units.cm - ) - .set_cylinder_head( - v12_75_head( - intake_camshaft: camshaft.intake_cam_1, - exhaust_camshaft: camshaft.exhaust_cam_1, - flow_attenuation: 1.0) - ) - - engine - .add_cylinder_bank(b0) - .add_cylinder_bank(b1) - - engine.add_crankshaft(c0) - - harmonic_cam_lobe intake_lobe( - duration_at_50_thou: 242 * units.deg, - gamma: 0.8, - lift: 15.95 * units.mm, - steps: 512 - ) - - harmonic_cam_lobe exhaust_lobe( - duration_at_50_thou: 246 * units.deg, - gamma: 0.8, - lift: 15.95 * units.mm, - steps: 512 - ) - - v12_75_camshaft camshaft( - lobe_profile: "N/A", - - intake_lobe_profile: intake_lobe, - exhaust_lobe_profile: exhaust_lobe, - intake_lobe_center: 90 * units.deg, - exhaust_lobe_center: 112 * units.deg, - base_radius: 1.0 * units.inch - ) - - function timing_curve(4000 * units.rpm) - timing_curve - .add_sample(0000 * units.rpm, 12 * units.deg) - .add_sample(4000 * units.rpm, 40 * units.deg) - .add_sample(8000 * units.rpm, 40 * units.deg) - .add_sample(12000 * units.rpm, 40 * units.deg) - .add_sample(14000 * units.rpm, 40 * units.deg) - .add_sample(18000 * units.rpm, 40 * units.deg) - - ignition_module ignition_module( - timing_curve: timing_curve, - rev_limit: 18500 * units.rpm, - limiter_duration: 0.1) - ignition_module - .connect_wire(wires.wire1, (0) * units.deg) - .connect_wire(wires.wire12, (0 + 75) * units.deg) - .connect_wire(wires.wire5, (120) * units.deg) - .connect_wire(wires.wire8, (120 + 75) * units.deg) - .connect_wire(wires.wire3, (240) * units.deg) - .connect_wire(wires.wire10, (240 + 75) * units.deg) - .connect_wire(wires.wire6, (360) * units.deg) - .connect_wire(wires.wire7, (360 + 75) * units.deg) - .connect_wire(wires.wire2, (480) * units.deg) - .connect_wire(wires.wire11, (480 + 75) * units.deg) - .connect_wire(wires.wire4, (600) * units.deg) - .connect_wire(wires.wire9, (600 + 75) * units.deg) - - engine.add_ignition_module(ignition_module) -} - -private node f1_vehicle { - alias output __out: - vehicle( - mass: 798 * units.kg, - drag_coefficient: 0.9, - cross_sectional_area: (72 * units.inch) * (36 * units.inch), - diff_ratio: 4.10, - tire_radius: 9 * units.inch, - rolling_resistance: 200 * units.N - ); -} - -private node f1_transmission { - alias output __out: - transmission( - max_clutch_torque: 1000 * units.lb_ft - ) - .add_gear(2.8) - .add_gear(2.29) - .add_gear(1.93) - .add_gear(1.583) - .add_gear(1.375) - .add_gear(1.19); -} - -public node main { - set_engine(ferrari_412_t2_v12()) - set_vehicle(f1_vehicle()) - set_transmission(f1_transmission()) -} diff --git a/es/engines/atg-video-2/radial.mr b/es/engines/atg-video-2/radial.mr deleted file mode 100644 index dd3e2bb..0000000 --- a/es/engines/atg-video-2/radial.mr +++ /dev/null @@ -1,56 +0,0 @@ -import "engine_sim.mr" - -units units() -constants constants() -label cycle(2 * 360 * units.deg) - -public node radial_head { - input offset; - input lobe_profile; - input chamber_volume: 290 * units.cc; - alias output __head: - generic_small_engine_head( - chamber_volume: chamber_volume, - intake_camshaft: camshaft.intake_cam, - exhaust_camshaft: camshaft.exhaust_cam, - flow_attenuation: 2.0, - intake_runner_cross_section_area: 20.0 * units.cm2, - exhaust_runner_cross_section_area: 20.0 * units.cm2 - ); - - radial_camshaft camshaft( - lobe_profile: lobe_profile, - offset: offset - ) -} - -public node radial_camshaft { - input lobe_profile; - input offset; - input intake_lobe_profile: lobe_profile; - input exhaust_lobe_profile: lobe_profile; - input lobe_separation: 114 * units.deg; - input intake_lobe_center: lobe_separation; - input exhaust_lobe_center: lobe_separation; - input advance: 0 * units.deg; - input base_radius: 1.0 * units.inch; - - output intake_cam: _intake_cam; - output exhaust_cam: _exhaust_cam; - - camshaft_parameters params ( - advance: advance, - base_radius: base_radius - ) - - camshaft _intake_cam(params, lobe_profile: intake_lobe_profile) - camshaft _exhaust_cam(params, lobe_profile: exhaust_lobe_profile) - - label rot180(180 * units.deg) - label rot360(360 * units.deg) - - _exhaust_cam - .add_lobe(rot360 - exhaust_lobe_center + offset * cycle) - _intake_cam - .add_lobe(rot360 + intake_lobe_center + offset * cycle) -} diff --git a/es/engines/dacxl/M156.mr b/es/engines/dacxl/M156.mr deleted file mode 100644 index 7476c8a..0000000 --- a/es/engines/dacxl/M156.mr +++ /dev/null @@ -1,456 +0,0 @@ -import "engine_sim.mr" - -units units() -constants constants() -impulse_response_library ir_lib() - -label cycle(2 * 360 * units.deg) -label cylcycle(720/8.0*units.deg) -label cycle90(90 * units.deg) - - -private node amg_distributor { - input wires; - input timing_curve; - input rev_limit: 7250 * units.rpm; - input limiter_duration: 0.05; - alias output __out: - ignition_module(timing_curve: timing_curve, rev_limit: rev_limit, limiter_duration: limiter_duration) - .connect_wire(wires.wire1, 0) - .connect_wire(wires.wire5, 1 * cycle90) - .connect_wire(wires.wire4, 2 * cycle90) - .connect_wire(wires.wire8, 3 * cycle90) - .connect_wire(wires.wire6, 4 * cycle90) - .connect_wire(wires.wire3, 5 * cycle90) - .connect_wire(wires.wire7, 6 * cycle90) - .connect_wire(wires.wire2, 7 * cycle90) - ; -} - -//1 - 5 - 4 - 8 - 6 - 3 - 7 - 2 M156 - -private node wires { - output wire1: ignition_wire(); - output wire2: ignition_wire(); - output wire3: ignition_wire(); - output wire4: ignition_wire(); - output wire5: ignition_wire(); - output wire6: ignition_wire(); - output wire7: ignition_wire(); - output wire8: ignition_wire(); -} - -private node add_sym_sample { - input angle; - input lift; - input this; - alias output __out: this; - - this.add_sample(angle * units.deg, lift * units.thou) - this.add_sample(-angle * units.deg, lift * units.thou) -} - -private node amg_lobe_profile_int { - alias output __out: - harmonic_cam_lobe( - duration_at_50_thou: 264 * units.deg, //288 - gamma: 3, - lift: 11 * units.mm, //14.5 - steps: 100 - ); -} - -private node amg_lobe_profile_exh { - alias output __out: - harmonic_cam_lobe( - duration_at_50_thou: 264 * units.deg, //280 - gamma: 3, - lift: 9.8 * units.mm, //14.5 - steps: 100 - ); -} - -private node camshaft_builder { - input lobe_profile: amg_lobe_profile_int(); - input ex_lobe_profile: amg_lobe_profile_exh(); - input intake_lobe_profile: lobe_profile; - input exhaust_lobe_profile: ex_lobe_profile; - input lobe_separation: 112.0 * units.deg; - input intake_lobe_center: lobe_separation; - input exhaust_lobe_center: 112.0 * units.deg; - input advance: 0.0 * units.deg; - input base_radius: 0.6 * units.inch; - - output intake_cam_0: _intake_cam_0; - output intake_cam_1: _intake_cam_1; - output exhaust_cam_0: _exhaust_cam_0; - output exhaust_cam_1: _exhaust_cam_1; - - camshaft_parameters params( - advance: advance, - base_radius: base_radius - ) - - camshaft _intake_cam_0(params, lobe_profile: intake_lobe_profile) - camshaft _intake_cam_1(params, lobe_profile: intake_lobe_profile) - camshaft _exhaust_cam_0(params, lobe_profile: exhaust_lobe_profile) - camshaft _exhaust_cam_1(params, lobe_profile: exhaust_lobe_profile) - - - label rot60(60 * units.deg) - label rot90(90 * units.deg) - label rot120(120 * units.deg) - label rot135(135 * units.deg) - label rot180(180 * units.deg) - label rot360(360 * units.deg) - label rot(90 * units.deg) - - // 1-5-3-7-4-8-2-6 - // 4 8 - // 3 7 - // 2 6 - // 1 5 - // 1 - 5 - 4 - 8 - 6 - 3 - 7 - 2 M156 - - _intake_cam_0 - .add_lobe(rot360 + intake_lobe_center + 0 * rot) // 1 - .add_lobe(rot360 + intake_lobe_center + 6 * rot) // 2 - .add_lobe(rot360 + intake_lobe_center + 5 * rot) // 3 - .add_lobe(rot360 + intake_lobe_center + 2 * rot) // 4 - - _intake_cam_1 - .add_lobe(rot360 + intake_lobe_center + 1 * rot) // 5 - .add_lobe(rot360 + intake_lobe_center + 4 * rot) // 6 - .add_lobe(rot360 + intake_lobe_center + 6 * rot) // 7 - .add_lobe(rot360 + intake_lobe_center + 3 * rot) // 8 - - _exhaust_cam_0 - .add_lobe(rot360 - exhaust_lobe_center + 0 * rot) // 1 - .add_lobe(rot360 - exhaust_lobe_center + 6 * rot) // 2 - .add_lobe(rot360 - exhaust_lobe_center + 5 * rot) // 3 - .add_lobe(rot360 - exhaust_lobe_center + 2 * rot) // 4 - - _exhaust_cam_1 - .add_lobe(rot360 - exhaust_lobe_center + 1 * rot) // 5 - .add_lobe(rot360 - exhaust_lobe_center + 4 * rot) // 6 - .add_lobe(rot360 - exhaust_lobe_center + 6 * rot) // 7 - .add_lobe(rot360 - exhaust_lobe_center + 3 * rot) // 8 -} - -private node add_flow_sample { - input lift; - input flow; - input this; - alias output __out: this; - - this.add_sample(lift * units.mm, k_28inH2O(flow)) -} - -private node amg_head { - input intake_camshaft; - input exhaust_camshaft; - input chamber_volume: 28.23 * units.cc; - input intake_runner_volume: 600.0 * units.cc; - input intake_runner_cross_section_area: 100.0 * units.cm2; - input exhaust_runner_volume: 600.0 * units.cc; - input exhaust_runner_cross_section_area: 100.0 * units.cm2; - input flip_display: false; - - input flow_attenuation: 1.0; - input lift_scale: 1.0; - alias output __out: head; - - function intake_flow(1 * units.mm) - intake_flow - .add_flow_sample(0 * lift_scale, 0 * flow_attenuation) - .add_flow_sample(1 * lift_scale, 40 * flow_attenuation) - .add_flow_sample(2 * lift_scale, 100 * flow_attenuation) - .add_flow_sample(3 * lift_scale, 168 * flow_attenuation) - .add_flow_sample(4 * lift_scale, 196 * flow_attenuation) - .add_flow_sample(5 * lift_scale, 228 * flow_attenuation) - .add_flow_sample(6 * lift_scale, 254 * flow_attenuation) - .add_flow_sample(7 * lift_scale, 274 * flow_attenuation) - .add_flow_sample(8 * lift_scale, 285 * flow_attenuation) - .add_flow_sample(9 * lift_scale, 314 * flow_attenuation) - .add_flow_sample(10 * lift_scale, 330 * flow_attenuation) - .add_flow_sample(11 * lift_scale, 343 * flow_attenuation) - .add_flow_sample(12 * lift_scale, 355 * flow_attenuation) - .add_flow_sample(13 * lift_scale, 359 * flow_attenuation) - .add_flow_sample(14 * lift_scale, 360 * flow_attenuation) - - function exhaust_flow(1 * units.mm) - exhaust_flow - .add_flow_sample(0 * lift_scale, 0 * flow_attenuation) - .add_flow_sample(1 * lift_scale, 42 * flow_attenuation) - .add_flow_sample(2 * lift_scale, 110 * flow_attenuation) - .add_flow_sample(3 * lift_scale, 140 * flow_attenuation) - .add_flow_sample(4 * lift_scale, 170 * flow_attenuation) - .add_flow_sample(5 * lift_scale, 194 * flow_attenuation) - .add_flow_sample(6 * lift_scale, 228 * flow_attenuation) - .add_flow_sample(7 * lift_scale, 237 * flow_attenuation) - .add_flow_sample(8 * lift_scale, 253 * flow_attenuation) - .add_flow_sample(9 * lift_scale, 288 * flow_attenuation) - .add_flow_sample(10 * lift_scale, 292 * flow_attenuation) - .add_flow_sample(11 * lift_scale, 317 * flow_attenuation) - .add_flow_sample(12 * lift_scale, 323 * flow_attenuation) - .add_flow_sample(13 * lift_scale, 331 * flow_attenuation) - .add_flow_sample(14 * lift_scale, 342 * flow_attenuation) - - - cylinder_head head( - chamber_volume: chamber_volume, - intake_runner_volume: intake_runner_volume, - intake_runner_cross_section_area: intake_runner_cross_section_area, - exhaust_runner_volume: exhaust_runner_volume, - exhaust_runner_cross_section_area: exhaust_runner_cross_section_area, - - intake_port_flow: intake_flow, - exhaust_port_flow: exhaust_flow, - intake_camshaft: intake_camshaft, - exhaust_camshaft: exhaust_camshaft, - flip_display: flip_display - ) -} - -public node amg_vehicle { - input mass: (1730 + 80) * units.kg; - input diff_ratio: 2.82; - input tire_radius: 12.7 * units.inch; - - alias output __out: vehicle; - - vehicle vehicle( - mass: mass, - diff_ratio: diff_ratio, - tire_radius: tire_radius - ) -} - -public node amg_transmission { - input max_clutch_torque: 680 * units.lb_ft; - alias output __out: - transmission(max_clutch_torque) - .add_gear(4.38) - .add_gear(2.86) - .add_gear(1.92) - .add_gear(1.37) - .add_gear(1.0) - .add_gear(0.82) - .add_gear(0.73); -} - - -public node M156 { - alias output __out: engine; - - engine engine( - name: "Mercedes-AMG M156 (C 63 W204)", - starter_torque: 200 * units.lb_ft, - starter_speed: 1400 * units.rpm, - redline: 7250 * units.rpm, - fuel: fuel( - max_turbulence_effect: 8.0, - burning_efficiency_randomness: 0.1, - max_burning_efficiency: 1.25 - ) - ) - - wires wires() - - crankshaft c0( - throw: 94.6 * units.mm / 2, - flywheel_mass: 11.7934 * units.kg, - mass: 23.2 * units.kg, - friction_torque: 10.0 * units.lb_ft, - moment_of_inertia: 0.22986844776863666 * 0.9, - position_x: 0.0, - position_y: 0.0, - tdc: 45.0 * units.deg - ) - - rod_journal rj0(angle: 90.0*units.deg) - rod_journal rj1(angle: 0.0*units.deg) - rod_journal rj2(angle: 180.0*units.deg) - rod_journal rj3(angle: 270.0*units.deg) - -// 4 8 -// 3 7 -// 2 6 -// 1 5 -//1 - 5 - 4 - 8 - 6 - 3 - 7 - 2 M156 - - - c0 - .add_rod_journal(rj0) - .add_rod_journal(rj1) - .add_rod_journal(rj2) - .add_rod_journal(rj3) - - piston_parameters piston_params( - mass: 420 * units.g, - //blowby: k_28inH2O(0.1), - compression_height: 24.0 * units.mm, - wrist_pin_position: 0.0, - displacement: 0.0 - ) - - connecting_rod_parameters cr_params( - mass: 408.0 * units.g, - moment_of_inertia: 0.0015884918028487504, - center_of_mass: 0.0, - length: 144.0 * units.mm - ) - - cylinder_bank_parameters bank_params( - bore: 102.2 * units.mm, - deck_height: 225.0 * units.mm //225 - ) - - intake intake( - plenum_volume: 80.0 * units.L, - plenum_cross_section_area: 120.0 * units.cm2, - intake_flow_rate: k_carb(5000.0), - idle_flow_rate: k_carb(0.002), - idle_throttle_plate_position: 0.99878, - throttle_gamma: 1.0 - ) - - exhaust_system_parameters es_params( - outlet_flow_rate: k_carb(8000.0), - primary_tube_length: 18.0 * units.inch, - primary_flow_rate: k_carb(1800.0), - velocity_decay: 0.6, //0.5 - volume: 600.0 * units.L - ) - - exhaust_system_parameters es_params2( - outlet_flow_rate: k_carb(8000.0), - primary_tube_length: 18.0 * units.inch, - primary_flow_rate: k_carb(1800.0), - velocity_decay: 0.6, //0.5 - volume: 600.0 * units.L - ) - - - exhaust_system exhaust0(es_params, audio_volume: 0.5, impulse_response: ir_lib.default_0) - exhaust_system exhaust1(es_params, audio_volume: 1.0, impulse_response: ir_lib.default_0) - - cylinder_bank b0(bank_params, angle: 45 * units.deg) - b0 - .add_cylinder( - piston: piston(piston_params, blowby: k_28inH2O(0.1)), - connecting_rod: connecting_rod(cr_params), - rod_journal: rj0, - intake: intake, - exhaust_system: exhaust0, - ignition_wire: wires.wire1 - ) - .add_cylinder( - piston: piston(piston_params, blowby: k_28inH2O(0.1)), - connecting_rod: connecting_rod(cr_params), - rod_journal: rj1, - intake: intake, - exhaust_system: exhaust0, - ignition_wire: wires.wire2 - ) - .add_cylinder( - piston: piston(piston_params, blowby: k_28inH2O(0.1)), - connecting_rod: connecting_rod(cr_params), - rod_journal: rj2, - intake: intake, - exhaust_system: exhaust0, - ignition_wire: wires.wire3 - ) - .add_cylinder( - piston: piston(piston_params, blowby: k_28inH2O(0.1)), - connecting_rod: connecting_rod(cr_params), - rod_journal: rj3, - intake: intake, - exhaust_system: exhaust0, - ignition_wire: wires.wire4 - ) - - cylinder_bank b1(bank_params, angle: -45 * units.deg) - b1 - .add_cylinder( - piston: piston(piston_params, blowby: k_28inH2O(0.1)), - connecting_rod: connecting_rod(cr_params), - rod_journal: rj0, - intake: intake, - exhaust_system: exhaust1, - ignition_wire: wires.wire5 - ) - .add_cylinder( - piston: piston(piston_params, blowby: k_28inH2O(0.1)), - connecting_rod: connecting_rod(cr_params), - rod_journal: rj1, - intake: intake, - exhaust_system: exhaust1, - ignition_wire: wires.wire6 - ) - .add_cylinder( - piston: piston(piston_params, blowby: k_28inH2O(0.1)), - connecting_rod: connecting_rod(cr_params), - rod_journal: rj2, - intake: intake, - exhaust_system: exhaust1, - ignition_wire: wires.wire7 - ) - .add_cylinder( - piston: piston(piston_params, blowby: k_28inH2O(0.1)), - connecting_rod: connecting_rod(cr_params), - rod_journal: rj3, - intake: intake, - exhaust_system: exhaust1, - ignition_wire: wires.wire8 - ) - - - engine - .add_cylinder_bank(b0) - .add_cylinder_bank(b1) - - engine.add_crankshaft(c0) - - - camshaft_builder camshaft( - lobe_profile: amg_lobe_profile_int(), - ex_lobe_profile: amg_lobe_profile_exh() - ) - - b0.set_cylinder_head ( - amg_head( - intake_camshaft: camshaft.intake_cam_0, - exhaust_camshaft: camshaft.exhaust_cam_0 - ) - ) - - b1.set_cylinder_head ( - amg_head( - intake_camshaft: camshaft.intake_cam_1, - exhaust_camshaft: camshaft.exhaust_cam_1, - flip_display:true - ) - ) - - function timing_curve(1000 * units.rpm) - timing_curve - .add_sample(0000 * units.rpm, 15 * units.deg) - .add_sample(1000 * units.rpm, 28 * units.deg) - .add_sample(2000 * units.rpm, 35 * units.deg) - .add_sample(3000 * units.rpm, 35 * units.deg) - .add_sample(4000 * units.rpm, 40 * units.deg) - .add_sample(5000 * units.rpm, 40 * units.deg) - .add_sample(6000 * units.rpm, 40 * units.deg) - .add_sample(7000 * units.rpm, 40 * units.deg) - .add_sample(8000 * units.rpm, 40 * units.deg) - .add_sample(9000 * units.rpm, 40 * units.deg) - - engine.add_ignition_module( - amg_distributor( - wires: wires, - timing_curve: timing_curve, - rev_limit: 7250 * units.rpm, - limiter_duration: 0.05 - )) -} diff --git a/es/ferrari_412_t2.mr b/es/ferrari_412_t2.mr deleted file mode 100644 index 174f8de..0000000 --- a/es/ferrari_412_t2.mr +++ /dev/null @@ -1,6 +0,0 @@ -import "engine_sim.mr" -import "themes/default.mr" -import "engines/atg-video-2/12_ferrari_412_t2.mr" - -use_default_theme() -main() diff --git a/es/ferrari_f136.mr b/es/ferrari_f136.mr deleted file mode 100644 index b410509..0000000 --- a/es/ferrari_f136.mr +++ /dev/null @@ -1,6 +0,0 @@ -import "engine_sim.mr" -import "themes/default.mr" -import "engines/atg-video-2/08_ferrari_f136_v8.mr" - -use_default_theme() -main() diff --git a/es/ferrari_v8.mr b/es/ferrari_v8.mr deleted file mode 100644 index 781b70a..0000000 --- a/es/ferrari_v8.mr +++ /dev/null @@ -1,451 +0,0 @@ -import "engine_sim.mr" - -units units() -constants constants() -impulse_response_library ir_lib() -label cycle(2 * 360 * units.deg) - -private node wires { - output wire1: ignition_wire(); - output wire2: ignition_wire(); - output wire3: ignition_wire(); - output wire4: ignition_wire(); - output wire5: ignition_wire(); - output wire6: ignition_wire(); - output wire7: ignition_wire(); - output wire8: ignition_wire(); -} - -private node f136_head { - input intake_camshaft; - input exhaust_camshaft; - input chamber_volume: 90 * units.cc; - input intake_runner_volume: 149.6 * units.cc; - input intake_runner_cross_section_area: 2.2 * units.inch * 2.2 * units.inch; - input exhaust_runner_volume: 50.0 * units.cc; - input exhaust_runner_cross_section_area: 1.75 * units.inch * 1.75 * units.inch; - - input flow_attenuation: 1.0; - input lift_scale: 1.0; - input flip_display: false; - alias output __out: head; - - function intake_flow(50 * units.thou) - intake_flow - .add_flow_sample(0 * lift_scale, 0 * flow_attenuation) - .add_flow_sample(50 * lift_scale, 58 * flow_attenuation) - .add_flow_sample(100 * lift_scale, 103 * flow_attenuation) - .add_flow_sample(150 * lift_scale, 156 * flow_attenuation) - .add_flow_sample(200 * lift_scale, 214 * flow_attenuation) - .add_flow_sample(250 * lift_scale, 249 * flow_attenuation) - .add_flow_sample(300 * lift_scale, 268 * flow_attenuation) - .add_flow_sample(350 * lift_scale, 280 * flow_attenuation) - .add_flow_sample(400 * lift_scale, 280 * flow_attenuation) - .add_flow_sample(450 * lift_scale, 281 * flow_attenuation) - - function exhaust_flow(50 * units.thou) - exhaust_flow - .add_flow_sample(0 * lift_scale, 0 * flow_attenuation) - .add_flow_sample(50 * lift_scale, 37 * flow_attenuation) - .add_flow_sample(100 * lift_scale, 72 * flow_attenuation) - .add_flow_sample(150 * lift_scale, 113 * flow_attenuation) - .add_flow_sample(200 * lift_scale, 160 * flow_attenuation) - .add_flow_sample(250 * lift_scale, 196 * flow_attenuation) - .add_flow_sample(300 * lift_scale, 222 * flow_attenuation) - .add_flow_sample(350 * lift_scale, 235 * flow_attenuation) - .add_flow_sample(400 * lift_scale, 245 * flow_attenuation) - .add_flow_sample(450 * lift_scale, 246 * flow_attenuation) - - generic_cylinder_head head( - chamber_volume: chamber_volume, - intake_runner_volume: intake_runner_volume, - intake_runner_cross_section_area: intake_runner_cross_section_area, - exhaust_runner_volume: exhaust_runner_volume, - exhaust_runner_cross_section_area: exhaust_runner_cross_section_area, - - intake_port_flow: intake_flow, - exhaust_port_flow: exhaust_flow, - valvetrain: standard_valvetrain( - intake_camshaft: intake_camshaft, - exhaust_camshaft: exhaust_camshaft - ), - flip_display: flip_display - ) -} - -private node f136_camshaft { - input lobe_profile; - input intake_lobe_profile: lobe_profile; - input exhaust_lobe_profile: lobe_profile; - input lobe_separation: 114 * units.deg; - input intake_lobe_center: lobe_separation; - input exhaust_lobe_center: lobe_separation; - input advance: 0 * units.deg; - input base_radius: 0.5 * units.inch; - - output intake_cam_0: _intake_cam_0; - output exhaust_cam_0: _exhaust_cam_0; - - output intake_cam_1: _intake_cam_1; - output exhaust_cam_1: _exhaust_cam_1; - - camshaft_parameters params ( - advance: advance, - base_radius: base_radius - ) - - camshaft _intake_cam_0(params, lobe_profile: intake_lobe_profile) - camshaft _exhaust_cam_0(params, lobe_profile: exhaust_lobe_profile) - camshaft _intake_cam_1(params, lobe_profile: intake_lobe_profile) - camshaft _exhaust_cam_1(params, lobe_profile: exhaust_lobe_profile) - - label rot(90 * units.deg) - label rot360(360 * units.deg) - - // 1 5 3 7 4 8 2 6 - _exhaust_cam_0 - .add_lobe(rot360 - exhaust_lobe_center + 0 * rot) // 1 - .add_lobe(rot360 - exhaust_lobe_center + 6 * rot) // 2 - .add_lobe(rot360 - exhaust_lobe_center + 2 * rot) // 3 - .add_lobe(rot360 - exhaust_lobe_center + 4 * rot) // 4 - _intake_cam_0 - .add_lobe(rot360 + intake_lobe_center + 0 * rot) // 1 - .add_lobe(rot360 + intake_lobe_center + 6 * rot) // 2 - .add_lobe(rot360 + intake_lobe_center + 2 * rot) // 3 - .add_lobe(rot360 + intake_lobe_center + 4 * rot) // 4 - - _exhaust_cam_1 - .add_lobe(rot360 - exhaust_lobe_center + 1 * rot) // 5 - .add_lobe(rot360 - exhaust_lobe_center + 7 * rot) // 6 - .add_lobe(rot360 - exhaust_lobe_center + 3 * rot) // 7 - .add_lobe(rot360 - exhaust_lobe_center + 5 * rot) // 8 - _intake_cam_1 - .add_lobe(rot360 + intake_lobe_center + 1 * rot) // 5 - .add_lobe(rot360 + intake_lobe_center + 7 * rot) // 6 - .add_lobe(rot360 + intake_lobe_center + 3 * rot) // 7 - .add_lobe(rot360 + intake_lobe_center + 5 * rot) // 8 -} - -private node turbulence_to_flame_speed_ratio { - alias output __out: - function(5.0) - .add_sample(0.0, 3.0) - .add_sample(5.0, 1.5 * 5.0) - .add_sample(10.0, 1.75 * 10.0) - .add_sample(15.0, 2.0 * 15.0) - .add_sample(20.0, 2.0 * 20.0) - .add_sample(25.0, 2.0 * 25.0) - .add_sample(30.0, 2.0 * 30.0) - .add_sample(35.0, 2.0 * 35.0) - .add_sample(40.0, 2.0 * 40.0) - .add_sample(45.0, 2.0 * 45.0); -} - -public node f136_v8 { - alias output __out: engine; - - engine engine( - name: "Ferrari F136", - starter_torque: 200 * units.lb_ft, - starter_speed: 200 * units.rpm, - redline: 9000 * units.rpm, - throttle_gamma: 2.0, - fuel: fuel( - max_burning_efficiency: 1.0, - turbulence_to_flame_speed_ratio: turbulence_to_flame_speed_ratio() - ), - hf_gain: 0.01, - noise: 1.0, - jitter: 0.15, - simulation_frequency: 10000 - ) - - wires wires() - - label stroke(81 * units.mm) - label bore(94 * units.mm) - label rod_length(160 * units.mm) - label rod_mass(50 * units.g) - label compression_height(1.0 * units.inch) - label crank_mass(60 * units.lb) - label flywheel_mass(30 * units.lb) - label flywheel_radius(8 * units.inch) - - label crank_moment( - 1.5 * disk_moment_of_inertia(mass: crank_mass, radius: stroke) - ) - label flywheel_moment( - disk_moment_of_inertia(mass: flywheel_mass, radius: flywheel_radius) - ) - label other_moment( // Moment from cams, pulleys, etc [estimated] - disk_moment_of_inertia(mass: 1 * units.kg, radius: 1.0 * units.cm) - ) - - label v_angle(90 * units.deg) - crankshaft c0( - throw: stroke / 2, - flywheel_mass: flywheel_mass, - mass: crank_mass, - friction_torque: 20.0 * units.lb_ft, - moment_of_inertia: - crank_moment + flywheel_moment + other_moment, - position_x: 0.0, - position_y: 0.0, - tdc: 90 * units.deg + (v_angle / 2.0) - ) - - // 1 5 3 7 4 8 2 6 - rod_journal rj0(angle: 0 * units.deg) - rod_journal rj1(angle: 180 * units.deg) - rod_journal rj2(angle: 180 * units.deg) - rod_journal rj3(angle: 0 * units.deg) - c0 - .add_rod_journal(rj0) - .add_rod_journal(rj1) - .add_rod_journal(rj2) - .add_rod_journal(rj3) - - piston_parameters piston_params( - // 414 - piston mass, 152 - pin weight - mass: (100) * units.g, - compression_height: compression_height, - wrist_pin_position: 0.0, - displacement: 0.0 - ) - - connecting_rod_parameters cr_params( - mass: rod_mass, - moment_of_inertia: rod_moment_of_inertia( - mass: rod_mass, - length: rod_length - ), - center_of_mass: 0.0, - length: rod_length - ) - - intake intake( - plenum_volume: 1.325 * units.L, - plenum_cross_section_area: 20.0 * units.cm2, - intake_flow_rate: k_carb(700.0), - runner_flow_rate: k_carb(100.0), - runner_length: 12.0 * units.inch, - idle_flow_rate: k_carb(0.0), - idle_throttle_plate_position: 0.995, - velocity_decay: 0.5 - ) - - exhaust_system_parameters es_params( - outlet_flow_rate: k_carb(1000.0), - primary_tube_length: 29.0 * units.inch, - primary_flow_rate: k_carb(600.0), - velocity_decay: 0.5 - ) - - exhaust_system exhaust0( - es_params, - audio_volume: 2.0 * 0.1, - length: 100 * units.inch, - impulse_response: ir_lib.mild_exhaust_0_reverb - - ) - exhaust_system exhaust1( - es_params, - audio_volume: 2.0 * 0.09, - length: 100 * units.inch, - impulse_response: ir_lib.mild_exhaust_0_reverb - ) - - cylinder_bank_parameters bank_params( - bore: bore, - deck_height: stroke / 2 + rod_length + compression_height - ) - - label spacing(5 * units.inch) - - cylinder_bank b0(bank_params, angle: v_angle / 2.0) - cylinder_bank b1(bank_params, angle: -v_angle / 2.0) - b0 - .add_cylinder( - piston: piston(piston_params, blowby: k_28inH2O(0.0)), - connecting_rod: connecting_rod(cr_params), - rod_journal: rj0, - intake: intake, - exhaust_system: exhaust0, - ignition_wire: wires.wire1, - sound_attenuation: 0.9, - primary_length: 2 * units.cm - ) - .add_cylinder( - piston: piston(piston_params, blowby: k_28inH2O(0.0)), - connecting_rod: connecting_rod(cr_params), - rod_journal: rj1, - intake: intake, - exhaust_system: exhaust0, - ignition_wire: wires.wire2, - sound_attenuation: 0.8, - primary_length: 1 * units.cm - ) - .add_cylinder( - piston: piston(piston_params, blowby: k_28inH2O(0.0)), - connecting_rod: connecting_rod(cr_params), - rod_journal: rj2, - intake: intake, - exhaust_system: exhaust0, - ignition_wire: wires.wire3, - sound_attenuation: 1.1, - primary_length: 3 * units.cm - ) - .add_cylinder( - piston: piston(piston_params, blowby: k_28inH2O(0.0)), - connecting_rod: connecting_rod(cr_params), - rod_journal: rj3, - intake: intake, - exhaust_system: exhaust0, - ignition_wire: wires.wire4, - sound_attenuation: 1.0, - primary_length: 5 * units.cm - ) - .set_cylinder_head( - f136_head( - intake_camshaft: camshaft.intake_cam_0, - exhaust_camshaft: camshaft.exhaust_cam_0, - flip_display: true, - flow_attenuation: 1.0) - ) - b1 - .add_cylinder( - piston: piston(piston_params, blowby: k_28inH2O(0.0)), - connecting_rod: connecting_rod(cr_params), - rod_journal: rj0, - intake: intake, - exhaust_system: exhaust1, - ignition_wire: wires.wire5, - sound_attenuation: 1.0, - primary_length: 1 * units.cm - ) - .add_cylinder( - piston: piston(piston_params, blowby: k_28inH2O(0.0)), - connecting_rod: connecting_rod(cr_params), - rod_journal: rj1, - intake: intake, - exhaust_system: exhaust1, - ignition_wire: wires.wire6, - sound_attenuation: 0.8, - primary_length: 5 * units.cm - ) - .add_cylinder( - piston: piston(piston_params, blowby: k_28inH2O(0.0)), - connecting_rod: connecting_rod(cr_params), - rod_journal: rj2, - intake: intake, - exhaust_system: exhaust1, - ignition_wire: wires.wire7, - sound_attenuation: 0.9, - primary_length: 7 * units.cm - ) - .add_cylinder( - piston: piston(piston_params, blowby: k_28inH2O(0.0)), - connecting_rod: connecting_rod(cr_params), - rod_journal: rj3, - intake: intake, - exhaust_system: exhaust1, - ignition_wire: wires.wire8, - sound_attenuation: 0.7, - primary_length: 0 * units.cm - ) - .set_cylinder_head( - f136_head( - intake_camshaft: camshaft.intake_cam_1, - exhaust_camshaft: camshaft.exhaust_cam_1, - flow_attenuation: 1.0) - ) - - engine - .add_cylinder_bank(b0) - .add_cylinder_bank(b1) - - engine.add_crankshaft(c0) - - harmonic_cam_lobe intake_lobe( - duration_at_50_thou: 230 * units.deg, - gamma: 0.9, - lift: 551 * units.thou, - steps: 256 - ) - - harmonic_cam_lobe exhaust_lobe( - duration_at_50_thou: 230 * units.deg, - gamma: 0.9, - lift: 551 * units.thou, - steps: 256 - ) - - f136_camshaft camshaft( - lobe_profile: "N/A", - - intake_lobe_profile: intake_lobe, - exhaust_lobe_profile: exhaust_lobe, - intake_lobe_center: 116 * units.deg, - exhaust_lobe_center: 116 * units.deg, - base_radius: 1.0 * units.inch - ) - - function timing_curve(1000 * units.rpm) - timing_curve - .add_sample(0000 * units.rpm, 12 * units.deg) - .add_sample(1000 * units.rpm, 12 * units.deg) - .add_sample(2000 * units.rpm, 20 * units.deg) - .add_sample(3000 * units.rpm, 30 * units.deg) - .add_sample(4000 * units.rpm, 40 * units.deg) - .add_sample(5000 * units.rpm, 40 * units.deg) - .add_sample(6000 * units.rpm, 40 * units.deg) - .add_sample(7000 * units.rpm, 40 * units.deg) - .add_sample(8000 * units.rpm, 40 * units.deg) - - ignition_module ignition_module( - timing_curve: timing_curve, - rev_limit: 9300 * units.rpm, - limiter_duration: 0.1) - ignition_module - .connect_wire(wires.wire1, 0 * 90 * units.deg) - .connect_wire(wires.wire5, 1 * 90 * units.deg) - .connect_wire(wires.wire3, 2 * 90 * units.deg) - .connect_wire(wires.wire7, 3 * 90 * units.deg) - .connect_wire(wires.wire4, 4 * 90 * units.deg) - .connect_wire(wires.wire8, 5 * 90 * units.deg) - .connect_wire(wires.wire2, 6 * 90 * units.deg) - .connect_wire(wires.wire6, 7 * 90 * units.deg) - - engine.add_ignition_module(ignition_module) -} - -private node mustang_vehicle { - alias output __out: - vehicle( - mass: 1614 * units.kg, - drag_coefficient: 0.3, - cross_sectional_area: (72 * units.inch) * (50 * units.inch), - diff_ratio: 3.42, - tire_radius: 10 * units.inch, - rolling_resistance: 200 * units.N - ); -} - -private node mustang_transmission { - alias output __out: - transmission( - max_clutch_torque: 500 * units.lb_ft - ) - .add_gear(3.23) - .add_gear(2.19) - .add_gear(1.61) - .add_gear(1.23) - .add_gear(0.97) - .add_gear(0.8); -} - -public node main { - set_engine(f136_v8()) - set_vehicle(mustang_vehicle()) - set_transmission(mustang_transmission()) -} diff --git a/es/heads.mr b/es/heads.mr deleted file mode 100644 index 85b9a00..0000000 --- a/es/heads.mr +++ /dev/null @@ -1,187 +0,0 @@ -private import "engine_sim.mr" - -units units() - -public node add_flow_sample { - input lift; - input flow; - input this; - alias output __out: this; - - this.add_sample(lift * units.thou, k_28inH2O(flow)) -} - -public node chevy_bbc_peanut_port_head { - input intake_camshaft; - input exhaust_camshaft; - input flip_display: false; - alias output __out: head; - - function intake_flow(50 * units.thou) - intake_flow - .add_flow_sample(0, 0) - .add_flow_sample(50, 25) - .add_flow_sample(100, 75) - .add_flow_sample(150, 100) - .add_flow_sample(200, 130) - .add_flow_sample(250, 180) - .add_flow_sample(300, 190) - .add_flow_sample(350, 220) - .add_flow_sample(400, 240) - .add_flow_sample(450, 250) - .add_flow_sample(500, 260) - .add_flow_sample(550, 260) - .add_flow_sample(600, 260) - .add_flow_sample(650, 255) - .add_flow_sample(700, 250) - - function exhaust_flow(50 * units.thou) - exhaust_flow - .add_flow_sample(0, 0) - .add_flow_sample(50, 25) - .add_flow_sample(100, 50) - .add_flow_sample(150, 75) - .add_flow_sample(200, 100) - .add_flow_sample(250, 125) - .add_flow_sample(300, 160) - .add_flow_sample(350, 175) - .add_flow_sample(400, 180) - .add_flow_sample(450, 190) - .add_flow_sample(500, 200) - .add_flow_sample(550, 205) - .add_flow_sample(600, 210) - .add_flow_sample(650, 210) - .add_flow_sample(700, 210) - - cylinder_head head( - chamber_volume: 118.0 * units.cc, - intake_runner_volume: 189.0 * units.cc, - intake_runner_cross_section_area: 37.8 * units.cm2, - - intake_port_flow: intake_flow, - exhaust_port_flow: exhaust_flow, - intake_camshaft: intake_camshaft, - exhaust_camshaft: exhaust_camshaft, - flip_display: flip_display - ) -} - -public node edelbrock_6055_rectangle_port { - input intake_camshaft; - input exhaust_camshaft; - input flip_display: false; - alias output __out: head; - - function intake_flow(50 * units.thou) - intake_flow - .add_flow_sample(0, 0) - .add_flow_sample(50, 25) - .add_flow_sample(100, 76) - .add_flow_sample(150, 100) - .add_flow_sample(200, 146) - .add_flow_sample(250, 175) - .add_flow_sample(300, 212) - .add_flow_sample(350, 230) - .add_flow_sample(400, 255) - .add_flow_sample(450, 275) - .add_flow_sample(500, 294) - .add_flow_sample(550, 300) - .add_flow_sample(600, 314) - .add_flow_sample(650, 314) - .add_flow_sample(700, 314) - - function exhaust_flow(50 * units.thou) - exhaust_flow - .add_flow_sample(0, 0) - .add_flow_sample(50, 25) - .add_flow_sample(100, 70) - .add_flow_sample(150, 100) - .add_flow_sample(200, 132) - .add_flow_sample(250, 140) - .add_flow_sample(300, 156) - .add_flow_sample(350, 170) - .add_flow_sample(400, 181) - .add_flow_sample(450, 191) - .add_flow_sample(500, 207) - .add_flow_sample(550, 214) - .add_flow_sample(600, 228) - .add_flow_sample(650, 228) - .add_flow_sample(700, 228) - - cylinder_head head( - chamber_volume: 118.0 * units.cc, - intake_runner_volume: 315.0 * units.cc, - intake_runner_cross_section_area: 78.75 * units.cm2, - - intake_port_flow: intake_flow, - exhaust_port_flow: exhaust_flow, - intake_camshaft: intake_camshaft, - exhaust_camshaft: exhaust_camshaft, - flip_display: flip_display - ) -} - -public node generic_small_engine_head { - input intake_camshaft; - input exhaust_camshaft; - input chamber_volume: 100.0 * units.cc; - input intake_runner_volume: 100.0 * units.cc; - input intake_runner_cross_section_area: 30.0 * units.cm2; - input exhaust_runner_volume: 100.0 * units.cc; - input exhaust_runner_cross_section_area: 30.0 * units.cm2; - - input flow_attenuation: 1.0; - input lift_scale: 1.0; - input flip_display: false; - alias output __out: head; - - function intake_flow(50 * units.thou) - intake_flow - .add_flow_sample(0 * lift_scale, 0 * flow_attenuation) - .add_flow_sample(50 * lift_scale, 25 * flow_attenuation) - .add_flow_sample(100 * lift_scale, 75 * flow_attenuation) - .add_flow_sample(150 * lift_scale, 100 * flow_attenuation) - .add_flow_sample(200 * lift_scale, 130 * flow_attenuation) - .add_flow_sample(250 * lift_scale, 180 * flow_attenuation) - .add_flow_sample(300 * lift_scale, 190 * flow_attenuation) - .add_flow_sample(350 * lift_scale, 220 * flow_attenuation) - .add_flow_sample(400 * lift_scale, 240 * flow_attenuation) - .add_flow_sample(450 * lift_scale, 250 * flow_attenuation) - .add_flow_sample(500 * lift_scale, 260 * flow_attenuation) - .add_flow_sample(550 * lift_scale, 260 * flow_attenuation) - .add_flow_sample(600 * lift_scale, 260 * flow_attenuation) - .add_flow_sample(650 * lift_scale, 255 * flow_attenuation) - .add_flow_sample(700 * lift_scale, 250 * flow_attenuation) - - function exhaust_flow(50 * units.thou) - exhaust_flow - .add_flow_sample(0 * lift_scale, 0 * flow_attenuation) - .add_flow_sample(50 * lift_scale, 25 * flow_attenuation) - .add_flow_sample(100 * lift_scale, 50 * flow_attenuation) - .add_flow_sample(150 * lift_scale, 75 * flow_attenuation) - .add_flow_sample(200 * lift_scale, 100 * flow_attenuation) - .add_flow_sample(250 * lift_scale, 125 * flow_attenuation) - .add_flow_sample(300 * lift_scale, 160 * flow_attenuation) - .add_flow_sample(350 * lift_scale, 175 * flow_attenuation) - .add_flow_sample(400 * lift_scale, 180 * flow_attenuation) - .add_flow_sample(450 * lift_scale, 190 * flow_attenuation) - .add_flow_sample(500 * lift_scale, 200 * flow_attenuation) - .add_flow_sample(550 * lift_scale, 205 * flow_attenuation) - .add_flow_sample(600 * lift_scale, 210 * flow_attenuation) - .add_flow_sample(650 * lift_scale, 210 * flow_attenuation) - .add_flow_sample(700 * lift_scale, 210 * flow_attenuation) - - cylinder_head head( - chamber_volume: chamber_volume, - intake_runner_volume: intake_runner_volume, - intake_runner_cross_section_area: intake_runner_cross_section_area, - exhaust_runner_volume: exhaust_runner_volume, - exhaust_runner_cross_section_area: exhaust_runner_cross_section_area, - - intake_port_flow: intake_flow, - exhaust_port_flow: exhaust_flow, - intake_camshaft: intake_camshaft, - exhaust_camshaft: exhaust_camshaft, - flip_display: flip_display - ) -} diff --git a/es/ignition_modules.mr b/es/ignition_modules.mr deleted file mode 100644 index a75144f..0000000 --- a/es/ignition_modules.mr +++ /dev/null @@ -1,50 +0,0 @@ -private import "engine_sim.mr" - -units units() -label cycle(2 * 360 * units.deg) - -public node chevy_bbc_distributor { - input wires; - input timing_curve; - input rev_limit: 5500 * units.rpm; - alias output __out: - ignition_module(timing_curve: timing_curve, rev_limit: rev_limit) - .connect_wire(wires.wire1, (0.0 / 8.0) * cycle) - .connect_wire(wires.wire8, (1.0 / 8.0) * cycle) - .connect_wire(wires.wire4, (2.0 / 8.0) * cycle) - .connect_wire(wires.wire3, (3.0 / 8.0) * cycle) - .connect_wire(wires.wire6, (4.0 / 8.0) * cycle) - .connect_wire(wires.wire5, (5.0 / 8.0) * cycle) - .connect_wire(wires.wire7, (6.0 / 8.0) * cycle) - .connect_wire(wires.wire2, (7.0 / 8.0) * cycle); -} - -public node chevy_sbc_distributor { - input wires; - input timing_curve; - input rev_limit: 5500 * units.rpm; - alias output __out: chevy_bbc_distributor( - wires: wires, - timing_curve: timing_curve, - rev_limit: rev_limit - ); -} - -public node vtwin90_distributor { - input wires; - input timing_curve; - input rev_limit: 5500 * units.rpm; - alias output __out: - ignition_module(timing_curve: timing_curve, rev_limit: rev_limit) - .connect_wire(wires.wire1, (0.0 / 8.0) * cycle) - .connect_wire(wires.wire2, (3.0 / 8.0) * cycle); -} - -public node single_cylinder_distributor { - input wires; - input timing_curve; - input rev_limit: 5500 * units.rpm; - alias output __out: - ignition_module(timing_curve: timing_curve, rev_limit: rev_limit) - .connect_wire(wires.wire1, (0.0 / 8.0) * cycle); -} diff --git a/es/impulse_responses.mr b/es/impulse_responses.mr deleted file mode 100644 index 5fca714..0000000 --- a/es/impulse_responses.mr +++ /dev/null @@ -1,26 +0,0 @@ -private import "engine_sim.mr" - -public node impulse_response_library { - output default_0: impulse_response(filename: "smooth/smooth_39.wav", volume: 0.001); - - output real_engine_0: - impulse_response(filename: "archive/test_engine_14_eq_adjusted_16.wav", volume: 0.001); - output real_engine_1: - impulse_response(filename: "archive/test_engine_15_eq_adjusted_16.wav", volume: 0.001); - output real_engine_2: - impulse_response(filename: "archive/test_engine_16_eq_adjusted_16.wav", volume: 0.001); - - output sharp_0: - impulse_response(filename: "sharp/sharp_01.wav", volume: 0.001); - - output mild_exhaust_0: - impulse_response(filename: "new/mild_exhaust.wav", volume: 0.01); - output mild_exhaust_0_reverb: - impulse_response(filename: "new/mild_exhaust_reverb.wav", volume: 0.01); - output minimal_muffling_01: - impulse_response(filename: "new/minimal_muffling_01.wav", volume: 0.01); - output minimal_muffling_02: - impulse_response(filename: "new/minimal_muffling_02.wav", volume: 0.01); - output minimal_muffling_03: - impulse_response(filename: "new/minimal_muffling_03.wav", volume: 0.01); -} diff --git a/es/infrastructure.mr b/es/infrastructure.mr deleted file mode 100644 index ac6390f..0000000 --- a/es/infrastructure.mr +++ /dev/null @@ -1,10 +0,0 @@ -module { - @name: "Infrastructure" - @author: "ATG (Ange Yaghi)" - @copyright: "Copyright 2022, Ange Yaghi" -} - -public node label { - input in; - alias output _out: in; -} diff --git a/es/infrastructure/infrastructure.mr b/es/infrastructure/infrastructure.mr deleted file mode 100644 index ac6390f..0000000 --- a/es/infrastructure/infrastructure.mr +++ /dev/null @@ -1,10 +0,0 @@ -module { - @name: "Infrastructure" - @author: "ATG (Ange Yaghi)" - @copyright: "Copyright 2022, Ange Yaghi" -} - -public node label { - input in; - alias output _out: in; -} diff --git a/es/intakes.mr b/es/intakes.mr deleted file mode 100644 index 502beae..0000000 --- a/es/intakes.mr +++ /dev/null @@ -1,45 +0,0 @@ -private import "engine_sim.mr" - -units units() - -public node chevy_bbc_stock_intake { - input carburetor_cfm: 650.0; - input idle_flow_rate_cfm: 1.0; - input idle_throttle_plate_position: 0.975; - input throttle_gamma: 2.0; - - alias output __out: intake; - - intake intake( - plenum_volume: 2.0 * units.L, - plenum_cross_section_area: 100.0 * units.cm2, - intake_flow_rate: k_carb(carburetor_cfm), - idle_flow_rate: k_carb(idle_flow_rate_cfm), - idle_throttle_plate_position: idle_throttle_plate_position, - throttle_gamma: throttle_gamma, - runner_flow_rate: k_carb(300.0), - runner_length: 6.0 * units.inch, - velocity_decay: 1.0 - ) -} - -public node performer_rpm_intake { - input carburetor_cfm: 650.0; - input idle_flow_rate_cfm: 1.0; - input idle_throttle_plate_position: 0.975; - input throttle_gamma: 2.0; - - alias output __out: intake; - - intake intake( - plenum_volume: 2.0 * units.L, - plenum_cross_section_area: 100.0 * units.cm2, - intake_flow_rate: k_carb(carburetor_cfm), - idle_flow_rate: k_carb(idle_flow_rate_cfm), - idle_throttle_plate_position: idle_throttle_plate_position, - throttle_gamma: throttle_gamma, - runner_flow_rate: k_carb(500.0), - runner_length: 6.0 * units.inch, - velocity_decay: 0.1 - ) -} diff --git a/es/lfa_v10.mr b/es/lfa_v10.mr deleted file mode 100644 index 7292b2f..0000000 --- a/es/lfa_v10.mr +++ /dev/null @@ -1,6 +0,0 @@ -import "engine_sim.mr" -import "themes/default.mr" -import "engines/atg-video-2/10_lfa_v10.mr" - -use_default_theme() -main() diff --git a/es/main.mr b/es/main.mr deleted file mode 100644 index 5f330f8..0000000 --- a/es/main.mr +++ /dev/null @@ -1,4 +0,0 @@ -import "engine_sim.mr" -import "v8_engine.mr" - -main() diff --git a/es/objects.mr b/es/objects.mr deleted file mode 100644 index 46c5211..0000000 --- a/es/objects.mr +++ /dev/null @@ -1,617 +0,0 @@ -module { - @name: "Objects" - @author: "ATG (Ange Yaghi)" - @copyright: "Copyright 2022, Ange Yaghi" -} - -private import "../types/atomic_types.mr" -private import "../types/conversions.mr" -private import "../types/operations.mr" -private import "../constants/units.mr" -private import "../actions/actions.mr" - -units units() - -// Channels -public node engine_channel => __engine_sim__engine_channel { /* void */ } -public node crankshaft_channel => __engine_sim__crankshaft_channel { /* void */ } -public node rod_journal_channel => __engine_sim__rod_journal { /* void */ } -public node connecting_rod_channel => __engine_sim__connecting_rod_channel { /* void */ } -public node piston_channel => __engine_sim__piston_channel { /* void */ } -public node cylinder_bank_channel => __engine_sim__cylinder_bank_channel { /* void */ } -public node function_channel => __engine_sim__function_channel { /* void */ } -public node cylinder_head_channel => __engine_sim__cylinder_head_channel { /* void */ } -public node camshaft_channel => __engine_sim__camshaft_channel { /* void */ } -public node intake_channel => __engine_sim__intake_channel { /* void */ } -public node exhaust_system_channel => __engine_sim__exhaust_system_channel { /* void */ } -public node ignition_module_channel => __engine_sim__ignition_module_channel { /* void */ } -public node ignition_wire_channel => __engine_sim__ignition_wire_channel { /* void */ } -public node fuel_channel => __engine_sim__fuel_channel { /* void */ } -public node impulse_response_channel => __engine_sim__impulse_response_channel { /* void */ } -public node valvetrain_channel => __engine_sim__valvetrain_channel { /* void */ } -public node vehicle_channel => __engine_sim__vehicle_channel { /* void */ } -public node transmission_channel => __engine_sim__transmission_channel { /* void */ } -public node throttle_channel => __engine_sim__throttle_channel { /* void */ } - -private node turbulence_to_flame_speed_ratio_default { - alias output __out: - function(5.0) - .add_sample(0.0, 3.0) - .add_sample(5.0, 1.5 * 5.0) - .add_sample(10.0, 1.5 * 10.0) - .add_sample(15.0, 1.5 * 15.0) - .add_sample(20.0, 1.5 * 20.0) - .add_sample(25.0, 1.5 * 25.0) - .add_sample(30.0, 1.5 * 30.0) - .add_sample(35.0, 1.5 * 35.0) - .add_sample(40.0, 1.5 * 40.0) - .add_sample(45.0, 1.5 * 45.0); -} - -public node fuel => __engine_sim__fuel { - input name [string]: "Gasoline [Default]"; - input molecular_mass [float]: 100 * units.g; - input energy_density [float]: 48.1 * units.kJ / units.g; - input density [float]: 0.755 * units.kg / units.L; - input molecular_afr [float]: 25 / 2.0; - input turbulence_to_flame_speed_ratio [function]: - turbulence_to_flame_speed_ratio_default(); - input max_burning_efficiency [float]: 0.8; - input burning_efficiency_randomness [float]: 0.5; - input low_efficiency_attenuation [float]: 0.6; - input max_turbulence_effect [float]: 2.0; - input max_dilution_effect [float]: 10.0; - alias output __out [fuel_channel]; -} - -// Engine -public node engine_parameters { - input name: ""; - input redline: 6000 * units.rpm; - input starter_speed: 200 * units.rpm; - input starter_torque: 200 * units.lb_ft; - input fuel: fuel(); -} - -private node _engine => __engine_sim__engine { - input name [string]; - - input redline [float]; - input starter_speed [float]; - input starter_torque [float]; - input dyno_min_speed [float]; - input dyno_max_speed [float]; - input dyno_hold_step [float]; - - input fuel [fuel]; - input throttle [throttle_channel]; - - input simulation_frequency [float]; - input hf_gain [float]; - input jitter [float]; - input noise [float]; - - alias output __out [engine_channel]; -} - -public node engine { - input params: engine_parameters(); - input name: params.name; - - input redline: params.redline; - input starter_speed: params.starter_speed; - input starter_torque: params.starter_torque; - input dyno_min_speed: 1000 * units.rpm; - input dyno_max_speed: redline; - input dyno_hold_step: 100 * units.rpm; - - input fuel: params.fuel; - input throttle_gamma: 1.0; - input throttle: - direct_throttle_linkage(gamma: throttle_gamma); - - input simulation_frequency: 10000; - input hf_gain: 0.01; - input jitter: 0.5; - input noise: 1.0; - - alias output __out [_engine]: - _engine( - name: name, - - redline: redline, - starter_speed: starter_speed, - starter_torque: starter_torque, - dyno_min_speed: dyno_min_speed, - dyno_max_speed: dyno_max_speed, - dyno_hold_step: dyno_hold_step, - - fuel: fuel, - throttle: throttle, - - simulation_frequency: simulation_frequency, - hf_gain: hf_gain, - jitter: jitter, - noise: noise - ); -} - -public node direct_throttle_linkage => __engine_sim__direct_throttle_linkage { - input gamma [float]: 1.0; - alias output __out [throttle_channel]; -} - -public node governor => __engine_sim__governor { - input min_speed [float]: 1.0; - input max_speed [float]: 1.0; - input min_v [float]: -2.0; - input max_v [float]: 2.0; - input k_s [float]: 1.0; - input k_d [float]: 300.0; - input gamma [float]: 0.1; - alias output __out [throttle_channel]; -} - -// Crankshaft -public node crankshaft_parameter_defaults { - input throw: 0.0; - input flywheel_mass: 0.0; - input mass: 0.0; - input friction_torque: 0.0; - input moment_of_inertia: 0.0; - input position_x: 0.0; - input position_y: 0.0; - input tdc: 0.0; -} - -private node _crankshaft => __engine_sim__crankshaft { - input throw [float]: 0.0; - input flywheel_mass [float]: 0.0; - input mass [float]: 0.0; - input friction_torque [float]: 0.0; - input moment_of_inertia [float]: 0.0; - input position_x [float]: 0.0; - input position_y [float]: 0.0; - input tdc [float]: 0.0; - alias output __out [crankshaft_channel]; -} - -public node crankshaft { - input params: crankshaft_parameter_defaults(); - input throw: params.throw; - input flywheel_mass: params.flywheel_mass; - input mass: params.mass; - input friction_torque: params.friction_torque; - input moment_of_inertia: params.moment_of_inertia; - input position_x: params.position_x; - input position_y: params.position_y; - input tdc: params.tdc; - alias output __out [_crankshaft]: - _crankshaft( - throw: throw, - flywheel_mass: flywheel_mass, - mass: mass, - friction_torque: friction_torque, - moment_of_inertia: moment_of_inertia, - position_x: position_x, - position_y: position_y, - tdc: tdc - ); -} - -// Rod Journal -public node rod_journal => __engine_sim__rod_journal { - input angle [float]: 0; - alias output __out [rod_journal_channel]; -} - -// Connecting Rod -private node connecting_rod_parameter_defaults { - input mass: 0.0; - input moment_of_inertia: 0.0; - input center_of_mass: 0.0; - input length: 0.0; - input slave_throw: 0.0; -} - -public node connecting_rod_parameters { - input copy: connecting_rod_parameter_defaults(); - input mass: copy.mass; - input moment_of_inertia: copy.moment_of_inertia; - input center_of_mass: copy.center_of_mass; - input length: copy.length; - input slave_throw: copy.slave_throw; -} - -private node _connecting_rod => __engine_sim__connecting_rod { - input mass [float]; - input moment_of_inertia [float]; - input center_of_mass [float]; - input length [float]; - input slave_throw [float]; - alias output __out [connecting_rod_channel]; -} - -public node connecting_rod { - input params: connecting_rod_parameters(); - alias output __out [_connecting_rod]: - _connecting_rod( - mass: params.mass, - moment_of_inertia: params.moment_of_inertia, - center_of_mass: params.center_of_mass, - length: params.length, - slave_throw: params.slave_throw - ); -} - -// Piston -public node piston_parameters { - input blowby: 0.0; - input compression_height: 0.0; - input wrist_pin_position: 0.0; - input wrist_pin_location: 0.0; - input displacement: 0.0; - input mass: 0.0; -} - -private node _piston => __engine_sim__piston { - input mass [float]: 0.0; - input blowby [float]: 0.0; - input compression_height [float]: 0.0; - input wrist_pin_position [float]: 0.0; - input displacement [float]: 0.0; - alias output __out [piston_channel]; -} - -public node piston { - input params: piston_parameters(); - input blowby: params.blowby; - alias output __out [_piston]: - _piston( - mass: params.mass, - blowby: blowby, - compression_height: params.compression_height, - wrist_pin_position: params.wrist_pin_position, - displacement: params.displacement - ); -} - -// Cylinder Bank -public node cylinder_bank_parameters { - input angle: 0.0; - input bore: 0.0; - input deck_height: 0.0; - input position_x: 0.0; - input position_y: 0.0; - input display_depth: 0.5; -} - -private node _cylinder_bank => __engine_sim__cylinder_bank { - input angle [float]: 0.0; - input bore [float]: 0.0; - input deck_height [float]: 0.0; - input position_x [float]: 0.0; - input position_y [float]: 0.0; - input display_depth [float]: 0.6; - alias output __out [cylinder_bank_channel]; -} - -public node cylinder_bank { - input parameters: cylinder_bank_parameters(); - input angle: parameters.angle; - input bore: parameters.bore; - input deck_height: parameters.deck_height; - input position_x: parameters.position_x; - input position_y: parameters.position_y; - input display_depth: parameters.display_depth; - alias output __out [_cylinder_bank]: - _cylinder_bank( - angle: angle, - bore: bore, - deck_height: deck_height, - position_x: position_x, - position_y: position_y, - display_depth: display_depth - ); -} - -// Function -public node function => __engine_sim__function { - input filter_radius [float]: 1.0; - alias output __out [function_channel]; -} - -// Cylinder -public node cylinder_friction_parameter_defaults { - output friction_k: 0.06; - output breakaway_friction: 0.0; - output breakaway_friction_velocity: 0.0; - output viscous_friction_coefficient: 0.0; -} - -public node cylinder_friction_parameters { - input copy: cylinder_friction_parameter_defaults(); - input friction_k: copy.friction_k; - input breakaway_friction: copy.breakaway_friction; - input breakaway_friction_velocity: copy.breakaway_friction_velocity; - input viscous_friction_coefficient: copy.viscous_friction_coefficient; -} - -// Valvetrain -public node standard_valvetrain => __engine_sim__standard_valvetrain { - input intake_camshaft [camshaft]; - input exhaust_camshaft [camshaft]; - alias output __out [valvetrain_channel]; -} - -public node vtec_valvetrain => __engine_sim__vtec_valvetrain { - input vtec_intake_camshaft [camshaft]; - input vtec_exhaust_camshaft [camshaft]; - input intake_camshaft [camshaft]; - input exhaust_camshaft [camshaft]; - - input min_rpm [float]: 5800 * units.rpm; - input min_speed [float]: 10 * units.mph; - input manifold_vacuum [float]: 1.0 * units.atm - 5.0 * units.inHg; - input min_throttle_position [float]: 0.3; - - alias output __out [valvetrain_channel]; -} - -// Cylinder Head -public node cylinder_head_parameters { - input intake_port_flow: function(); - input exhaust_port_flow: function(); - input chamber_volume: 118.0 * units.cc; - - input intake_runner_volume: 300.0 * units.cc; - input intake_runner_cross_section_area: circle_area(0.75 * units.inch); - - input exhaust_runner_volume: 300.0 * units.cc; - input exhaust_runner_cross_section_area: circle_area(0.85 * units.inch); - - input flip_display: false; -} - -private node _cylinder_head => __engine_sim__cylinder_head { - input intake_port_flow [function]; - input exhaust_port_flow [function]; - input valvetrain [valvetrain_channel]; - input chamber_volume [float]; - input intake_runner_volume [float]; - input intake_runner_cross_section_area [float]; - input exhaust_runner_volume [float]; - input exhaust_runner_cross_section_area [float]; - input flip_display [bool]; - alias output __out [cylinder_head_channel]; -} - -public node generic_cylinder_head { - input parameters: cylinder_head_parameters(); - input valvetrain; - - input intake_port_flow: parameters.intake_port_flow; - input exhaust_port_flow: parameters.exhaust_port_flow; - - input chamber_volume: parameters.chamber_volume; - - input intake_runner_volume: parameters.intake_runner_volume; - input intake_runner_cross_section_area: parameters.intake_runner_cross_section_area; - - input exhaust_runner_volume: parameters.exhaust_runner_volume; - input exhaust_runner_cross_section_area: parameters.exhaust_runner_cross_section_area; - - input flip_display: parameters.flip_display; - - alias output __out [_cylinder_head]: - _cylinder_head( - intake_port_flow: intake_port_flow, - exhaust_port_flow: exhaust_port_flow, - chamber_volume: chamber_volume, - intake_runner_volume: intake_runner_volume, - intake_runner_cross_section_area: intake_runner_cross_section_area, - exhaust_runner_volume: exhaust_runner_volume, - exhaust_runner_cross_section_area: exhaust_runner_cross_section_area, - flip_display: flip_display, - valvetrain: valvetrain - ); -} - -public node cylinder_head { - input parameters: cylinder_head_parameters(); - - input intake_camshaft; - input exhaust_camshaft; - - input intake_port_flow: parameters.intake_port_flow; - input exhaust_port_flow: parameters.exhaust_port_flow; - - input chamber_volume: parameters.chamber_volume; - - input intake_runner_volume: parameters.intake_runner_volume; - input intake_runner_cross_section_area: parameters.intake_runner_cross_section_area; - - input exhaust_runner_volume: parameters.exhaust_runner_volume; - input exhaust_runner_cross_section_area: parameters.exhaust_runner_cross_section_area; - - input flip_display: parameters.flip_display; - - alias output __out [_cylinder_head]: - generic_cylinder_head( - intake_port_flow: intake_port_flow, - exhaust_port_flow: exhaust_port_flow, - chamber_volume: chamber_volume, - intake_runner_volume: intake_runner_volume, - intake_runner_cross_section_area: intake_runner_cross_section_area, - exhaust_runner_volume: exhaust_runner_volume, - exhaust_runner_cross_section_area: exhaust_runner_cross_section_area, - flip_display: flip_display, - valvetrain: standard_valvetrain( - intake_camshaft: intake_camshaft, - exhaust_camshaft: exhaust_camshaft - ) - ); -} - -// Camshaft -public node camshaft_parameters { - input advance: 0.0; - input base_radius: 0.0; - input lobe_profile: function(); -} - -private node _camshaft => __engine_sim__camshaft { - input advance [float]; - input base_radius [float]; - input lobe_profile [function]; - alias output __out [camshaft_channel]; -} - -public node camshaft { - input parameters: camshaft_parameters(); - input advance: parameters.advance; - input base_radius: parameters.base_radius; - input lobe_profile: parameters.lobe_profile; - alias output __out [_camshaft]: - _camshaft( - advance: advance, - base_radius: base_radius, - lobe_profile: lobe_profile - ); -} - -// Intake -public node intake_parameters { - input plenum_volume: 2.0 * units.L; - input plenum_cross_section_area: 100.0 * units.cm2; - input intake_flow_rate: 0.0; - input idle_flow_rate: 0.0; - input molecular_afr: (25.0 / 2.0); - input idle_throttle_plate_position: 0.975; - input throttle_gamma: 2.0; - input runner_length: 4.0 * units.inch; - input runner_flow_rate: k_carb(200.0); - input velocity_decay: 0.25; -} - -private node _intake => __engine_sim__intake { - input plenum_volume [float]; - input plenum_cross_section_area [float]; - input intake_flow_rate [float]; - input idle_flow_rate [float]; - input runner_flow_rate [float]; - input molecular_afr [float]; - input idle_throttle_plate_position [float]; - input throttle_gamma [float]; - input runner_length [float]; - input velocity_decay [float]; - alias output __out [intake_channel]; -} - -public node intake { - input parameters: intake_parameters(); - input plenum_volume: parameters.plenum_volume; - input plenum_cross_section_area: parameters.plenum_cross_section_area; - input intake_flow_rate: parameters.intake_flow_rate; - input idle_flow_rate: parameters.idle_flow_rate; - input runner_flow_rate: parameters.runner_flow_rate; - input molecular_afr: parameters.molecular_afr; - input idle_throttle_plate_position: parameters.idle_throttle_plate_position; - input throttle_gamma: parameters.throttle_gamma; - input runner_length: parameters.runner_length; - input velocity_decay: parameters.velocity_decay; - alias output __out [_intake]: - _intake( - plenum_volume: plenum_volume, - plenum_cross_section_area: plenum_cross_section_area, - intake_flow_rate: intake_flow_rate, - idle_flow_rate: idle_flow_rate, - runner_flow_rate: runner_flow_rate, - molecular_afr: molecular_afr, - idle_throttle_plate_position: idle_throttle_plate_position, - throttle_gamma: throttle_gamma, - runner_length: runner_length, - velocity_decay: velocity_decay - ); -} - -// Exhaust System -public node impulse_response => __engine_sim__impulse_response { - input filename [string]; - input volume [float]: 1.0; - alias output __out [impulse_response_channel]; -} - -public node exhaust_system_parameters { - input volume: 100.0 * units.L; - input length: volume / collector_cross_section_area; - input collector_cross_section_area: circle_area(2.0 * units.inch); - input outlet_flow_rate: k_carb(1000.0); - input primary_tube_length: 10.0 * units.inch; - input primary_flow_rate: k_carb(100.0); - input audio_volume: 1.0; - input velocity_decay: 1.0; -} - -private node _exhaust_system => __engine_sim__exhaust_system { - input length [float]; - input collector_cross_section_area [float]; - input outlet_flow_rate [float]; - input primary_tube_length [float]; - input primary_flow_rate [float]; - input audio_volume [float]; - input velocity_decay [float]; - input impulse_response [impulse_response]; - alias output __out [exhaust_system_channel]; -} - -public node exhaust_system { - input parameters: exhaust_system_parameters(); - input length: parameters.length; - input collector_cross_section_area: parameters.collector_cross_section_area; - input outlet_flow_rate: parameters.outlet_flow_rate; - input primary_tube_length: parameters.primary_tube_length; - input primary_flow_rate: parameters.primary_flow_rate; - input audio_volume: parameters.audio_volume; - input velocity_decay: parameters.velocity_decay; - input impulse_response; - alias output __out [_exhaust_system]: - _exhaust_system( - length: length, - collector_cross_section_area: collector_cross_section_area, - outlet_flow_rate: outlet_flow_rate, - primary_tube_length: primary_tube_length, - primary_flow_rate: primary_flow_rate, - audio_volume: audio_volume, - velocity_decay: velocity_decay, - impulse_response: impulse_response - ); -} - -// Ignition Module -public node ignition_module => __engine_sim__ignition_module { - input timing_curve [function]; - input rev_limit [float]: 7000.0 * units.rpm; - input limiter_duration [float]: 0.5 * units.sec; - alias output __out [ignition_module_channel]; -} - -public node ignition_wire => __engine_sim__ignition_wire { - alias output __out [ignition_wire_channel]; -} - -public node vehicle => __engine_sim__vehicle { - input mass [float]: 1000 * units.kg; - input drag_coefficient [float]: 0.25; - input cross_sectional_area [float]: (72 * units.inch) * (72 * units.inch); - input diff_ratio [float]: 3.42; - input tire_radius [float]: 10 * units.inch; - input rolling_resistance [float]: 2000; - - alias output __out [vehicle_channel]; -} - -public node transmission => __engine_sim__transmission { - input max_clutch_torque [float]: 1000 * units.lb_ft; - alias output __out [transmission_channel]; -} diff --git a/es/objects/objects.mr b/es/objects/objects.mr deleted file mode 100644 index 46c5211..0000000 --- a/es/objects/objects.mr +++ /dev/null @@ -1,617 +0,0 @@ -module { - @name: "Objects" - @author: "ATG (Ange Yaghi)" - @copyright: "Copyright 2022, Ange Yaghi" -} - -private import "../types/atomic_types.mr" -private import "../types/conversions.mr" -private import "../types/operations.mr" -private import "../constants/units.mr" -private import "../actions/actions.mr" - -units units() - -// Channels -public node engine_channel => __engine_sim__engine_channel { /* void */ } -public node crankshaft_channel => __engine_sim__crankshaft_channel { /* void */ } -public node rod_journal_channel => __engine_sim__rod_journal { /* void */ } -public node connecting_rod_channel => __engine_sim__connecting_rod_channel { /* void */ } -public node piston_channel => __engine_sim__piston_channel { /* void */ } -public node cylinder_bank_channel => __engine_sim__cylinder_bank_channel { /* void */ } -public node function_channel => __engine_sim__function_channel { /* void */ } -public node cylinder_head_channel => __engine_sim__cylinder_head_channel { /* void */ } -public node camshaft_channel => __engine_sim__camshaft_channel { /* void */ } -public node intake_channel => __engine_sim__intake_channel { /* void */ } -public node exhaust_system_channel => __engine_sim__exhaust_system_channel { /* void */ } -public node ignition_module_channel => __engine_sim__ignition_module_channel { /* void */ } -public node ignition_wire_channel => __engine_sim__ignition_wire_channel { /* void */ } -public node fuel_channel => __engine_sim__fuel_channel { /* void */ } -public node impulse_response_channel => __engine_sim__impulse_response_channel { /* void */ } -public node valvetrain_channel => __engine_sim__valvetrain_channel { /* void */ } -public node vehicle_channel => __engine_sim__vehicle_channel { /* void */ } -public node transmission_channel => __engine_sim__transmission_channel { /* void */ } -public node throttle_channel => __engine_sim__throttle_channel { /* void */ } - -private node turbulence_to_flame_speed_ratio_default { - alias output __out: - function(5.0) - .add_sample(0.0, 3.0) - .add_sample(5.0, 1.5 * 5.0) - .add_sample(10.0, 1.5 * 10.0) - .add_sample(15.0, 1.5 * 15.0) - .add_sample(20.0, 1.5 * 20.0) - .add_sample(25.0, 1.5 * 25.0) - .add_sample(30.0, 1.5 * 30.0) - .add_sample(35.0, 1.5 * 35.0) - .add_sample(40.0, 1.5 * 40.0) - .add_sample(45.0, 1.5 * 45.0); -} - -public node fuel => __engine_sim__fuel { - input name [string]: "Gasoline [Default]"; - input molecular_mass [float]: 100 * units.g; - input energy_density [float]: 48.1 * units.kJ / units.g; - input density [float]: 0.755 * units.kg / units.L; - input molecular_afr [float]: 25 / 2.0; - input turbulence_to_flame_speed_ratio [function]: - turbulence_to_flame_speed_ratio_default(); - input max_burning_efficiency [float]: 0.8; - input burning_efficiency_randomness [float]: 0.5; - input low_efficiency_attenuation [float]: 0.6; - input max_turbulence_effect [float]: 2.0; - input max_dilution_effect [float]: 10.0; - alias output __out [fuel_channel]; -} - -// Engine -public node engine_parameters { - input name: ""; - input redline: 6000 * units.rpm; - input starter_speed: 200 * units.rpm; - input starter_torque: 200 * units.lb_ft; - input fuel: fuel(); -} - -private node _engine => __engine_sim__engine { - input name [string]; - - input redline [float]; - input starter_speed [float]; - input starter_torque [float]; - input dyno_min_speed [float]; - input dyno_max_speed [float]; - input dyno_hold_step [float]; - - input fuel [fuel]; - input throttle [throttle_channel]; - - input simulation_frequency [float]; - input hf_gain [float]; - input jitter [float]; - input noise [float]; - - alias output __out [engine_channel]; -} - -public node engine { - input params: engine_parameters(); - input name: params.name; - - input redline: params.redline; - input starter_speed: params.starter_speed; - input starter_torque: params.starter_torque; - input dyno_min_speed: 1000 * units.rpm; - input dyno_max_speed: redline; - input dyno_hold_step: 100 * units.rpm; - - input fuel: params.fuel; - input throttle_gamma: 1.0; - input throttle: - direct_throttle_linkage(gamma: throttle_gamma); - - input simulation_frequency: 10000; - input hf_gain: 0.01; - input jitter: 0.5; - input noise: 1.0; - - alias output __out [_engine]: - _engine( - name: name, - - redline: redline, - starter_speed: starter_speed, - starter_torque: starter_torque, - dyno_min_speed: dyno_min_speed, - dyno_max_speed: dyno_max_speed, - dyno_hold_step: dyno_hold_step, - - fuel: fuel, - throttle: throttle, - - simulation_frequency: simulation_frequency, - hf_gain: hf_gain, - jitter: jitter, - noise: noise - ); -} - -public node direct_throttle_linkage => __engine_sim__direct_throttle_linkage { - input gamma [float]: 1.0; - alias output __out [throttle_channel]; -} - -public node governor => __engine_sim__governor { - input min_speed [float]: 1.0; - input max_speed [float]: 1.0; - input min_v [float]: -2.0; - input max_v [float]: 2.0; - input k_s [float]: 1.0; - input k_d [float]: 300.0; - input gamma [float]: 0.1; - alias output __out [throttle_channel]; -} - -// Crankshaft -public node crankshaft_parameter_defaults { - input throw: 0.0; - input flywheel_mass: 0.0; - input mass: 0.0; - input friction_torque: 0.0; - input moment_of_inertia: 0.0; - input position_x: 0.0; - input position_y: 0.0; - input tdc: 0.0; -} - -private node _crankshaft => __engine_sim__crankshaft { - input throw [float]: 0.0; - input flywheel_mass [float]: 0.0; - input mass [float]: 0.0; - input friction_torque [float]: 0.0; - input moment_of_inertia [float]: 0.0; - input position_x [float]: 0.0; - input position_y [float]: 0.0; - input tdc [float]: 0.0; - alias output __out [crankshaft_channel]; -} - -public node crankshaft { - input params: crankshaft_parameter_defaults(); - input throw: params.throw; - input flywheel_mass: params.flywheel_mass; - input mass: params.mass; - input friction_torque: params.friction_torque; - input moment_of_inertia: params.moment_of_inertia; - input position_x: params.position_x; - input position_y: params.position_y; - input tdc: params.tdc; - alias output __out [_crankshaft]: - _crankshaft( - throw: throw, - flywheel_mass: flywheel_mass, - mass: mass, - friction_torque: friction_torque, - moment_of_inertia: moment_of_inertia, - position_x: position_x, - position_y: position_y, - tdc: tdc - ); -} - -// Rod Journal -public node rod_journal => __engine_sim__rod_journal { - input angle [float]: 0; - alias output __out [rod_journal_channel]; -} - -// Connecting Rod -private node connecting_rod_parameter_defaults { - input mass: 0.0; - input moment_of_inertia: 0.0; - input center_of_mass: 0.0; - input length: 0.0; - input slave_throw: 0.0; -} - -public node connecting_rod_parameters { - input copy: connecting_rod_parameter_defaults(); - input mass: copy.mass; - input moment_of_inertia: copy.moment_of_inertia; - input center_of_mass: copy.center_of_mass; - input length: copy.length; - input slave_throw: copy.slave_throw; -} - -private node _connecting_rod => __engine_sim__connecting_rod { - input mass [float]; - input moment_of_inertia [float]; - input center_of_mass [float]; - input length [float]; - input slave_throw [float]; - alias output __out [connecting_rod_channel]; -} - -public node connecting_rod { - input params: connecting_rod_parameters(); - alias output __out [_connecting_rod]: - _connecting_rod( - mass: params.mass, - moment_of_inertia: params.moment_of_inertia, - center_of_mass: params.center_of_mass, - length: params.length, - slave_throw: params.slave_throw - ); -} - -// Piston -public node piston_parameters { - input blowby: 0.0; - input compression_height: 0.0; - input wrist_pin_position: 0.0; - input wrist_pin_location: 0.0; - input displacement: 0.0; - input mass: 0.0; -} - -private node _piston => __engine_sim__piston { - input mass [float]: 0.0; - input blowby [float]: 0.0; - input compression_height [float]: 0.0; - input wrist_pin_position [float]: 0.0; - input displacement [float]: 0.0; - alias output __out [piston_channel]; -} - -public node piston { - input params: piston_parameters(); - input blowby: params.blowby; - alias output __out [_piston]: - _piston( - mass: params.mass, - blowby: blowby, - compression_height: params.compression_height, - wrist_pin_position: params.wrist_pin_position, - displacement: params.displacement - ); -} - -// Cylinder Bank -public node cylinder_bank_parameters { - input angle: 0.0; - input bore: 0.0; - input deck_height: 0.0; - input position_x: 0.0; - input position_y: 0.0; - input display_depth: 0.5; -} - -private node _cylinder_bank => __engine_sim__cylinder_bank { - input angle [float]: 0.0; - input bore [float]: 0.0; - input deck_height [float]: 0.0; - input position_x [float]: 0.0; - input position_y [float]: 0.0; - input display_depth [float]: 0.6; - alias output __out [cylinder_bank_channel]; -} - -public node cylinder_bank { - input parameters: cylinder_bank_parameters(); - input angle: parameters.angle; - input bore: parameters.bore; - input deck_height: parameters.deck_height; - input position_x: parameters.position_x; - input position_y: parameters.position_y; - input display_depth: parameters.display_depth; - alias output __out [_cylinder_bank]: - _cylinder_bank( - angle: angle, - bore: bore, - deck_height: deck_height, - position_x: position_x, - position_y: position_y, - display_depth: display_depth - ); -} - -// Function -public node function => __engine_sim__function { - input filter_radius [float]: 1.0; - alias output __out [function_channel]; -} - -// Cylinder -public node cylinder_friction_parameter_defaults { - output friction_k: 0.06; - output breakaway_friction: 0.0; - output breakaway_friction_velocity: 0.0; - output viscous_friction_coefficient: 0.0; -} - -public node cylinder_friction_parameters { - input copy: cylinder_friction_parameter_defaults(); - input friction_k: copy.friction_k; - input breakaway_friction: copy.breakaway_friction; - input breakaway_friction_velocity: copy.breakaway_friction_velocity; - input viscous_friction_coefficient: copy.viscous_friction_coefficient; -} - -// Valvetrain -public node standard_valvetrain => __engine_sim__standard_valvetrain { - input intake_camshaft [camshaft]; - input exhaust_camshaft [camshaft]; - alias output __out [valvetrain_channel]; -} - -public node vtec_valvetrain => __engine_sim__vtec_valvetrain { - input vtec_intake_camshaft [camshaft]; - input vtec_exhaust_camshaft [camshaft]; - input intake_camshaft [camshaft]; - input exhaust_camshaft [camshaft]; - - input min_rpm [float]: 5800 * units.rpm; - input min_speed [float]: 10 * units.mph; - input manifold_vacuum [float]: 1.0 * units.atm - 5.0 * units.inHg; - input min_throttle_position [float]: 0.3; - - alias output __out [valvetrain_channel]; -} - -// Cylinder Head -public node cylinder_head_parameters { - input intake_port_flow: function(); - input exhaust_port_flow: function(); - input chamber_volume: 118.0 * units.cc; - - input intake_runner_volume: 300.0 * units.cc; - input intake_runner_cross_section_area: circle_area(0.75 * units.inch); - - input exhaust_runner_volume: 300.0 * units.cc; - input exhaust_runner_cross_section_area: circle_area(0.85 * units.inch); - - input flip_display: false; -} - -private node _cylinder_head => __engine_sim__cylinder_head { - input intake_port_flow [function]; - input exhaust_port_flow [function]; - input valvetrain [valvetrain_channel]; - input chamber_volume [float]; - input intake_runner_volume [float]; - input intake_runner_cross_section_area [float]; - input exhaust_runner_volume [float]; - input exhaust_runner_cross_section_area [float]; - input flip_display [bool]; - alias output __out [cylinder_head_channel]; -} - -public node generic_cylinder_head { - input parameters: cylinder_head_parameters(); - input valvetrain; - - input intake_port_flow: parameters.intake_port_flow; - input exhaust_port_flow: parameters.exhaust_port_flow; - - input chamber_volume: parameters.chamber_volume; - - input intake_runner_volume: parameters.intake_runner_volume; - input intake_runner_cross_section_area: parameters.intake_runner_cross_section_area; - - input exhaust_runner_volume: parameters.exhaust_runner_volume; - input exhaust_runner_cross_section_area: parameters.exhaust_runner_cross_section_area; - - input flip_display: parameters.flip_display; - - alias output __out [_cylinder_head]: - _cylinder_head( - intake_port_flow: intake_port_flow, - exhaust_port_flow: exhaust_port_flow, - chamber_volume: chamber_volume, - intake_runner_volume: intake_runner_volume, - intake_runner_cross_section_area: intake_runner_cross_section_area, - exhaust_runner_volume: exhaust_runner_volume, - exhaust_runner_cross_section_area: exhaust_runner_cross_section_area, - flip_display: flip_display, - valvetrain: valvetrain - ); -} - -public node cylinder_head { - input parameters: cylinder_head_parameters(); - - input intake_camshaft; - input exhaust_camshaft; - - input intake_port_flow: parameters.intake_port_flow; - input exhaust_port_flow: parameters.exhaust_port_flow; - - input chamber_volume: parameters.chamber_volume; - - input intake_runner_volume: parameters.intake_runner_volume; - input intake_runner_cross_section_area: parameters.intake_runner_cross_section_area; - - input exhaust_runner_volume: parameters.exhaust_runner_volume; - input exhaust_runner_cross_section_area: parameters.exhaust_runner_cross_section_area; - - input flip_display: parameters.flip_display; - - alias output __out [_cylinder_head]: - generic_cylinder_head( - intake_port_flow: intake_port_flow, - exhaust_port_flow: exhaust_port_flow, - chamber_volume: chamber_volume, - intake_runner_volume: intake_runner_volume, - intake_runner_cross_section_area: intake_runner_cross_section_area, - exhaust_runner_volume: exhaust_runner_volume, - exhaust_runner_cross_section_area: exhaust_runner_cross_section_area, - flip_display: flip_display, - valvetrain: standard_valvetrain( - intake_camshaft: intake_camshaft, - exhaust_camshaft: exhaust_camshaft - ) - ); -} - -// Camshaft -public node camshaft_parameters { - input advance: 0.0; - input base_radius: 0.0; - input lobe_profile: function(); -} - -private node _camshaft => __engine_sim__camshaft { - input advance [float]; - input base_radius [float]; - input lobe_profile [function]; - alias output __out [camshaft_channel]; -} - -public node camshaft { - input parameters: camshaft_parameters(); - input advance: parameters.advance; - input base_radius: parameters.base_radius; - input lobe_profile: parameters.lobe_profile; - alias output __out [_camshaft]: - _camshaft( - advance: advance, - base_radius: base_radius, - lobe_profile: lobe_profile - ); -} - -// Intake -public node intake_parameters { - input plenum_volume: 2.0 * units.L; - input plenum_cross_section_area: 100.0 * units.cm2; - input intake_flow_rate: 0.0; - input idle_flow_rate: 0.0; - input molecular_afr: (25.0 / 2.0); - input idle_throttle_plate_position: 0.975; - input throttle_gamma: 2.0; - input runner_length: 4.0 * units.inch; - input runner_flow_rate: k_carb(200.0); - input velocity_decay: 0.25; -} - -private node _intake => __engine_sim__intake { - input plenum_volume [float]; - input plenum_cross_section_area [float]; - input intake_flow_rate [float]; - input idle_flow_rate [float]; - input runner_flow_rate [float]; - input molecular_afr [float]; - input idle_throttle_plate_position [float]; - input throttle_gamma [float]; - input runner_length [float]; - input velocity_decay [float]; - alias output __out [intake_channel]; -} - -public node intake { - input parameters: intake_parameters(); - input plenum_volume: parameters.plenum_volume; - input plenum_cross_section_area: parameters.plenum_cross_section_area; - input intake_flow_rate: parameters.intake_flow_rate; - input idle_flow_rate: parameters.idle_flow_rate; - input runner_flow_rate: parameters.runner_flow_rate; - input molecular_afr: parameters.molecular_afr; - input idle_throttle_plate_position: parameters.idle_throttle_plate_position; - input throttle_gamma: parameters.throttle_gamma; - input runner_length: parameters.runner_length; - input velocity_decay: parameters.velocity_decay; - alias output __out [_intake]: - _intake( - plenum_volume: plenum_volume, - plenum_cross_section_area: plenum_cross_section_area, - intake_flow_rate: intake_flow_rate, - idle_flow_rate: idle_flow_rate, - runner_flow_rate: runner_flow_rate, - molecular_afr: molecular_afr, - idle_throttle_plate_position: idle_throttle_plate_position, - throttle_gamma: throttle_gamma, - runner_length: runner_length, - velocity_decay: velocity_decay - ); -} - -// Exhaust System -public node impulse_response => __engine_sim__impulse_response { - input filename [string]; - input volume [float]: 1.0; - alias output __out [impulse_response_channel]; -} - -public node exhaust_system_parameters { - input volume: 100.0 * units.L; - input length: volume / collector_cross_section_area; - input collector_cross_section_area: circle_area(2.0 * units.inch); - input outlet_flow_rate: k_carb(1000.0); - input primary_tube_length: 10.0 * units.inch; - input primary_flow_rate: k_carb(100.0); - input audio_volume: 1.0; - input velocity_decay: 1.0; -} - -private node _exhaust_system => __engine_sim__exhaust_system { - input length [float]; - input collector_cross_section_area [float]; - input outlet_flow_rate [float]; - input primary_tube_length [float]; - input primary_flow_rate [float]; - input audio_volume [float]; - input velocity_decay [float]; - input impulse_response [impulse_response]; - alias output __out [exhaust_system_channel]; -} - -public node exhaust_system { - input parameters: exhaust_system_parameters(); - input length: parameters.length; - input collector_cross_section_area: parameters.collector_cross_section_area; - input outlet_flow_rate: parameters.outlet_flow_rate; - input primary_tube_length: parameters.primary_tube_length; - input primary_flow_rate: parameters.primary_flow_rate; - input audio_volume: parameters.audio_volume; - input velocity_decay: parameters.velocity_decay; - input impulse_response; - alias output __out [_exhaust_system]: - _exhaust_system( - length: length, - collector_cross_section_area: collector_cross_section_area, - outlet_flow_rate: outlet_flow_rate, - primary_tube_length: primary_tube_length, - primary_flow_rate: primary_flow_rate, - audio_volume: audio_volume, - velocity_decay: velocity_decay, - impulse_response: impulse_response - ); -} - -// Ignition Module -public node ignition_module => __engine_sim__ignition_module { - input timing_curve [function]; - input rev_limit [float]: 7000.0 * units.rpm; - input limiter_duration [float]: 0.5 * units.sec; - alias output __out [ignition_module_channel]; -} - -public node ignition_wire => __engine_sim__ignition_wire { - alias output __out [ignition_wire_channel]; -} - -public node vehicle => __engine_sim__vehicle { - input mass [float]: 1000 * units.kg; - input drag_coefficient [float]: 0.25; - input cross_sectional_area [float]: (72 * units.inch) * (72 * units.inch); - input diff_ratio [float]: 3.42; - input tire_radius [float]: 10 * units.inch; - input rolling_resistance [float]: 2000; - - alias output __out [vehicle_channel]; -} - -public node transmission => __engine_sim__transmission { - input max_clutch_torque [float]: 1000 * units.lb_ft; - alias output __out [transmission_channel]; -} diff --git a/es/operations.mr b/es/operations.mr deleted file mode 100644 index 223d056..0000000 --- a/es/operations.mr +++ /dev/null @@ -1,78 +0,0 @@ -module { - @name: "Operations" - @author: "ATG (Ange Yaghi)" - @copyright: "Copyright 2022, Ange Yaghi" -} - -private import "atomic_types.mr" -private import "conversions.mr" - -// Float operations - -public node float_negate => __engine_sim__float_negate { - input __in [float]; - alias output __out [float]; -} - -public node float_divide => __engine_sim__float_divide { - input __in0 [float]; - input __in1 [float]; - alias output __out [float]; -} - -public node float_multiply => __engine_sim__float_multiply { - input __in0 [float]; - input __in1 [float]; - alias output __out [float]; -} - -public node float_add => __engine_sim__float_add { - input __in0 [float]; - input __in1 [float]; - alias output __out [float]; -} - -public node float_subtract => __engine_sim__float_subtract { - input __in0 [float]; - input __in1 [float]; - alias output __out [float]; -} - -// String operations - -public node string_add => __engine_sim__string_add { - input __in0 [string]; - input __in1 [string]; - alias output __out [string]; -} - -// Int operations - -public node int_add => __engine_sim__int_add { - input __in0 [int]; - input __in1 [int]; - alias output __out [int]; -} - -public node int_mul => __engine_sim__int_multiply { - input __in0 [int]; - input __in1 [int]; - alias output __out [int]; -} - -public node int_sub => __engine_sim__int_subtract { - input __in0 [int]; - input __in1 [int]; - alias output __out [int]; -} - -public node int_div => __engine_sim__int_divide { - input __in0 [int]; - input __in1 [int]; - alias output __out [int]; -} - -public node int_negate => __engine_sim__int_negate { - input __in [int]; - alias output __out [int]; -} diff --git a/es/part-library/part_library.mr b/es/part-library/part_library.mr deleted file mode 100644 index 48c8b0a..0000000 --- a/es/part-library/part_library.mr +++ /dev/null @@ -1,5 +0,0 @@ -public import "parts/cam_lobes.mr" -public import "parts/camshafts.mr" -public import "parts/heads.mr" -public import "parts/intakes.mr" -public import "parts/ignition_modules.mr" diff --git a/es/part-library/parts/cam_lobes.mr b/es/part-library/parts/cam_lobes.mr deleted file mode 100644 index c8c80cf..0000000 --- a/es/part-library/parts/cam_lobes.mr +++ /dev/null @@ -1,53 +0,0 @@ -private import "engine_sim.mr" - -units units() - -private node add_sym_sample { - input angle; - input lift; - input this; - alias output __out: this; - - this.add_sample(angle * units.deg, lift * units.thou) - this.add_sample(-angle * units.deg, lift * units.thou) -} - -public node stock_454_intake_lobe_profile { - alias output __out: - harmonic_cam_lobe( - duration_at_50_thou: 194 * units.deg, - gamma: 0.8, - lift: 390 * units.thou, - steps: 100 - ); -} - -public node stock_454_exhaust_lobe_profile { - alias output __out: - harmonic_cam_lobe( - duration_at_50_thou: 202 * units.deg, - gamma: 0.8, - lift: 409 * units.thou, - steps: 100 - ); -} - -public node comp_cams_magnum_11_450_8_lobe_profile { - alias output __out: - harmonic_cam_lobe( - duration_at_50_thou: 232 * units.deg, - gamma: 0.75, - lift: 578 * units.thou, - steps: 100 - ); -} - -public node comp_cams_magnum_11_470_8_lobe_profile { - alias output __out: - harmonic_cam_lobe( - duration_at_50_thou: 252 * units.deg, - gamma: 0.8, - lift: 612 * units.thou, - steps: 100 - ); -} diff --git a/es/part-library/parts/camshafts.mr b/es/part-library/parts/camshafts.mr deleted file mode 100644 index 0a917ba..0000000 --- a/es/part-library/parts/camshafts.mr +++ /dev/null @@ -1,153 +0,0 @@ -private import "cam_lobes.mr" - -private import "engine_sim.mr" - -units units() - -public node chevy_bbc_camshaft_builder { - input lobe_profile: stock_454_intake_lobe_profile(); - input intake_lobe_profile: lobe_profile; - input exhaust_lobe_profile: lobe_profile; - input lobe_separation: 114.0 * units.deg; - input intake_lobe_center: lobe_separation; - input exhaust_lobe_center: lobe_separation; - input advance: 0.0 * units.deg; - input base_radius: 0.75 * units.inch; - - output intake_cam_0: _intake_cam_0; - output intake_cam_1: _intake_cam_1; - output exhaust_cam_0: _exhaust_cam_0; - output exhaust_cam_1: _exhaust_cam_1; - - camshaft_parameters params( - advance: advance, - base_radius: base_radius - ) - - camshaft _intake_cam_0(params, lobe_profile: intake_lobe_profile) - camshaft _intake_cam_1(params, lobe_profile: intake_lobe_profile) - camshaft _exhaust_cam_0(params, lobe_profile: exhaust_lobe_profile) - camshaft _exhaust_cam_1(params, lobe_profile: exhaust_lobe_profile) - - label rot90(90 * units.deg) - label rot360(360 * units.deg) - - _exhaust_cam_0 - .add_lobe(rot360 - exhaust_lobe_center) - .add_lobe(rot360 - exhaust_lobe_center + 3 * rot90) - .add_lobe(rot360 - exhaust_lobe_center + 5 * rot90) - .add_lobe(rot360 - exhaust_lobe_center + 6 * rot90) - - _exhaust_cam_1 - .add_lobe(rot360 - exhaust_lobe_center + 7 * rot90) - .add_lobe(rot360 - exhaust_lobe_center + 2 * rot90) - .add_lobe(rot360 - exhaust_lobe_center + 4 * rot90) - .add_lobe(rot360 - exhaust_lobe_center + 1 * rot90) - - _intake_cam_0 - .add_lobe(rot360 + intake_lobe_center) - .add_lobe(rot360 + intake_lobe_center + 3 * rot90) - .add_lobe(rot360 + intake_lobe_center + 5 * rot90) - .add_lobe(rot360 + intake_lobe_center + 6 * rot90) - - _intake_cam_1 - .add_lobe(rot360 + intake_lobe_center + 7 * rot90) - .add_lobe(rot360 + intake_lobe_center + 2 * rot90) - .add_lobe(rot360 + intake_lobe_center + 4 * rot90) - .add_lobe(rot360 + intake_lobe_center + 1 * rot90) -} - -public node vtwin_camshaft_builder { - input lobe_profile; - input intake_lobe_profile: lobe_profile; - input exhaust_lobe_profile: lobe_profile; - input lobe_separation: 114.0 * units.deg; - input intake_lobe_center: lobe_separation; - input exhaust_lobe_center: lobe_separation; - input advance: 0.0 * units.deg; - input base_radius: 0.75 * units.inch; - input angle: 90 * 3 * units.deg; - - output intake_cam_0: _intake_cam_0; - output intake_cam_1: _intake_cam_1; - output exhaust_cam_0: _exhaust_cam_0; - output exhaust_cam_1: _exhaust_cam_1; - - camshaft_parameters params( - advance: advance, - base_radius: base_radius - ) - - camshaft _intake_cam_0(params, lobe_profile: intake_lobe_profile) - camshaft _intake_cam_1(params, lobe_profile: intake_lobe_profile) - camshaft _exhaust_cam_0(params, lobe_profile: exhaust_lobe_profile) - camshaft _exhaust_cam_1(params, lobe_profile: exhaust_lobe_profile) - - label rot90(90 * units.deg) - label rot360(360 * units.deg) - - _exhaust_cam_0 - .add_lobe(rot360 - exhaust_lobe_center) - _exhaust_cam_1 - .add_lobe(rot360 - exhaust_lobe_center + angle) - _intake_cam_0 - .add_lobe(rot360 + intake_lobe_center) - _intake_cam_1 - .add_lobe(rot360 + intake_lobe_center + angle) -} - -public node vtwin90_camshaft_builder { - input lobe_profile; - input intake_lobe_profile: lobe_profile; - input exhaust_lobe_profile: lobe_profile; - input lobe_separation: 114.0 * units.deg; - input intake_lobe_center: lobe_separation; - input exhaust_lobe_center: lobe_separation; - input advance: 0.0 * units.deg; - input base_radius: 0.75 * units.inch; - - output intake_cam_0: camshaft.intake_cam_0; - output intake_cam_1: camshaft.intake_cam_1; - output exhaust_cam_0: camshaft.exhaust_cam_0; - output exhaust_cam_1: camshaft.exhaust_cam_1; - - vtwin_camshaft_builder camshaft( - lobe_profile: lobe_profile, - intake_lobe_profile: intake_lobe_profile, - exhaust_lobe_profile: exhaust_lobe_profile, - lobe_separation: lobe_separation, - intake_lobe_center: intake_lobe_center, - exhaust_lobe_center: exhaust_lobe_center, - advance: advance, - base_radius: base_radius, - angle: 90 * 3 * units.deg - ) -} - -public node chevy_454_stock_camshaft { - alias output __out: - chevy_bbc_camshaft_builder( - advance: 0 * units.deg, - intake_lobe_profile: stock_454_intake_lobe_profile(), - exhaust_lobe_profile: stock_454_exhaust_lobe_profile(), - intake_lobe_center: 108 * units.deg, - exhaust_lobe_center: 113 * units.deg); -} - -public node comp_cams_magnum_11_450_8 { - alias output __out: - chevy_bbc_camshaft_builder( - lobe_profile: comp_cams_magnum_11_450_8_lobe_profile(), - lobe_separation: 110 * units.deg, - advance: 4.0 * units.deg, - base_radius: 1000.0 * units.thou); -} - -public node comp_cams_magnum_11_470_8 { - alias output __out: - chevy_bbc_camshaft_builder( - lobe_profile: comp_cams_magnum_11_470_8_lobe_profile(), - lobe_separation: 110 * units.deg, - advance: 4.0 * units.deg, - base_radius: 1000.0 * units.thou); -} diff --git a/es/part-library/parts/heads.mr b/es/part-library/parts/heads.mr deleted file mode 100644 index 85b9a00..0000000 --- a/es/part-library/parts/heads.mr +++ /dev/null @@ -1,187 +0,0 @@ -private import "engine_sim.mr" - -units units() - -public node add_flow_sample { - input lift; - input flow; - input this; - alias output __out: this; - - this.add_sample(lift * units.thou, k_28inH2O(flow)) -} - -public node chevy_bbc_peanut_port_head { - input intake_camshaft; - input exhaust_camshaft; - input flip_display: false; - alias output __out: head; - - function intake_flow(50 * units.thou) - intake_flow - .add_flow_sample(0, 0) - .add_flow_sample(50, 25) - .add_flow_sample(100, 75) - .add_flow_sample(150, 100) - .add_flow_sample(200, 130) - .add_flow_sample(250, 180) - .add_flow_sample(300, 190) - .add_flow_sample(350, 220) - .add_flow_sample(400, 240) - .add_flow_sample(450, 250) - .add_flow_sample(500, 260) - .add_flow_sample(550, 260) - .add_flow_sample(600, 260) - .add_flow_sample(650, 255) - .add_flow_sample(700, 250) - - function exhaust_flow(50 * units.thou) - exhaust_flow - .add_flow_sample(0, 0) - .add_flow_sample(50, 25) - .add_flow_sample(100, 50) - .add_flow_sample(150, 75) - .add_flow_sample(200, 100) - .add_flow_sample(250, 125) - .add_flow_sample(300, 160) - .add_flow_sample(350, 175) - .add_flow_sample(400, 180) - .add_flow_sample(450, 190) - .add_flow_sample(500, 200) - .add_flow_sample(550, 205) - .add_flow_sample(600, 210) - .add_flow_sample(650, 210) - .add_flow_sample(700, 210) - - cylinder_head head( - chamber_volume: 118.0 * units.cc, - intake_runner_volume: 189.0 * units.cc, - intake_runner_cross_section_area: 37.8 * units.cm2, - - intake_port_flow: intake_flow, - exhaust_port_flow: exhaust_flow, - intake_camshaft: intake_camshaft, - exhaust_camshaft: exhaust_camshaft, - flip_display: flip_display - ) -} - -public node edelbrock_6055_rectangle_port { - input intake_camshaft; - input exhaust_camshaft; - input flip_display: false; - alias output __out: head; - - function intake_flow(50 * units.thou) - intake_flow - .add_flow_sample(0, 0) - .add_flow_sample(50, 25) - .add_flow_sample(100, 76) - .add_flow_sample(150, 100) - .add_flow_sample(200, 146) - .add_flow_sample(250, 175) - .add_flow_sample(300, 212) - .add_flow_sample(350, 230) - .add_flow_sample(400, 255) - .add_flow_sample(450, 275) - .add_flow_sample(500, 294) - .add_flow_sample(550, 300) - .add_flow_sample(600, 314) - .add_flow_sample(650, 314) - .add_flow_sample(700, 314) - - function exhaust_flow(50 * units.thou) - exhaust_flow - .add_flow_sample(0, 0) - .add_flow_sample(50, 25) - .add_flow_sample(100, 70) - .add_flow_sample(150, 100) - .add_flow_sample(200, 132) - .add_flow_sample(250, 140) - .add_flow_sample(300, 156) - .add_flow_sample(350, 170) - .add_flow_sample(400, 181) - .add_flow_sample(450, 191) - .add_flow_sample(500, 207) - .add_flow_sample(550, 214) - .add_flow_sample(600, 228) - .add_flow_sample(650, 228) - .add_flow_sample(700, 228) - - cylinder_head head( - chamber_volume: 118.0 * units.cc, - intake_runner_volume: 315.0 * units.cc, - intake_runner_cross_section_area: 78.75 * units.cm2, - - intake_port_flow: intake_flow, - exhaust_port_flow: exhaust_flow, - intake_camshaft: intake_camshaft, - exhaust_camshaft: exhaust_camshaft, - flip_display: flip_display - ) -} - -public node generic_small_engine_head { - input intake_camshaft; - input exhaust_camshaft; - input chamber_volume: 100.0 * units.cc; - input intake_runner_volume: 100.0 * units.cc; - input intake_runner_cross_section_area: 30.0 * units.cm2; - input exhaust_runner_volume: 100.0 * units.cc; - input exhaust_runner_cross_section_area: 30.0 * units.cm2; - - input flow_attenuation: 1.0; - input lift_scale: 1.0; - input flip_display: false; - alias output __out: head; - - function intake_flow(50 * units.thou) - intake_flow - .add_flow_sample(0 * lift_scale, 0 * flow_attenuation) - .add_flow_sample(50 * lift_scale, 25 * flow_attenuation) - .add_flow_sample(100 * lift_scale, 75 * flow_attenuation) - .add_flow_sample(150 * lift_scale, 100 * flow_attenuation) - .add_flow_sample(200 * lift_scale, 130 * flow_attenuation) - .add_flow_sample(250 * lift_scale, 180 * flow_attenuation) - .add_flow_sample(300 * lift_scale, 190 * flow_attenuation) - .add_flow_sample(350 * lift_scale, 220 * flow_attenuation) - .add_flow_sample(400 * lift_scale, 240 * flow_attenuation) - .add_flow_sample(450 * lift_scale, 250 * flow_attenuation) - .add_flow_sample(500 * lift_scale, 260 * flow_attenuation) - .add_flow_sample(550 * lift_scale, 260 * flow_attenuation) - .add_flow_sample(600 * lift_scale, 260 * flow_attenuation) - .add_flow_sample(650 * lift_scale, 255 * flow_attenuation) - .add_flow_sample(700 * lift_scale, 250 * flow_attenuation) - - function exhaust_flow(50 * units.thou) - exhaust_flow - .add_flow_sample(0 * lift_scale, 0 * flow_attenuation) - .add_flow_sample(50 * lift_scale, 25 * flow_attenuation) - .add_flow_sample(100 * lift_scale, 50 * flow_attenuation) - .add_flow_sample(150 * lift_scale, 75 * flow_attenuation) - .add_flow_sample(200 * lift_scale, 100 * flow_attenuation) - .add_flow_sample(250 * lift_scale, 125 * flow_attenuation) - .add_flow_sample(300 * lift_scale, 160 * flow_attenuation) - .add_flow_sample(350 * lift_scale, 175 * flow_attenuation) - .add_flow_sample(400 * lift_scale, 180 * flow_attenuation) - .add_flow_sample(450 * lift_scale, 190 * flow_attenuation) - .add_flow_sample(500 * lift_scale, 200 * flow_attenuation) - .add_flow_sample(550 * lift_scale, 205 * flow_attenuation) - .add_flow_sample(600 * lift_scale, 210 * flow_attenuation) - .add_flow_sample(650 * lift_scale, 210 * flow_attenuation) - .add_flow_sample(700 * lift_scale, 210 * flow_attenuation) - - cylinder_head head( - chamber_volume: chamber_volume, - intake_runner_volume: intake_runner_volume, - intake_runner_cross_section_area: intake_runner_cross_section_area, - exhaust_runner_volume: exhaust_runner_volume, - exhaust_runner_cross_section_area: exhaust_runner_cross_section_area, - - intake_port_flow: intake_flow, - exhaust_port_flow: exhaust_flow, - intake_camshaft: intake_camshaft, - exhaust_camshaft: exhaust_camshaft, - flip_display: flip_display - ) -} diff --git a/es/part-library/parts/ignition_modules.mr b/es/part-library/parts/ignition_modules.mr deleted file mode 100644 index a75144f..0000000 --- a/es/part-library/parts/ignition_modules.mr +++ /dev/null @@ -1,50 +0,0 @@ -private import "engine_sim.mr" - -units units() -label cycle(2 * 360 * units.deg) - -public node chevy_bbc_distributor { - input wires; - input timing_curve; - input rev_limit: 5500 * units.rpm; - alias output __out: - ignition_module(timing_curve: timing_curve, rev_limit: rev_limit) - .connect_wire(wires.wire1, (0.0 / 8.0) * cycle) - .connect_wire(wires.wire8, (1.0 / 8.0) * cycle) - .connect_wire(wires.wire4, (2.0 / 8.0) * cycle) - .connect_wire(wires.wire3, (3.0 / 8.0) * cycle) - .connect_wire(wires.wire6, (4.0 / 8.0) * cycle) - .connect_wire(wires.wire5, (5.0 / 8.0) * cycle) - .connect_wire(wires.wire7, (6.0 / 8.0) * cycle) - .connect_wire(wires.wire2, (7.0 / 8.0) * cycle); -} - -public node chevy_sbc_distributor { - input wires; - input timing_curve; - input rev_limit: 5500 * units.rpm; - alias output __out: chevy_bbc_distributor( - wires: wires, - timing_curve: timing_curve, - rev_limit: rev_limit - ); -} - -public node vtwin90_distributor { - input wires; - input timing_curve; - input rev_limit: 5500 * units.rpm; - alias output __out: - ignition_module(timing_curve: timing_curve, rev_limit: rev_limit) - .connect_wire(wires.wire1, (0.0 / 8.0) * cycle) - .connect_wire(wires.wire2, (3.0 / 8.0) * cycle); -} - -public node single_cylinder_distributor { - input wires; - input timing_curve; - input rev_limit: 5500 * units.rpm; - alias output __out: - ignition_module(timing_curve: timing_curve, rev_limit: rev_limit) - .connect_wire(wires.wire1, (0.0 / 8.0) * cycle); -} diff --git a/es/part-library/parts/intakes.mr b/es/part-library/parts/intakes.mr deleted file mode 100644 index 502beae..0000000 --- a/es/part-library/parts/intakes.mr +++ /dev/null @@ -1,45 +0,0 @@ -private import "engine_sim.mr" - -units units() - -public node chevy_bbc_stock_intake { - input carburetor_cfm: 650.0; - input idle_flow_rate_cfm: 1.0; - input idle_throttle_plate_position: 0.975; - input throttle_gamma: 2.0; - - alias output __out: intake; - - intake intake( - plenum_volume: 2.0 * units.L, - plenum_cross_section_area: 100.0 * units.cm2, - intake_flow_rate: k_carb(carburetor_cfm), - idle_flow_rate: k_carb(idle_flow_rate_cfm), - idle_throttle_plate_position: idle_throttle_plate_position, - throttle_gamma: throttle_gamma, - runner_flow_rate: k_carb(300.0), - runner_length: 6.0 * units.inch, - velocity_decay: 1.0 - ) -} - -public node performer_rpm_intake { - input carburetor_cfm: 650.0; - input idle_flow_rate_cfm: 1.0; - input idle_throttle_plate_position: 0.975; - input throttle_gamma: 2.0; - - alias output __out: intake; - - intake intake( - plenum_volume: 2.0 * units.L, - plenum_cross_section_area: 100.0 * units.cm2, - intake_flow_rate: k_carb(carburetor_cfm), - idle_flow_rate: k_carb(idle_flow_rate_cfm), - idle_throttle_plate_position: idle_throttle_plate_position, - throttle_gamma: throttle_gamma, - runner_flow_rate: k_carb(500.0), - runner_length: 6.0 * units.inch, - velocity_decay: 0.1 - ) -} diff --git a/es/radial_9.mr b/es/radial_9.mr deleted file mode 100644 index 1ebb4c9..0000000 --- a/es/radial_9.mr +++ /dev/null @@ -1,6 +0,0 @@ -import "engine_sim.mr" -import "themes/default.mr" -import "engines/atg-video-2/09_radial_9.mr" - -use_default_theme() -main() diff --git a/es/settings/application_settings.mr b/es/settings/application_settings.mr deleted file mode 100644 index 98ba2f0..0000000 --- a/es/settings/application_settings.mr +++ /dev/null @@ -1,24 +0,0 @@ -private import "engine_sim.mr" - -units units() - -public node set_application_settings => __engine_sim__set_application_settings { - input start_fullscreen [bool]: false; - input power_units [string]: "HP"; - input torque_units [string]: "FTLBS"; - input speed_units [string]: "MPH"; - input pressure_units [string]: "INHG"; - input boost_units [string]: "PSI"; - input color_background [int]: 0x0E1012; - input color_foreground [int]: 0xFFFFFF; - input color_shadow [int]: 0x0E1012; - input color_highlight1 [int]: 0xEF4545; - input color_highlight2 [int]: 0xFFFFFF; - input color_pink [int]: 0xF394BE; - input color_red [int]: 0xEE4445; - input color_orange [int]: 0xF4802A; - input color_yellow [int]: 0xFDBD2E; - input color_blue [int]: 0x77CEE0; - input color_green [int]: 0xBDD869; - -} diff --git a/es/simple_test.mr b/es/simple_test.mr deleted file mode 100644 index 011ac78..0000000 --- a/es/simple_test.mr +++ /dev/null @@ -1,86 +0,0 @@ -import "engine_sim.mr" - -units units() -constants constants() - -public node simple_1cyl { - alias output __out: engine( - name: "Simple 1-Cylinder", - starter_torque: 50 * units.lb_ft, - starter_speed: 500 * units.rpm, - redline: 5000 * units.rpm, - simulation_frequency: 10000 - ) - - crankshaft c0( - throw: 80 * units.mm / 2, - flywheel_mass: 5 * units.lb, - mass: 5 * units.lb, - friction_torque: 3.0 * units.lb_ft, - moment_of_inertia: 0.2, - position_x: 0.0, - position_y: 0.0, - tdc: constants.pi / 2 - ) - - rod_journal rj0(angle: 0.0) - c0.add_rod_journal(rj0) - - cylinder_bank_parameters bank_params( - angle: 0.0, - bore: 80 * units.mm, - deck_height: 200 * units.mm - ) - - c0.add_cylinder_bank(bank_params) - - intake_parameters intake_params( - flow_rate: 0.0, - radius: 20 * units.mm - ) - - exhaust_system_parameters exhaust_params( - primary_length: 500 * units.mm, - primary_radius: 20 * units.mm, - collector_radius: 30 * units.mm, - collector_length: 200 * units.mm, - secondary_radius: 25 * units.mm, - secondary_length: 500 * units.mm, - tailpipe_radius: 30 * units.mm, - tailpipe_length: 1000 * units.mm, - atmosphere_volume: 100.0 - ) - - piston_parameters piston( - mass: 100 * units.g, - compression_height: 1.0 * units.inch, - wrist_pin_position: 0.0, - displacement: 0.0 - ) - - connecting_rod_parameters rod( - mass: 100 * units.g, - moment_of_inertia: 0.001, - length: 100 * units.mm, - center_of_mass: 0.5 - ) - - rod_journal rj(angle: 0.0) - - ignition_wire_parameters wire_params( - index: 0 - ) - - bank_params.add_cylinder( - intake: intake_params, - exhaust_system: exhaust_params, - piston: piston, - connecting_rod: rod, - rod_journal: rj, - ignition_wire: wire_params, - sound_attenuation: 1.0, - primary_length: 0.0 - ) -} - -set_engine(simple_1cyl()) diff --git a/es/simple_v8_test.mr b/es/simple_v8_test.mr deleted file mode 100644 index d20106f..0000000 --- a/es/simple_v8_test.mr +++ /dev/null @@ -1,124 +0,0 @@ -import "engine_sim.mr" - -units units() -constants constants() - -public node simple_v8 { - alias output __out: engine( - name: "Simple V8 Test", - starter_torque: 100 * units.lb_ft, - starter_speed: 500 * units.rpm, - redline: 6000 * units.rpm, - simulation_frequency: 10000 - ) - - crankshaft c0( - throw: 90 * units.mm / 2, - flywheel_mass: 20 * units.lb, - mass: 30 * units.lb, - friction_torque: 10.0 * units.lb_ft, - moment_of_inertia: 0.4, - position_x: 0.0, - position_y: 0.0, - tdc: constants.pi / 2 - ) - - rod_journal rj0(angle: 0.0) - c0.add_rod_journal(rj0) - - cylinder_bank_parameters bank_params( - bore: 100 * units.mm, - deck_height: 200 * units.mm - ) - - piston_parameters piston_params( - mass: 350 * units.g, - compression_height: 1.2 * units.inch, - wrist_pin_position: 0.0, - displacement: 0.0 - ) - - connecting_rod_parameters cr_params( - mass: 400.0 * units.g, - moment_of_inertia: 0.002, - center_of_mass: 0.0, - length: 6.0 * units.inch - ) - - intake_parameters intake_params( - flow_rate: 5.0, - radius: 35 * units.mm - ) - - exhaust_system_parameters exhaust_params( - primary_length: 600 * units.mm, - primary_radius: 25 * units.mm, - collector_radius: 40 * units.mm, - collector_length: 200 * units.mm, - secondary_radius: 35 * units.mm, - secondary_length: 500 * units.mm, - tailpipe_radius: 40 * units.mm, - tailpipe_length: 1500 * units.mm, - atmosphere_volume: 100.0 - ) - - ignition_wire_parameters wire_params(index: 0) - - cylinder_bank b0(bank_params, angle: 0 * units.deg) - b0.add_cylinder( - intake: intake_params, - exhaust_system: exhaust_params, - piston: piston_params, - connecting_rod: cr_params, - rod_journal: rj0, - ignition_wire: wire_params, - sound_attenuation: 1.0, - primary_length: 0.0 - ) - - __out.add_cylinder_bank(b0) - __out.add_crankshaft(c0) - - harmonic_cam_lobe lobe( - duration_at_50_thou: 220 * units.deg, - gamma: 1.0, - lift: 250 * units.thou, - steps: 100 - ) - - harmonic_camshaft camshaft( - lobe_profile: lobe, - base_radius: 500 * units.thou - ) - - b0.set_cylinder_head( - cylinder_head( - chambers: [ - combustion_chamber(chamber_volume: 65 * units.cc) - ], - intake_camshaft: camshaft, - exhaust_camshaft: camshaft, - intake_flow_attenuation: 1.5, - exhaust_flow_attenuation: 1.5, - intake_runner_cross_section_area: 12.0 * units.cm2, - exhaust_runner_cross_section_area: 12.0 * units.cm2 - ) - ) - - function timing_curve(1000 * units.rpm) - timing_curve - .add_sample(0000 * units.rpm, 10 * units.deg) - .add_sample(1000 * units.rpm, 15 * units.deg) - .add_sample(2000 * units.rpm, 25 * units.deg) - .add_sample(3000 * units.rpm, 32 * units.deg) - - distributor distributor( - wires: [wire_params], - timing_curve: timing_curve, - rev_limit: 6000 * units.rpm - ) - - __out.add_ignition_module(distributor) -} - -set_engine(simple_v8()) diff --git a/es/sound-library/archive/engine_01.wav b/es/sound-library/archive/engine_01.wav deleted file mode 100644 index 6a5d009..0000000 Binary files a/es/sound-library/archive/engine_01.wav and /dev/null differ diff --git a/es/sound-library/archive/engine_02.wav b/es/sound-library/archive/engine_02.wav deleted file mode 100644 index d37c27e..0000000 Binary files a/es/sound-library/archive/engine_02.wav and /dev/null differ diff --git a/es/sound-library/archive/engine_03.wav b/es/sound-library/archive/engine_03.wav deleted file mode 100644 index 085df62..0000000 Binary files a/es/sound-library/archive/engine_03.wav and /dev/null differ diff --git a/es/sound-library/archive/engine_04.wav b/es/sound-library/archive/engine_04.wav deleted file mode 100644 index 7892f90..0000000 Binary files a/es/sound-library/archive/engine_04.wav and /dev/null differ diff --git a/es/sound-library/archive/test_engine.wav b/es/sound-library/archive/test_engine.wav deleted file mode 100644 index dd90809..0000000 Binary files a/es/sound-library/archive/test_engine.wav and /dev/null differ diff --git a/es/sound-library/archive/test_engine_01_16.wav b/es/sound-library/archive/test_engine_01_16.wav deleted file mode 100644 index 29536c7..0000000 Binary files a/es/sound-library/archive/test_engine_01_16.wav and /dev/null differ diff --git a/es/sound-library/archive/test_engine_02_16.wav b/es/sound-library/archive/test_engine_02_16.wav deleted file mode 100644 index f7b1afb..0000000 Binary files a/es/sound-library/archive/test_engine_02_16.wav and /dev/null differ diff --git a/es/sound-library/archive/test_engine_03_16.wav b/es/sound-library/archive/test_engine_03_16.wav deleted file mode 100644 index 55b1615..0000000 Binary files a/es/sound-library/archive/test_engine_03_16.wav and /dev/null differ diff --git a/es/sound-library/archive/test_engine_04_16.wav b/es/sound-library/archive/test_engine_04_16.wav deleted file mode 100644 index 72b8122..0000000 Binary files a/es/sound-library/archive/test_engine_04_16.wav and /dev/null differ diff --git a/es/sound-library/archive/test_engine_05_16.wav b/es/sound-library/archive/test_engine_05_16.wav deleted file mode 100644 index a561419..0000000 Binary files a/es/sound-library/archive/test_engine_05_16.wav and /dev/null differ diff --git a/es/sound-library/archive/test_engine_06_16.wav b/es/sound-library/archive/test_engine_06_16.wav deleted file mode 100644 index 59dbea5..0000000 Binary files a/es/sound-library/archive/test_engine_06_16.wav and /dev/null differ diff --git a/es/sound-library/archive/test_engine_07_16.wav b/es/sound-library/archive/test_engine_07_16.wav deleted file mode 100644 index a5dd548..0000000 Binary files a/es/sound-library/archive/test_engine_07_16.wav and /dev/null differ diff --git a/es/sound-library/archive/test_engine_08_16.wav b/es/sound-library/archive/test_engine_08_16.wav deleted file mode 100644 index 2f6e608..0000000 Binary files a/es/sound-library/archive/test_engine_08_16.wav and /dev/null differ diff --git a/es/sound-library/archive/test_engine_09_16.wav b/es/sound-library/archive/test_engine_09_16.wav deleted file mode 100644 index bab50d5..0000000 Binary files a/es/sound-library/archive/test_engine_09_16.wav and /dev/null differ diff --git a/es/sound-library/archive/test_engine_10_16.wav b/es/sound-library/archive/test_engine_10_16.wav deleted file mode 100644 index c1088eb..0000000 Binary files a/es/sound-library/archive/test_engine_10_16.wav and /dev/null differ diff --git a/es/sound-library/archive/test_engine_11_16.wav b/es/sound-library/archive/test_engine_11_16.wav deleted file mode 100644 index eacc70b..0000000 Binary files a/es/sound-library/archive/test_engine_11_16.wav and /dev/null differ diff --git a/es/sound-library/archive/test_engine_12_16.wav b/es/sound-library/archive/test_engine_12_16.wav deleted file mode 100644 index d4bb01d..0000000 Binary files a/es/sound-library/archive/test_engine_12_16.wav and /dev/null differ diff --git a/es/sound-library/archive/test_engine_13_16.wav b/es/sound-library/archive/test_engine_13_16.wav deleted file mode 100644 index 94e9af0..0000000 Binary files a/es/sound-library/archive/test_engine_13_16.wav and /dev/null differ diff --git a/es/sound-library/archive/test_engine_14_eq_adjusted_16.wav b/es/sound-library/archive/test_engine_14_eq_adjusted_16.wav deleted file mode 100644 index 0734e9f..0000000 Binary files a/es/sound-library/archive/test_engine_14_eq_adjusted_16.wav and /dev/null differ diff --git a/es/sound-library/archive/test_engine_15_eq_adjusted_16.wav b/es/sound-library/archive/test_engine_15_eq_adjusted_16.wav deleted file mode 100644 index e6a87df..0000000 Binary files a/es/sound-library/archive/test_engine_15_eq_adjusted_16.wav and /dev/null differ diff --git a/es/sound-library/archive/test_engine_16.wav b/es/sound-library/archive/test_engine_16.wav deleted file mode 100644 index 5b9d265..0000000 Binary files a/es/sound-library/archive/test_engine_16.wav and /dev/null differ diff --git a/es/sound-library/archive/test_engine_16_eq_adjusted_16.wav b/es/sound-library/archive/test_engine_16_eq_adjusted_16.wav deleted file mode 100644 index c115631..0000000 Binary files a/es/sound-library/archive/test_engine_16_eq_adjusted_16.wav and /dev/null differ diff --git a/es/sound-library/archive/test_engine_17.wav b/es/sound-library/archive/test_engine_17.wav deleted file mode 100644 index ca98c2d..0000000 Binary files a/es/sound-library/archive/test_engine_17.wav and /dev/null differ diff --git a/es/sound-library/archive/test_engine_18.wav b/es/sound-library/archive/test_engine_18.wav deleted file mode 100644 index 5251a7e..0000000 Binary files a/es/sound-library/archive/test_engine_18.wav and /dev/null differ diff --git a/es/sound-library/impulse_responses.mr b/es/sound-library/impulse_responses.mr deleted file mode 100644 index 5fca714..0000000 --- a/es/sound-library/impulse_responses.mr +++ /dev/null @@ -1,26 +0,0 @@ -private import "engine_sim.mr" - -public node impulse_response_library { - output default_0: impulse_response(filename: "smooth/smooth_39.wav", volume: 0.001); - - output real_engine_0: - impulse_response(filename: "archive/test_engine_14_eq_adjusted_16.wav", volume: 0.001); - output real_engine_1: - impulse_response(filename: "archive/test_engine_15_eq_adjusted_16.wav", volume: 0.001); - output real_engine_2: - impulse_response(filename: "archive/test_engine_16_eq_adjusted_16.wav", volume: 0.001); - - output sharp_0: - impulse_response(filename: "sharp/sharp_01.wav", volume: 0.001); - - output mild_exhaust_0: - impulse_response(filename: "new/mild_exhaust.wav", volume: 0.01); - output mild_exhaust_0_reverb: - impulse_response(filename: "new/mild_exhaust_reverb.wav", volume: 0.01); - output minimal_muffling_01: - impulse_response(filename: "new/minimal_muffling_01.wav", volume: 0.01); - output minimal_muffling_02: - impulse_response(filename: "new/minimal_muffling_02.wav", volume: 0.01); - output minimal_muffling_03: - impulse_response(filename: "new/minimal_muffling_03.wav", volume: 0.01); -} diff --git a/es/sound-library/new/mild_exhaust.wav b/es/sound-library/new/mild_exhaust.wav deleted file mode 100644 index 990f0be..0000000 Binary files a/es/sound-library/new/mild_exhaust.wav and /dev/null differ diff --git a/es/sound-library/new/mild_exhaust_reverb.wav b/es/sound-library/new/mild_exhaust_reverb.wav deleted file mode 100644 index 5f96f60..0000000 Binary files a/es/sound-library/new/mild_exhaust_reverb.wav and /dev/null differ diff --git a/es/sound-library/new/minimal_muffling_01.wav b/es/sound-library/new/minimal_muffling_01.wav deleted file mode 100644 index 8cbea59..0000000 Binary files a/es/sound-library/new/minimal_muffling_01.wav and /dev/null differ diff --git a/es/sound-library/new/minimal_muffling_02.wav b/es/sound-library/new/minimal_muffling_02.wav deleted file mode 100644 index 6d3f868..0000000 Binary files a/es/sound-library/new/minimal_muffling_02.wav and /dev/null differ diff --git a/es/sound-library/new/minimal_muffling_03.wav b/es/sound-library/new/minimal_muffling_03.wav deleted file mode 100644 index ebd71e3..0000000 Binary files a/es/sound-library/new/minimal_muffling_03.wav and /dev/null differ diff --git a/es/sound-library/sharp/sharp_01.wav b/es/sound-library/sharp/sharp_01.wav deleted file mode 100644 index ebd71e3..0000000 Binary files a/es/sound-library/sharp/sharp_01.wav and /dev/null differ diff --git a/es/sound-library/smooth/smooth_01.wav b/es/sound-library/smooth/smooth_01.wav deleted file mode 100644 index 3b7a568..0000000 Binary files a/es/sound-library/smooth/smooth_01.wav and /dev/null differ diff --git a/es/sound-library/smooth/smooth_02.wav b/es/sound-library/smooth/smooth_02.wav deleted file mode 100644 index efb0a59..0000000 Binary files a/es/sound-library/smooth/smooth_02.wav and /dev/null differ diff --git a/es/sound-library/smooth/smooth_03.wav b/es/sound-library/smooth/smooth_03.wav deleted file mode 100644 index ab302bd..0000000 Binary files a/es/sound-library/smooth/smooth_03.wav and /dev/null differ diff --git a/es/sound-library/smooth/smooth_04.wav b/es/sound-library/smooth/smooth_04.wav deleted file mode 100644 index 1f7d6d3..0000000 Binary files a/es/sound-library/smooth/smooth_04.wav and /dev/null differ diff --git a/es/sound-library/smooth/smooth_05.wav b/es/sound-library/smooth/smooth_05.wav deleted file mode 100644 index ef8632c..0000000 Binary files a/es/sound-library/smooth/smooth_05.wav and /dev/null differ diff --git a/es/sound-library/smooth/smooth_06.wav b/es/sound-library/smooth/smooth_06.wav deleted file mode 100644 index 8b0465e..0000000 Binary files a/es/sound-library/smooth/smooth_06.wav and /dev/null differ diff --git a/es/sound-library/smooth/smooth_07.wav b/es/sound-library/smooth/smooth_07.wav deleted file mode 100644 index da9b830..0000000 Binary files a/es/sound-library/smooth/smooth_07.wav and /dev/null differ diff --git a/es/sound-library/smooth/smooth_08.wav b/es/sound-library/smooth/smooth_08.wav deleted file mode 100644 index 0cce1db..0000000 Binary files a/es/sound-library/smooth/smooth_08.wav and /dev/null differ diff --git a/es/sound-library/smooth/smooth_09.wav b/es/sound-library/smooth/smooth_09.wav deleted file mode 100644 index 96d0015..0000000 Binary files a/es/sound-library/smooth/smooth_09.wav and /dev/null differ diff --git a/es/sound-library/smooth/smooth_10.wav b/es/sound-library/smooth/smooth_10.wav deleted file mode 100644 index 0740173..0000000 Binary files a/es/sound-library/smooth/smooth_10.wav and /dev/null differ diff --git a/es/sound-library/smooth/smooth_11.wav b/es/sound-library/smooth/smooth_11.wav deleted file mode 100644 index 94f2052..0000000 Binary files a/es/sound-library/smooth/smooth_11.wav and /dev/null differ diff --git a/es/sound-library/smooth/smooth_12.wav b/es/sound-library/smooth/smooth_12.wav deleted file mode 100644 index 3e47eea..0000000 Binary files a/es/sound-library/smooth/smooth_12.wav and /dev/null differ diff --git a/es/sound-library/smooth/smooth_13.wav b/es/sound-library/smooth/smooth_13.wav deleted file mode 100644 index c854244..0000000 Binary files a/es/sound-library/smooth/smooth_13.wav and /dev/null differ diff --git a/es/sound-library/smooth/smooth_14.wav b/es/sound-library/smooth/smooth_14.wav deleted file mode 100644 index 5131efb..0000000 Binary files a/es/sound-library/smooth/smooth_14.wav and /dev/null differ diff --git a/es/sound-library/smooth/smooth_15.wav b/es/sound-library/smooth/smooth_15.wav deleted file mode 100644 index bbfd1bb..0000000 Binary files a/es/sound-library/smooth/smooth_15.wav and /dev/null differ diff --git a/es/sound-library/smooth/smooth_16.wav b/es/sound-library/smooth/smooth_16.wav deleted file mode 100644 index bd18bc4..0000000 Binary files a/es/sound-library/smooth/smooth_16.wav and /dev/null differ diff --git a/es/sound-library/smooth/smooth_17.wav b/es/sound-library/smooth/smooth_17.wav deleted file mode 100644 index 03ab2f1..0000000 Binary files a/es/sound-library/smooth/smooth_17.wav and /dev/null differ diff --git a/es/sound-library/smooth/smooth_18.wav b/es/sound-library/smooth/smooth_18.wav deleted file mode 100644 index 6c7257b..0000000 Binary files a/es/sound-library/smooth/smooth_18.wav and /dev/null differ diff --git a/es/sound-library/smooth/smooth_19.wav b/es/sound-library/smooth/smooth_19.wav deleted file mode 100644 index b2614c9..0000000 Binary files a/es/sound-library/smooth/smooth_19.wav and /dev/null differ diff --git a/es/sound-library/smooth/smooth_20.wav b/es/sound-library/smooth/smooth_20.wav deleted file mode 100644 index 0cd38fd..0000000 Binary files a/es/sound-library/smooth/smooth_20.wav and /dev/null differ diff --git a/es/sound-library/smooth/smooth_21.wav b/es/sound-library/smooth/smooth_21.wav deleted file mode 100644 index b2cb5d7..0000000 Binary files a/es/sound-library/smooth/smooth_21.wav and /dev/null differ diff --git a/es/sound-library/smooth/smooth_22.wav b/es/sound-library/smooth/smooth_22.wav deleted file mode 100644 index a8d3a8b..0000000 Binary files a/es/sound-library/smooth/smooth_22.wav and /dev/null differ diff --git a/es/sound-library/smooth/smooth_23.wav b/es/sound-library/smooth/smooth_23.wav deleted file mode 100644 index 719a96a..0000000 Binary files a/es/sound-library/smooth/smooth_23.wav and /dev/null differ diff --git a/es/sound-library/smooth/smooth_24.wav b/es/sound-library/smooth/smooth_24.wav deleted file mode 100644 index 89112b5..0000000 Binary files a/es/sound-library/smooth/smooth_24.wav and /dev/null differ diff --git a/es/sound-library/smooth/smooth_25.wav b/es/sound-library/smooth/smooth_25.wav deleted file mode 100644 index c775a9a..0000000 Binary files a/es/sound-library/smooth/smooth_25.wav and /dev/null differ diff --git a/es/sound-library/smooth/smooth_26.wav b/es/sound-library/smooth/smooth_26.wav deleted file mode 100644 index d01ec5c..0000000 Binary files a/es/sound-library/smooth/smooth_26.wav and /dev/null differ diff --git a/es/sound-library/smooth/smooth_27.wav b/es/sound-library/smooth/smooth_27.wav deleted file mode 100644 index 2143889..0000000 Binary files a/es/sound-library/smooth/smooth_27.wav and /dev/null differ diff --git a/es/sound-library/smooth/smooth_28.wav b/es/sound-library/smooth/smooth_28.wav deleted file mode 100644 index e4c4f17..0000000 Binary files a/es/sound-library/smooth/smooth_28.wav and /dev/null differ diff --git a/es/sound-library/smooth/smooth_29.wav b/es/sound-library/smooth/smooth_29.wav deleted file mode 100644 index a523100..0000000 Binary files a/es/sound-library/smooth/smooth_29.wav and /dev/null differ diff --git a/es/sound-library/smooth/smooth_30.wav b/es/sound-library/smooth/smooth_30.wav deleted file mode 100644 index 54cd61a..0000000 Binary files a/es/sound-library/smooth/smooth_30.wav and /dev/null differ diff --git a/es/sound-library/smooth/smooth_31.wav b/es/sound-library/smooth/smooth_31.wav deleted file mode 100644 index fff43ba..0000000 Binary files a/es/sound-library/smooth/smooth_31.wav and /dev/null differ diff --git a/es/sound-library/smooth/smooth_32.wav b/es/sound-library/smooth/smooth_32.wav deleted file mode 100644 index d5da751..0000000 Binary files a/es/sound-library/smooth/smooth_32.wav and /dev/null differ diff --git a/es/sound-library/smooth/smooth_33.wav b/es/sound-library/smooth/smooth_33.wav deleted file mode 100644 index 0237865..0000000 Binary files a/es/sound-library/smooth/smooth_33.wav and /dev/null differ diff --git a/es/sound-library/smooth/smooth_34.wav b/es/sound-library/smooth/smooth_34.wav deleted file mode 100644 index ac93e30..0000000 Binary files a/es/sound-library/smooth/smooth_34.wav and /dev/null differ diff --git a/es/sound-library/smooth/smooth_35.wav b/es/sound-library/smooth/smooth_35.wav deleted file mode 100644 index 3e9f988..0000000 Binary files a/es/sound-library/smooth/smooth_35.wav and /dev/null differ diff --git a/es/sound-library/smooth/smooth_36.wav b/es/sound-library/smooth/smooth_36.wav deleted file mode 100644 index 7e07e74..0000000 Binary files a/es/sound-library/smooth/smooth_36.wav and /dev/null differ diff --git a/es/sound-library/smooth/smooth_37.wav b/es/sound-library/smooth/smooth_37.wav deleted file mode 100644 index b233703..0000000 Binary files a/es/sound-library/smooth/smooth_37.wav and /dev/null differ diff --git a/es/sound-library/smooth/smooth_38.wav b/es/sound-library/smooth/smooth_38.wav deleted file mode 100644 index 4dfed17..0000000 Binary files a/es/sound-library/smooth/smooth_38.wav and /dev/null differ diff --git a/es/sound-library/smooth/smooth_39.wav b/es/sound-library/smooth/smooth_39.wav deleted file mode 100644 index 960b035..0000000 Binary files a/es/sound-library/smooth/smooth_39.wav and /dev/null differ diff --git a/es/sound-library/smooth/smooth_40.wav b/es/sound-library/smooth/smooth_40.wav deleted file mode 100644 index 8c7a32f..0000000 Binary files a/es/sound-library/smooth/smooth_40.wav and /dev/null differ diff --git a/es/sound-library/smooth/smooth_41.wav b/es/sound-library/smooth/smooth_41.wav deleted file mode 100644 index 5f1cb03..0000000 Binary files a/es/sound-library/smooth/smooth_41.wav and /dev/null differ diff --git a/es/sound-library/smooth/smooth_42.wav b/es/sound-library/smooth/smooth_42.wav deleted file mode 100644 index 0eb0fb9..0000000 Binary files a/es/sound-library/smooth/smooth_42.wav and /dev/null differ diff --git a/es/sound-library/smooth/smooth_43.wav b/es/sound-library/smooth/smooth_43.wav deleted file mode 100644 index 798842c..0000000 Binary files a/es/sound-library/smooth/smooth_43.wav and /dev/null differ diff --git a/es/sound-library/smooth/smooth_44.wav b/es/sound-library/smooth/smooth_44.wav deleted file mode 100644 index 090da48..0000000 Binary files a/es/sound-library/smooth/smooth_44.wav and /dev/null differ diff --git a/es/sound-library/smooth/smooth_45.wav b/es/sound-library/smooth/smooth_45.wav deleted file mode 100644 index c7e1010..0000000 Binary files a/es/sound-library/smooth/smooth_45.wav and /dev/null differ diff --git a/es/sound-library/smooth/smooth_46.wav b/es/sound-library/smooth/smooth_46.wav deleted file mode 100644 index 813d193..0000000 Binary files a/es/sound-library/smooth/smooth_46.wav and /dev/null differ diff --git a/es/sound-library/smooth/smooth_47.wav b/es/sound-library/smooth/smooth_47.wav deleted file mode 100644 index 28bb8c3..0000000 Binary files a/es/sound-library/smooth/smooth_47.wav and /dev/null differ diff --git a/es/sound-library/smooth/smooth_48.wav b/es/sound-library/smooth/smooth_48.wav deleted file mode 100644 index 2055a46..0000000 Binary files a/es/sound-library/smooth/smooth_48.wav and /dev/null differ diff --git a/es/sound-library/smooth/smooth_49.wav b/es/sound-library/smooth/smooth_49.wav deleted file mode 100644 index ffa0192..0000000 Binary files a/es/sound-library/smooth/smooth_49.wav and /dev/null differ diff --git a/es/subaru_ej25.mr b/es/subaru_ej25.mr deleted file mode 100644 index 10b716d..0000000 --- a/es/subaru_ej25.mr +++ /dev/null @@ -1,380 +0,0 @@ -import "engine_sim.mr" - -units units() -constants constants() -impulse_response_library ir_lib() -label cycle(2 * 360 * units.deg) - -private node turbulence_to_flame_speed_ratio { - alias output __out: - function(5.0) - .add_sample(0.0, 1.0 * 3.0) - .add_sample(5.0, 1.0 * 1.5 * 5.0) - .add_sample(10.0, 1.0 * 1.5 * 10.0) - .add_sample(15.0, 1.1 * 1.5 * 15.0) - .add_sample(20.0, 1.25 * 1.5 * 20.0) - .add_sample(25.0, 1.25 * 1.5 * 25.0) - .add_sample(30.0, 1.25 * 1.5 * 30.0) - .add_sample(35.0, 1.25 * 1.5 * 35.0) - .add_sample(40.0, 1.25 * 1.5 * 40.0) - .add_sample(45.0, 1.25 * 1.5 * 45.0); -} - -private node wires { - output wire1: ignition_wire(); - output wire2: ignition_wire(); - output wire3: ignition_wire(); - output wire4: ignition_wire(); -} - -private node ej25_head { - input intake_camshaft; - input exhaust_camshaft; - input chamber_volume: 67 * units.cc; - input intake_runner_volume: 149.6 * units.cc; - input intake_runner_cross_section_area: 1.75 * units.inch * 1.75 * units.inch; - input exhaust_runner_volume: 50.0 * units.cc; - input exhaust_runner_cross_section_area: 1.25 * units.inch * 1.25 * units.inch; - - input flow_attenuation: 1.0; - input lift_scale: 1.0; - input flip_display: false; - alias output __out: head; - - function intake_flow(50 * units.thou) - intake_flow - .add_flow_sample(0 * lift_scale, 0 * flow_attenuation) - .add_flow_sample(50 * lift_scale, 58 * flow_attenuation) - .add_flow_sample(100 * lift_scale, 103 * flow_attenuation) - .add_flow_sample(150 * lift_scale, 156 * flow_attenuation) - .add_flow_sample(200 * lift_scale, 214 * flow_attenuation) - .add_flow_sample(250 * lift_scale, 249 * flow_attenuation) - .add_flow_sample(300 * lift_scale, 268 * flow_attenuation) - .add_flow_sample(350 * lift_scale, 280 * flow_attenuation) - .add_flow_sample(400 * lift_scale, 280 * flow_attenuation) - .add_flow_sample(450 * lift_scale, 281 * flow_attenuation) - - function exhaust_flow(50 * units.thou) - exhaust_flow - .add_flow_sample(0 * lift_scale, 0 * flow_attenuation) - .add_flow_sample(50 * lift_scale, 37 * flow_attenuation) - .add_flow_sample(100 * lift_scale, 72 * flow_attenuation) - .add_flow_sample(150 * lift_scale, 113 * flow_attenuation) - .add_flow_sample(200 * lift_scale, 160 * flow_attenuation) - .add_flow_sample(250 * lift_scale, 196 * flow_attenuation) - .add_flow_sample(300 * lift_scale, 222 * flow_attenuation) - .add_flow_sample(350 * lift_scale, 235 * flow_attenuation) - .add_flow_sample(400 * lift_scale, 245 * flow_attenuation) - .add_flow_sample(450 * lift_scale, 246 * flow_attenuation) - - generic_cylinder_head head( - chamber_volume: chamber_volume, - intake_runner_volume: intake_runner_volume, - intake_runner_cross_section_area: intake_runner_cross_section_area, - exhaust_runner_volume: exhaust_runner_volume, - exhaust_runner_cross_section_area: exhaust_runner_cross_section_area, - - intake_port_flow: intake_flow, - exhaust_port_flow: exhaust_flow, - valvetrain: standard_valvetrain( - intake_camshaft: intake_camshaft, - exhaust_camshaft: exhaust_camshaft - ), - flip_display: flip_display - ) -} - -private node ej25_camshaft { - input lobe_profile; - input intake_lobe_profile: lobe_profile; - input exhaust_lobe_profile: lobe_profile; - input lobe_separation: 114 * units.deg; - input intake_lobe_center: lobe_separation; - input exhaust_lobe_center: lobe_separation; - input advance: 0 * units.deg; - input base_radius: 1.0 * units.inch; - - output intake_cam_0: _intake_cam_0; - output exhaust_cam_0: _exhaust_cam_0; - - output intake_cam_1: _intake_cam_1; - output exhaust_cam_1: _exhaust_cam_1; - - camshaft_parameters params ( - advance: advance, - base_radius: base_radius - ) - - camshaft _intake_cam_0(params, lobe_profile: intake_lobe_profile) - camshaft _exhaust_cam_0(params, lobe_profile: exhaust_lobe_profile) - camshaft _intake_cam_1(params, lobe_profile: intake_lobe_profile) - camshaft _exhaust_cam_1(params, lobe_profile: exhaust_lobe_profile) - - label rot180(180 * units.deg) - label rot360(360 * units.deg) - - _exhaust_cam_0 - .add_lobe(rot360 - exhaust_lobe_center + (0.0 / 4) * cycle) - .add_lobe(rot360 - exhaust_lobe_center + (1.0 / 4) * cycle) - _intake_cam_0 - .add_lobe(rot360 + intake_lobe_center + (0.0 / 4) * cycle) - .add_lobe(rot360 + intake_lobe_center + (1.0 / 4) * cycle) - - _exhaust_cam_1 - .add_lobe(rot360 - exhaust_lobe_center + (2.0 / 4) * cycle) - .add_lobe(rot360 - exhaust_lobe_center + (3.0 / 4) * cycle) - _intake_cam_1 - .add_lobe(rot360 + intake_lobe_center + (2.0 / 4) * cycle) - .add_lobe(rot360 + intake_lobe_center + (3.0 / 4) * cycle) -} - -public node subaru_ej25 { - alias output __out: engine; - - engine engine( - name: "Subaru EJ25", - starter_torque: 70 * units.lb_ft, - starter_speed: 500 * units.rpm, - redline: 6500 * units.rpm, - fuel: fuel( - max_burning_efficiency: 0.9, - turbulence_to_flame_speed_ratio: turbulence_to_flame_speed_ratio() - ), - throttle_gamma: 2.0, - hf_gain: 0.01, - noise: 1.0, - jitter: 0.5, - simulation_frequency: 20000 - ) - - wires wires() - - label stroke(79 * units.mm) - label bore(99.5 * units.mm) - label rod_length(5.142 * units.inch) - label rod_mass(535 * units.g) - label compression_height(1.0 * units.inch) - label crank_mass(9.39 * units.kg) - label flywheel_mass(6.8 * units.kg) - label flywheel_radius(6 * units.inch) - - label crank_moment( - disk_moment_of_inertia(mass: crank_mass, radius: stroke / 2) - ) - label flywheel_moment( - disk_moment_of_inertia(mass: flywheel_mass, radius: flywheel_radius) * 2 - ) - label other_moment( // Moment from cams, pulleys, etc [estimated] - disk_moment_of_inertia(mass: 10 * units.kg, radius: 6.0 * units.cm) - ) - - crankshaft c0( - throw: stroke / 2, - flywheel_mass: flywheel_mass, - mass: crank_mass, - friction_torque: 1.0 * units.lb_ft, - moment_of_inertia: - crank_moment + flywheel_moment + other_moment, - position_x: 0.0, - position_y: 0.0, - tdc: 180 * units.deg - ) - - rod_journal rj0(angle: 0.0 * units.deg) - rod_journal rj1(angle: 180.0 * units.deg) - rod_journal rj2(angle: 0.0 * units.deg) - rod_journal rj3(angle: 180.0 * units.deg) - c0 - .add_rod_journal(rj0) - .add_rod_journal(rj1) - .add_rod_journal(rj2) - .add_rod_journal(rj3) - - piston_parameters piston_params( - mass: (414 + 152) * units.g, // 414 - piston mass, 152 - pin weight - compression_height: compression_height, - wrist_pin_position: 0.0, - displacement: 0.0 - ) - - connecting_rod_parameters cr_params( - mass: rod_mass, - moment_of_inertia: rod_moment_of_inertia( - mass: rod_mass, - length: rod_length - ), - center_of_mass: 0.0, - length: rod_length - ) - - intake intake( - plenum_volume: 1.325 * units.L, - plenum_cross_section_area: 20.0 * units.cm2, - intake_flow_rate: k_carb(400.0), - runner_flow_rate: k_carb(100.0), - runner_length: 12.0 * units.inch, - idle_flow_rate: k_carb(0.0), - idle_throttle_plate_position: 0.9978, - velocity_decay: 1.0 - ) - - exhaust_system_parameters es_params( - outlet_flow_rate: k_carb(1000.0), - primary_tube_length: 40.0 * units.inch, - primary_flow_rate: k_carb(400.0), - velocity_decay: 1.0 - ) - - exhaust_system exhaust0( - es_params, - length: 500 * units.mm, - audio_volume: 0.5 * 0.02, - impulse_response: ir_lib.minimal_muffling_02 - ) - - cylinder_bank_parameters bank_params( - bore: bore, - deck_height: stroke / 2 + rod_length + compression_height - ) - - cylinder_bank b0(bank_params, angle: 90.0 * units.deg) - cylinder_bank b1(bank_params, angle: -90.0 * units.deg) - b0 - .add_cylinder( - piston: piston(piston_params, blowby: k_28inH2O(0.001)), - connecting_rod: connecting_rod(cr_params), - rod_journal: rj0, - intake: intake, - exhaust_system: exhaust0, - ignition_wire: wires.wire1, - primary_length: 2.0 * units.inch, - sound_attenuation: 0.9 - ) - .add_cylinder( - piston: piston(piston_params, blowby: k_28inH2O(0.002)), - connecting_rod: connecting_rod(cr_params), - rod_journal: rj3, - intake: intake, - exhaust_system: exhaust0, - ignition_wire: wires.wire3, - primary_length: 3.0 * units.inch, - sound_attenuation: 1.0 - ) - .set_cylinder_head( - ej25_head( - flip_display: true, - intake_camshaft: camshaft.intake_cam_0, - exhaust_camshaft: camshaft.exhaust_cam_0) - ) - b1 - .add_cylinder( - piston: piston(piston_params, blowby: k_28inH2O(0.001)), - connecting_rod: connecting_rod(cr_params), - rod_journal: rj1, - intake: intake, - exhaust_system: exhaust0, - ignition_wire: wires.wire2, - primary_length: 3.0 * units.inch, - sound_attenuation: 1.1 - ) - .add_cylinder( - piston: piston(piston_params, blowby: k_28inH2O(0.002)), - connecting_rod: connecting_rod(cr_params), - rod_journal: rj2, - intake: intake, - exhaust_system: exhaust0, - ignition_wire: wires.wire4, - primary_length: 5.0 * units.inch, - sound_attenuation: 0.9 - ) - .set_cylinder_head( - ej25_head( - flip_display: false, - intake_camshaft: camshaft.intake_cam_1, - exhaust_camshaft: camshaft.exhaust_cam_1) - ) - - engine - .add_cylinder_bank(b0) - .add_cylinder_bank(b1) - - engine.add_crankshaft(c0) - - harmonic_cam_lobe intake_lobe( - duration_at_50_thou: 232 * units.deg, - gamma: 2.0, - lift: 9.78 * units.mm, - steps: 100 - ) - - harmonic_cam_lobe exhaust_lobe( - duration_at_50_thou: 236 * units.deg, - gamma: 2.0, - lift: 9.60 * units.mm, - steps: 100 - ) - - ej25_camshaft camshaft( - lobe_profile: "N/A", - - intake_lobe_profile: intake_lobe, - exhaust_lobe_profile: exhaust_lobe, - intake_lobe_center: 117 * units.deg, - exhaust_lobe_center: 112 * units.deg, - base_radius: (34.0 / 2) * units.mm - ) - - function timing_curve(1000 * units.rpm) - timing_curve - .add_sample(0000 * units.rpm, 25 * units.deg) - .add_sample(1000 * units.rpm, 25 * units.deg) - .add_sample(2000 * units.rpm, 30 * units.deg) - .add_sample(3000 * units.rpm, 40 * units.deg) - .add_sample(4000 * units.rpm, 40 * units.deg) - - ignition_module ignition_module( - timing_curve: timing_curve, - rev_limit: 6800 * units.rpm, - limiter_duration: 0.16) - ignition_module - .connect_wire(wires.wire1, (0.0 / 4.0) * cycle) - .connect_wire(wires.wire3, (1.0 / 4.0) * cycle) - .connect_wire(wires.wire2, (2.0 / 4.0) * cycle) - .connect_wire(wires.wire4, (3.0 / 4.0) * cycle) - - engine.add_ignition_module(ignition_module) -} - -label car_mass(2700 * units.lb) - -private node impreza { - alias output __out: - vehicle( - mass: 2700 * units.lb, - drag_coefficient: 0.3, - cross_sectional_area: (72 * units.inch) * (56 * units.inch), - diff_ratio: 3.9, - tire_radius: 10 * units.inch, - rolling_resistance: 0.015 * car_mass * 9.81 - ); -} - -private node impreza_transmission { - alias output __out: - transmission( - max_clutch_torque: 300 * units.lb_ft - ) - .add_gear(3.636) - .add_gear(2.375) - .add_gear(1.761) - .add_gear(1.346) - .add_gear(0.971) - .add_gear(0.756); -} - -public node main { - set_engine(subaru_ej25()) - set_vehicle(impreza()) - set_transmission(impreza_transmission()) -} -main() diff --git a/es/test.mr b/es/test.mr deleted file mode 100644 index 9daeafb..0000000 --- a/es/test.mr +++ /dev/null @@ -1 +0,0 @@ -test diff --git a/es/themes/amateur.mr b/es/themes/amateur.mr deleted file mode 100644 index 3c4a92d..0000000 --- a/es/themes/amateur.mr +++ /dev/null @@ -1,31 +0,0 @@ -import "engine_sim.mr" - -unit_names units() -public node use_amateur_theme { - input start_fullscreen: false; - input speed_units: units.mph; - input pressure_units: units.inHg; - input torque_units: units.lb_ft; - input power_units: units.hp; - - set_application_settings( - start_fullscreen: start_fullscreen, - speed_units: speed_units, - pressure_units: pressure_units, - torque_units:torque_units, - power_units: power_units, - - // Default Color Settings - color_background: 0x000000, - color_foreground: 0xFFFFFF, - color_highlight1: 0xFF0000, - color_highlight2: 0xFFFFFF, - color_shadow: 0x000000, - color_pink: 0xFF00FF, - color_red: 0xFF0000, - color_orange: 0xFF8000, - color_yellow: 0xFFFF00, - color_blue: 0x0000FF, - color_green: 0x00FF00 - ) -} diff --git a/es/themes/bubble_gum.mr b/es/themes/bubble_gum.mr deleted file mode 100644 index c6f1e7a..0000000 --- a/es/themes/bubble_gum.mr +++ /dev/null @@ -1,31 +0,0 @@ -import "engine_sim.mr" - -unit_names units() -public node use_bubble_gum_theme { - input start_fullscreen: false; - input speed_units: units.mph; - input pressure_units: units.inHg; - input torque_units: units.lb_ft; - input power_units: units.hp; - - set_application_settings( - start_fullscreen: start_fullscreen, - speed_units: speed_units, - pressure_units: pressure_units, - torque_units:torque_units, - power_units: power_units, - - // Default Color Settings - color_background: 0xF394BE, - color_foreground: 0xFFFFFF, - color_highlight1: 0xfdeaf2, - color_highlight2: 0xFFFFFF, - color_shadow: 0xF394BE, - color_pink: 0xfad4e5, - color_red: 0xf5a9cb, - color_orange: 0xffd086, - color_yellow: 0xffd0c3, - color_blue: 0xcfd2dc, - color_green: 0xd7f7d2 - ) -} diff --git a/es/themes/default.mr b/es/themes/default.mr deleted file mode 100644 index cbf4ecf..0000000 --- a/es/themes/default.mr +++ /dev/null @@ -1,31 +0,0 @@ -import "engine_sim.mr" - -unit_names units() -public node use_default_theme { - input start_fullscreen: false; - input speed_units: units.mph; - input pressure_units: units.inHg; - input torque_units: units.lb_ft; - input power_units: units.hp; - - set_application_settings( - start_fullscreen: start_fullscreen, - speed_units: speed_units, - pressure_units: pressure_units, - torque_units: torque_units, - power_units: power_units, - - // Default Color Settings - color_background: 0x0E1012, - color_foreground: 0xFFFFFF, - color_shadow: 0x0E1012, - color_highlight1: 0xEF4545, - color_highlight2: 0xFFFFFF, - color_pink: 0xF394BE, - color_red: 0xEE4445, - color_orange: 0xF4802A, - color_yellow: 0xFDBD2E, - color_blue: 0x77CEE0, - color_green: 0xBDD869 - ) -} diff --git a/es/themes/minimalistic.mr b/es/themes/minimalistic.mr deleted file mode 100644 index 1af8e87..0000000 --- a/es/themes/minimalistic.mr +++ /dev/null @@ -1,31 +0,0 @@ -import "engine_sim.mr" - -unit_names units() -public node use_minimalistic_theme { - input start_fullscreen: false; - input speed_units: units.mph; - input pressure_units: units.inHg; - input torque_units: units.lb_ft; - input power_units: units.hp; - - set_application_settings( - start_fullscreen: start_fullscreen, - speed_units: speed_units, - pressure_units: pressure_units, - torque_units:torque_units, - power_units: power_units, - - // Default Color Settings - color_background: 0x000000, - color_foreground: 0xFFFFFF, - color_highlight1: 0xFFFFFF, - color_highlight2: 0xFFFFFF, - color_shadow: 0x000000, - color_pink: 0xFFFFFF, - color_red: 0xFFFFFF, - color_orange: 0xFFFFFF, - color_yellow: 0xFFFFFF, - color_blue: 0xFFFFFF, - color_green: 0xFFFFFF - ) -} diff --git a/es/themes/night_vision.mr b/es/themes/night_vision.mr deleted file mode 100644 index a911eda..0000000 --- a/es/themes/night_vision.mr +++ /dev/null @@ -1,32 +0,0 @@ -import "engine_sim.mr" - -unit_names units() -public node use_night_vision_theme { - input start_fullscreen: false; - input speed_units: units.mph; - input pressure_units: units.inHg; - input torque_units: units.lb_ft; - input power_units: units.hp; - input color: 0x4dff68; - - set_application_settings( - start_fullscreen: start_fullscreen, - speed_units: speed_units, - pressure_units: pressure_units, - torque_units:torque_units, - power_units: power_units, - - // Default Color Settings - color_background: 0x000000, - color_foreground: color, - color_highlight1: color, - color_highlight2: color, - color_shadow: 0x000000, - color_pink: color, - color_red: color, - color_orange: color, - color_yellow: color, - color_blue: color, - color_green: color - ) -} diff --git a/es/themes/paper.mr b/es/themes/paper.mr deleted file mode 100644 index b236082..0000000 --- a/es/themes/paper.mr +++ /dev/null @@ -1,32 +0,0 @@ -import "engine_sim.mr" - -unit_names units() -public node use_paper_theme { - input start_fullscreen: false; - input speed_units: units.mph; - input pressure_units: units.inHg; - input torque_units: units.lb_ft; - input power_units: units.hp; - input color: 0x63aaff; - - set_application_settings( - start_fullscreen: start_fullscreen, - speed_units: speed_units, - pressure_units: pressure_units, - torque_units:torque_units, - power_units: power_units, - - // Default Color Settings - color_background: 0xf8f2f0, - color_foreground: color, - color_highlight1: color, - color_highlight2: color, - color_shadow: 0xf8f2f0, - color_pink: color, - color_red: color, - color_orange: color, - color_yellow: color, - color_blue: color, - color_green: color - ) -} diff --git a/es/types/atomic_types.mr b/es/types/atomic_types.mr deleted file mode 100644 index 760d7ef..0000000 --- a/es/types/atomic_types.mr +++ /dev/null @@ -1,75 +0,0 @@ -module { - @name: "Atomic Types" - @author: "ATG (Ange Yaghi)" - @copyright: "Copyright 2022, Ange Yaghi" -} - -// ======================================================== -// Channels -// ======================================================== - -@doc: "Floating-point channel type" -private node float_channel => __engine_sim__float { /* void */ } - -@doc: "String channel type" -private node string_channel => __engine_sim__string { /* void */ } - -@doc: "Integer channel type" -private node int_channel => __engine_sim__int { /* void */ } - -@doc: "Bool channel type" -private node bool_channel => __engine_sim__bool { /* void */ } - -// ======================================================== -// Types -// ======================================================== - -@doc: "Float cast type" -@detail: "Converts anything connected to __in to " - "a float type" -public inline node float { - input __in [::float_channel]: 0.0; - alias output __out [::float_channel]: __in; -} - -@doc: "Integer cast type" -@detail: "Converts anything connected to __in to " - "an integer type" -public inline node int { - input __in [::int_channel]: 0; - alias output __out [::int_channel]: __in; -} - -@doc: "Boolean cast type" -@detail: "Converts anything connected to __in to " - "a boolean type" -public inline node bool { - input __in [::bool_channel]: false; - alias output __out [::bool_channel]: __in; -} - -@doc: "String type" -public inline node string { - input s [::string_channel]: ""; - alias output __out [::string_channel]: s; -} - -// ======================================================== -// Literals -// ======================================================== - -public node literal_string => __engine_sim__literal_string { - alias output __out [::string]; -} - -public node literal_float => __engine_sim__literal_float { - alias output __out [::float]; -} - -public node literal_int => __engine_sim__literal_int { - alias output __out [::int]; -} - -public node literal_bool => __engine_sim__literal_bool { - alias output __out [::bool]; -} diff --git a/es/types/conversions.mr b/es/types/conversions.mr deleted file mode 100644 index d703961..0000000 --- a/es/types/conversions.mr +++ /dev/null @@ -1,25 +0,0 @@ -module { - @name: "Conversions" - @author: "ATG (Ange Yaghi)" - @copyright: "Copyright 2022, Ange Yaghi" -} - -private import "atomic_types.mr" - -// Float conversions -public node int_to_float => __engine_sim__int_to_float { - input __in [int]; - alias output __out [float]; -} - -// String conversions -public node int_to_string => __engine_sim__int_to_string { - input __in [int]; - alias output __out [string]; -} - -// Integer conversions -public node string_to_int => __engine_sim__string_to_int { - input __in [string]; - alias output __out [int]; -} diff --git a/es/types/operations.mr b/es/types/operations.mr deleted file mode 100644 index 223d056..0000000 --- a/es/types/operations.mr +++ /dev/null @@ -1,78 +0,0 @@ -module { - @name: "Operations" - @author: "ATG (Ange Yaghi)" - @copyright: "Copyright 2022, Ange Yaghi" -} - -private import "atomic_types.mr" -private import "conversions.mr" - -// Float operations - -public node float_negate => __engine_sim__float_negate { - input __in [float]; - alias output __out [float]; -} - -public node float_divide => __engine_sim__float_divide { - input __in0 [float]; - input __in1 [float]; - alias output __out [float]; -} - -public node float_multiply => __engine_sim__float_multiply { - input __in0 [float]; - input __in1 [float]; - alias output __out [float]; -} - -public node float_add => __engine_sim__float_add { - input __in0 [float]; - input __in1 [float]; - alias output __out [float]; -} - -public node float_subtract => __engine_sim__float_subtract { - input __in0 [float]; - input __in1 [float]; - alias output __out [float]; -} - -// String operations - -public node string_add => __engine_sim__string_add { - input __in0 [string]; - input __in1 [string]; - alias output __out [string]; -} - -// Int operations - -public node int_add => __engine_sim__int_add { - input __in0 [int]; - input __in1 [int]; - alias output __out [int]; -} - -public node int_mul => __engine_sim__int_multiply { - input __in0 [int]; - input __in1 [int]; - alias output __out [int]; -} - -public node int_sub => __engine_sim__int_subtract { - input __in0 [int]; - input __in1 [int]; - alias output __out [int]; -} - -public node int_div => __engine_sim__int_divide { - input __in0 [int]; - input __in1 [int]; - alias output __out [int]; -} - -public node int_negate => __engine_sim__int_negate { - input __in [int]; - alias output __out [int]; -} diff --git a/es/units.mr b/es/units.mr deleted file mode 100644 index 4e60838..0000000 --- a/es/units.mr +++ /dev/null @@ -1,131 +0,0 @@ -module { - @name: "Units" - @author: "ATG (Ange Yaghi)" - @copyright: "Copyright 2022, Ange Yaghi" -} - -private import "constants.mr" - -private import "../types/atomic_types.mr" -private import "../types/conversions.mr" -private import "../types/operations.mr" - -constants constants() -public node units { - // Force - output N: 1.0; - output lbf: N * 4.44822; - - // Mass - output kg: 1.0; - output g: kg / 1000.0; - - output lb: 0.45359237 * kg; - - // Distance - output m: 1.0; - output cm: m / 100.0; - output mm: m / 1000.0; - output km: m * 1000.0; - - output inch: cm * 2.54; - output foot: inch * 12.0; - output thou: inch / 1000.0; - - output mile: m * 1609.344; - - // Time - output sec: 1.0; - output minute: 60.0 * sec; - output hour: 60.0 * minute; - - // Torque - output Nm: N * m; - output lb_ft: lbf * foot; - - // Volume - output m3: 1.0; - output cc: cm * cm * cm; - output mL: cc; - output L: mL * 1000.0; - output cubic_feet: foot * foot * foot; - output cubic_inches: inch * inch * inch; - output gal: 3.785411784 * L; - - // Molecular - output mol: 1.0; - output kmol: mol / 1000.0; - output mmol: kmol / 1000.0; - output lbmol: mol * 453.59237; - - // Flow-rate - output mol_per_sec: mol / sec; - output scfm: 0.002641 * lbmol / minute; - - // Area - output m2: 1.0; - output cm2: cm * cm; - - // Pressure - output Pa: 1.0; - output kPa: Pa * 1000.0; - output MPa: kPa * 1000.0; - output atm: 101.325 * kPa; - - output psi: lb / (inch * inch); - output psig: psi; - output inHg: Pa * 3386.3886666666713; - output inH2O: inHg * 0.0734824; - - // Temperature - output K: 1.0; - output K0: 273.15; - output C: K; - output F: (5.0 / 9.0) * K; - output F0: -459.67; - - // Energy - output J: 1.0; - output kJ: J * 1000.0; - output MJ: kJ * 1000.0; - - // Angles - output rad: 1.0; - output deg: rad * (constants.pi / 180.0); - - // RPM - output rpm: 0.104719755; - - // Speed - output mph: mile / hour; -} - -public node unit_names { - // Pressure - output inHg: "inHg"; - output mbar: "mbar"; - output millibar: mbar; - output bar: "bar"; - output kPa: "kPa"; - output psi: "psi"; - - // Speed - output mph: "mph"; - output kph: "kph"; - output american: mph; - output murican: american; - output british: mph; - output european: kph; - output euro: european; - - // Torque - output lb_ft: "lb-ft"; - output ft_lb: lb_ft; - output Nm: "Nm"; - - // Power - output hp: "hp"; - output kW: "kW"; - output horsepower: hp; - output kilowatt: kW; -} diff --git a/es/utilities.mr b/es/utilities.mr deleted file mode 100644 index b4da3cf..0000000 --- a/es/utilities.mr +++ /dev/null @@ -1,15 +0,0 @@ -private import "engine_sim.mr" - -node rod_moment_of_inertia { - input mass; - input length; - alias output __moment: - (1 / 12.0) * mass * length * length; -} - -node disk_moment_of_inertia { - input mass; - input radius; - alias output __moment: - (1 / 2.0) * mass * radius * radius; -} diff --git a/es/utilities/utilities.mr b/es/utilities/utilities.mr deleted file mode 100644 index b4da3cf..0000000 --- a/es/utilities/utilities.mr +++ /dev/null @@ -1,15 +0,0 @@ -private import "engine_sim.mr" - -node rod_moment_of_inertia { - input mass; - input length; - alias output __moment: - (1 / 12.0) * mass * length * length; -} - -node disk_moment_of_inertia { - input mass; - input radius; - alias output __moment: - (1 / 2.0) * mass * radius * radius; -} diff --git a/es/v6_60_degree.mr b/es/v6_60_degree.mr deleted file mode 100644 index fedffb8..0000000 --- a/es/v6_60_degree.mr +++ /dev/null @@ -1,6 +0,0 @@ -import "engine_sim.mr" -import "themes/default.mr" -import "engines/atg-video-2/04_60_degree_v6.mr" - -use_default_theme() -main() diff --git a/es/v6_even_fire.mr b/es/v6_even_fire.mr deleted file mode 100644 index c155352..0000000 --- a/es/v6_even_fire.mr +++ /dev/null @@ -1,6 +0,0 @@ -import "engine_sim.mr" -import "themes/default.mr" -import "engines/atg-video-2/06_even_fire_v6.mr" - -use_default_theme() -main() diff --git a/es/v6_odd_fire.mr b/es/v6_odd_fire.mr deleted file mode 100644 index 821fb6b..0000000 --- a/es/v6_odd_fire.mr +++ /dev/null @@ -1,6 +0,0 @@ -import "engine_sim.mr" -import "themes/default.mr" -import "engines/atg-video-2/05_odd_fire_v6.mr" - -use_default_theme() -main() diff --git a/es/v8_engine.mr b/es/v8_engine.mr deleted file mode 100644 index 92c5e36..0000000 --- a/es/v8_engine.mr +++ /dev/null @@ -1,435 +0,0 @@ -import "engine_sim.mr" - -units units() -constants constants() -impulse_response_library ir_lib() -label cycle(2 * 360 * units.deg) - -private node wires { - output wire1: ignition_wire(); - output wire2: ignition_wire(); - output wire3: ignition_wire(); - output wire4: ignition_wire(); - output wire5: ignition_wire(); - output wire6: ignition_wire(); - output wire7: ignition_wire(); - output wire8: ignition_wire(); -} - -private node simple_head { - input intake_camshaft; - input exhaust_camshaft; - input chamber_volume: 65 * units.cc; - input intake_runner_volume: 100 * units.cc; - input intake_runner_cross_section_area: 2.0 * units.inch * 2.0 * units.inch; - input exhaust_runner_volume: 50.0 * units.cc; - input exhaust_runner_cross_section_area: 1.75 * units.inch * 1.75 * units.inch; - input flow_attenuation: 1.0; - input lift_scale: 1.0; - alias output __out: head; - - function intake_flow(50 * units.thou) - intake_flow - .add_flow_sample(0 * lift_scale, 0 * flow_attenuation) - .add_flow_sample(50 * lift_scale, 58 * flow_attenuation) - .add_flow_sample(100 * lift_scale, 103 * flow_attenuation) - .add_flow_sample(150 * lift_scale, 156 * flow_attenuation) - .add_flow_sample(200 * lift_scale, 214 * flow_attenuation) - .add_flow_sample(250 * lift_scale, 249 * flow_attenuation) - .add_flow_sample(300 * lift_scale, 268 * flow_attenuation) - .add_flow_sample(350 * lift_scale, 280 * flow_attenuation) - .add_flow_sample(400 * lift_scale, 280 * flow_attenuation) - .add_flow_sample(450 * lift_scale, 281 * flow_attenuation) - - function exhaust_flow(50 * units.thou) - exhaust_flow - .add_flow_sample(0 * lift_scale, 0 * flow_attenuation) - .add_flow_sample(50 * lift_scale, 37 * flow_attenuation) - .add_flow_sample(100 * lift_scale, 72 * flow_attenuation) - .add_flow_sample(150 * lift_scale, 113 * flow_attenuation) - .add_flow_sample(200 * lift_scale, 160 * flow_attenuation) - .add_flow_sample(250 * lift_scale, 196 * flow_attenuation) - .add_flow_sample(300 * lift_scale, 222 * flow_attenuation) - .add_flow_sample(350 * lift_scale, 235 * flow_attenuation) - .add_flow_sample(400 * lift_scale, 245 * flow_attenuation) - .add_flow_sample(450 * lift_scale, 246 * flow_attenuation) - - generic_cylinder_head head( - chamber_volume: chamber_volume, - intake_runner_volume: intake_runner_volume, - intake_runner_cross_section_area: intake_runner_cross_section_area, - exhaust_runner_volume: exhaust_runner_volume, - exhaust_runner_cross_section_area: exhaust_runner_cross_section_area, - intake_port_flow: intake_flow, - exhaust_port_flow: exhaust_flow, - valvetrain: standard_valvetrain( - intake_camshaft: intake_camshaft, - exhaust_camshaft: exhaust_camshaft - ) - ) -} - -private node simple_camshaft { - input lobe_profile; - input intake_lobe_profile: lobe_profile; - input exhaust_lobe_profile: lobe_profile; - input lobe_separation: 114 * units.deg; - input intake_lobe_center: lobe_separation; - input exhaust_lobe_center: lobe_separation; - input advance: 0 * units.deg; - input base_radius: 0.5 * units.inch; - - output intake_cam_0: _intake_cam_0; - output exhaust_cam_0: _exhaust_cam_0; - output intake_cam_1: _intake_cam_1; - output exhaust_cam_1: _exhaust_cam_1; - - camshaft_parameters params ( - advance: advance, - base_radius: base_radius - ) - - camshaft _intake_cam_0(params, lobe_profile: intake_lobe_profile) - camshaft _exhaust_cam_0(params, lobe_profile: exhaust_lobe_profile) - camshaft _intake_cam_1(params, lobe_profile: intake_lobe_profile) - camshaft _exhaust_cam_1(params, lobe_profile: exhaust_lobe_profile) - - label rot(90 * units.deg) - label rot360(360 * units.deg) - - // 1 5 3 7 4 8 2 6 - _exhaust_cam_0 - .add_lobe(rot360 - exhaust_lobe_center + 0 * rot) // 1 - .add_lobe(rot360 - exhaust_lobe_center + 6 * rot) // 2 - .add_lobe(rot360 - exhaust_lobe_center + 2 * rot) // 3 - .add_lobe(rot360 - exhaust_lobe_center + 4 * rot) // 4 - _intake_cam_0 - .add_lobe(rot360 + intake_lobe_center + 0 * rot) // 1 - .add_lobe(rot360 + intake_lobe_center + 6 * rot) // 2 - .add_lobe(rot360 + intake_lobe_center + 2 * rot) // 3 - .add_lobe(rot360 + intake_lobe_center + 4 * rot) // 4 - - _exhaust_cam_1 - .add_lobe(rot360 - exhaust_lobe_center + 1 * rot) // 5 - .add_lobe(rot360 - exhaust_lobe_center + 7 * rot) // 6 - .add_lobe(rot360 - exhaust_lobe_center + 3 * rot) // 7 - .add_lobe(rot360 - exhaust_lobe_center + 5 * rot) // 8 - _intake_cam_1 - .add_lobe(rot360 + intake_lobe_center + 1 * rot) // 5 - .add_lobe(rot360 + intake_lobe_center + 7 * rot) // 6 - .add_lobe(rot360 + intake_lobe_center + 3 * rot) // 7 - .add_lobe(rot360 + intake_lobe_center + 5 * rot) // 8 -} - -public node simple_v8 { - alias output __out: engine; - - engine engine( - name: "Simple V8", - starter_torque: 200 * units.lb_ft, - starter_speed: 200 * units.rpm, - redline: 6000 * units.rpm, - throttle_gamma: 2.0, - fuel: fuel( - max_burning_efficiency: 1.0, - turbulence_to_flame_speed_ratio: function(5.0) - .add_sample(0.0, 3.0) - .add_sample(5.0, 1.5 * 5.0) - .add_sample(10.0, 1.75 * 10.0) - .add_sample(15.0, 2.0 * 15.0) - .add_sample(20.0, 2.0 * 20.0) - .add_sample(25.0, 2.0 * 25.0) - .add_sample(30.0, 2.0 * 30.0) - .add_sample(35.0, 2.0 * 35.0) - .add_sample(40.0, 2.0 * 40.0) - .add_sample(45.0, 2.0 * 45.0) - ), - hf_gain: 0.01, - noise: 1.0, - jitter: 0.15, - simulation_frequency: 10000 - ) - - wires wires() - - label stroke(90 * units.mm) - label bore(100 * units.mm) - label rod_length(160 * units.mm) - label rod_mass(400 * units.g) - label compression_height(1.2 * units.inch) - label crank_mass(60 * units.lb) - label flywheel_mass(30 * units.lb) - label flywheel_radius(8 * units.inch) - - label crank_moment( - 1.5 * disk_moment_of_inertia(mass: crank_mass, radius: stroke) - ) - label flywheel_moment( - disk_moment_of_inertia(mass: flywheel_mass, radius: flywheel_radius) - ) - label other_moment( // Moment from cams, pulleys, etc [estimated] - disk_moment_of_inertia(mass: 1 * units.kg, radius: 1.0 * units.cm) - ) - - label v_angle(90 * units.deg) - crankshaft c0( - throw: stroke / 2, - flywheel_mass: flywheel_mass, - mass: crank_mass, - friction_torque: 20.0 * units.lb_ft, - moment_of_inertia: - crank_moment + flywheel_moment + other_moment, - position_x: 0.0, - position_y: 0.0, - tdc: 90 * units.deg + (v_angle / 2.0) - ) - - // 1 5 3 7 4 8 2 6 - rod_journal rj0(angle: 0 * units.deg) - rod_journal rj1(angle: 180 * units.deg) - rod_journal rj2(angle: 180 * units.deg) - rod_journal rj3(angle: 0 * units.deg) - c0 - .add_rod_journal(rj0) - .add_rod_journal(rj1) - .add_rod_journal(rj2) - .add_rod_journal(rj3) - - piston_parameters piston_params( - // Simplified piston parameters - mass: 350 * units.g, - compression_height: compression_height, - wrist_pin_position: 0.0, - displacement: 0.0 - ) - - connecting_rod_parameters cr_params( - mass: rod_mass, - moment_of_inertia: rod_moment_of_inertia( - mass: rod_mass, - length: rod_length - ), - center_of_mass: 0.0, - length: rod_length - ) - - intake intake( - plenum_volume: 1.325 * units.L, - plenum_cross_section_area: 20.0 * units.cm2, - intake_flow_rate: k_carb(700.0), - runner_flow_rate: k_carb(100.0), - runner_length: 12.0 * units.inch, - idle_flow_rate: k_carb(0.0), - idle_throttle_plate_position: 0.995, - velocity_decay: 0.5 - ) - - exhaust_system_parameters es_params( - outlet_flow_rate: k_carb(1000.0), - primary_tube_length: 29.0 * units.inch, - primary_flow_rate: k_carb(600.0), - velocity_decay: 0.5 - ) - - exhaust_system exhaust0( - es_params, - audio_volume: 2.0 * 0.1, - length: 100 * units.inch, - impulse_response: ir_lib.mild_exhaust_0_reverb - ) - exhaust_system exhaust1( - es_params, - audio_volume: 2.0 * 0.09, - length: 100 * units.inch, - impulse_response: ir_lib.mild_exhaust_0_reverb - ) - - cylinder_bank_parameters bank_params( - bore: bore, - deck_height: stroke / 2 + rod_length + compression_height - ) - - label spacing(5 * units.inch) - - cylinder_bank b0(bank_params, angle: v_angle / 2.0) - cylinder_bank b1(bank_params, angle: -v_angle / 2.0) - b0 - .add_cylinder( - piston: piston(piston_params, blowby: k_28inH2O(0.0)), - connecting_rod: connecting_rod(cr_params), - rod_journal: rj0, - intake: intake, - exhaust_system: exhaust0, - ignition_wire: wires.wire1, - sound_attenuation: 0.9, - primary_length: 2 * units.cm - ) - .add_cylinder( - piston: piston(piston_params, blowby: k_28inH2O(0.0)), - connecting_rod: connecting_rod(cr_params), - rod_journal: rj1, - intake: intake, - exhaust_system: exhaust0, - ignition_wire: wires.wire2, - sound_attenuation: 0.8, - primary_length: 1 * units.cm - ) - .add_cylinder( - piston: piston(piston_params, blowby: k_28inH2O(0.0)), - connecting_rod: connecting_rod(cr_params), - rod_journal: rj2, - intake: intake, - exhaust_system: exhaust0, - ignition_wire: wires.wire3, - sound_attenuation: 1.1, - primary_length: 3 * units.cm - ) - .add_cylinder( - piston: piston(piston_params, blowby: k_28inH2O(0.0)), - connecting_rod: connecting_rod(cr_params), - rod_journal: rj3, - intake: intake, - exhaust_system: exhaust0, - ignition_wire: wires.wire4, - sound_attenuation: 1.0, - primary_length: 5 * units.cm - ) - .set_cylinder_head( - simple_head( - intake_camshaft: camshaft.intake_cam_0, - exhaust_camshaft: camshaft.exhaust_cam_0 - ) - ) - b1 - .add_cylinder( - piston: piston(piston_params, blowby: k_28inH2O(0.0)), - connecting_rod: connecting_rod(cr_params), - rod_journal: rj0, - intake: intake, - exhaust_system: exhaust1, - ignition_wire: wires.wire5, - sound_attenuation: 1.0, - primary_length: 1 * units.cm - ) - .add_cylinder( - piston: piston(piston_params, blowby: k_28inH2O(0.0)), - connecting_rod: connecting_rod(cr_params), - rod_journal: rj1, - intake: intake, - exhaust_system: exhaust1, - ignition_wire: wires.wire6, - sound_attenuation: 0.8, - primary_length: 5 * units.cm - ) - .add_cylinder( - piston: piston(piston_params, blowby: k_28inH2O(0.0)), - connecting_rod: connecting_rod(cr_params), - rod_journal: rj2, - intake: intake, - exhaust_system: exhaust1, - ignition_wire: wires.wire7, - sound_attenuation: 0.9, - primary_length: 7 * units.cm - ) - .add_cylinder( - piston: piston(piston_params, blowby: k_28inH2O(0.0)), - connecting_rod: connecting_rod(cr_params), - rod_journal: rj3, - intake: intake, - exhaust_system: exhaust1, - ignition_wire: wires.wire8, - sound_attenuation: 0.7, - primary_length: 0 * units.cm - ) - .set_cylinder_head( - simple_head( - intake_camshaft: camshaft.intake_cam_1, - exhaust_camshaft: camshaft.exhaust_cam_1 - ) - ) - - engine - .add_cylinder_bank(b0) - .add_cylinder_bank(b1) - - engine.add_crankshaft(c0) - - harmonic_cam_lobe intake_lobe( - duration_at_50_thou: 230 * units.deg, - gamma: 0.9, - lift: 250 * units.thou, - steps: 256 - ) - - harmonic_cam_lobe exhaust_lobe( - duration_at_50_thou: 230 * units.deg, - gamma: 0.9, - lift: 250 * units.thou, - steps: 256 - ) - - simple_camshaft camshaft( - lobe_profile: "N/A", - intake_lobe_profile: intake_lobe, - exhaust_lobe_profile: exhaust_lobe, - intake_lobe_center: 116 * units.deg, - exhaust_lobe_center: 116 * units.deg, - base_radius: 1.0 * units.inch - ) - - function timing_curve(1000 * units.rpm) - timing_curve - .add_sample(0000 * units.rpm, 12 * units.deg) - .add_sample(1000 * units.rpm, 12 * units.deg) - .add_sample(2000 * units.rpm, 20 * units.deg) - .add_sample(3000 * units.rpm, 30 * units.deg) - .add_sample(4000 * units.rpm, 35 * units.deg) - .add_sample(5000 * units.rpm, 35 * units.deg) - - ignition_module ignition_module( - timing_curve: timing_curve, - rev_limit: 6500 * units.rpm, - limiter_duration: 0.1) - ignition_module - .connect_wire(wires.wire1, 0 * 90 * units.deg) - .connect_wire(wires.wire5, 1 * 90 * units.deg) - .connect_wire(wires.wire3, 2 * 90 * units.deg) - .connect_wire(wires.wire7, 3 * 90 * units.deg) - .connect_wire(wires.wire4, 4 * 90 * units.deg) - .connect_wire(wires.wire8, 5 * 90 * units.deg) - .connect_wire(wires.wire2, 6 * 90 * units.deg) - .connect_wire(wires.wire6, 7 * 90 * units.deg) - - engine.add_ignition_module(ignition_module) -} - -private node simple_vehicle { - alias output __out: - vehicle( - mass: 1614 * units.kg, - drag_coefficient: 0.3, - cross_sectional_area: (72 * units.inch) * (50 * units.inch), - diff_ratio: 3.42, - tire_radius: 10 * units.inch, - rolling_resistance: 200 * units.N - ); -} - -private node simple_transmission { - alias output __out: - transmission( - max_clutch_torque: 500 * units.lb_ft - ) - .add_gear(3.23) - .add_gear(2.19) - .add_gear(1.61) - .add_gear(1.23) - .add_gear(0.97) - .add_gear(0.8); -} - -public node main { - set_engine(simple_v8()) - set_vehicle(simple_vehicle()) - set_transmission(simple_transmission()) -} \ No newline at end of file diff --git a/es/v8_gm_ls.mr b/es/v8_gm_ls.mr deleted file mode 100644 index 8a32f48..0000000 --- a/es/v8_gm_ls.mr +++ /dev/null @@ -1,6 +0,0 @@ -import "engine_sim.mr" -import "themes/default.mr" -import "engines/atg-video-2/07_gm_ls.mr" - -use_default_theme() -main() diff --git a/src/config/CLIMain.cpp b/src/config/CLIMain.cpp index 30a4218..619f542 100644 --- a/src/config/CLIMain.cpp +++ b/src/config/CLIMain.cpp @@ -10,6 +10,7 @@ #include "telemetry/ITelemetryProvider.h" #include "simulation/SimulationLoop.h" #include "simulator/SimulatorFactory.h" +#include "simulator/BridgeSimulator.h" #include "simulator/EngineSimTypes.h" #include "io/IInputProvider.h" #include "input/KeyboardInputProvider.h" @@ -18,6 +19,9 @@ #include "common/ILogging.h" #include "config/ANSIColors.h" +#include "engine-sim/include/simulator.h" +#include "engine-sim/include/units.h" + #include #include #include @@ -40,7 +44,7 @@ namespace { input::IInputProvider* createInputProvider(const SimulationConfig& config, ILogging* logger) { if (config.interactive) { - auto provider = std::make_unique(logger); + auto provider = std::make_unique(logger, config.targetLoad); if (provider->Initialize()) { return provider.release(); } @@ -63,6 +67,30 @@ presentation::IPresentation* createPresentation(const SimulationConfig& config) throw std::runtime_error("Failed to initialize presentation"); } +// Configure dyno in load torque mode if --load is specified. +// hold=false + rotationSpeed=0 = brake-only (velocity-dependent damping). +// m_maxTorque is the load knob — the engine must work against this torque. +// Returns true if dyno was configured, false otherwise. +bool configureLoadTorque(ISimulator* simulator, double loadFraction) { + if (loadFraction <= 0) return false; + + auto* bridgeSim = dynamic_cast(simulator); + if (!bridgeSim) return false; + + Simulator* rawSim = bridgeSim->getInternalSimulator(); + if (!rawSim) return false; + + rawSim->m_dyno.m_enabled = true; + rawSim->m_dyno.m_hold = false; // Brake-only: resists but doesn't drive + const double radPerRpm = 3.14159265358979323846 / 30.0; + rawSim->m_dyno.m_rotationSpeed = 700.0 * radPerRpm; // Idle RPM: no braking below idle + rawSim->m_dyno.m_maxTorque = units::torque(EngineSimDefaults::DYNO_MAX_TORQUE_FT_LBS, units::ft_lb) * loadFraction; + + std::cout << " Load: " << static_cast(loadFraction * 100) + << "% (" << static_cast(loadFraction * EngineSimDefaults::DYNO_MAX_TORQUE_FT_LBS) << " ft*lbs max)" << std::endl; + return true; +} + } // anonymous namespace SimulationConfig CreateSimulationConfig(const CommandLineArgs& args) { @@ -77,7 +105,6 @@ SimulationConfig CreateSimulationConfig(const CommandLineArgs& args) { config.duration = args.duration > 0.0 ? args.duration : config.duration; config.volume = args.silent ? 0.0f : config.volume; config.syncPull = args.syncPull != config.syncPull ? args.syncPull : config.syncPull; - config.targetRPM = args.targetRPM != config.targetRPM ? args.targetRPM : config.targetRPM; config.targetLoad = args.targetLoad != config.targetLoad ? args.targetLoad : config.targetLoad; config.useDefaultEngine = args.useDefaultEngine != config.useDefaultEngine ? args.useDefaultEngine : config.useDefaultEngine; config.preFillMs = (args.preFillMs > 0) ? args.preFillMs : config.preFillMs; @@ -133,6 +160,9 @@ int main(int argc, char* argv[]) { type, scriptPath, assetBasePath, config.engineConfig, cliLogger.get(), telemetry.get()); + // Configure dyno load torque if specified (--load flag) + configureLoadTorque(simulator.get(), config.targetLoad); + // Create strategy via factory - pass telemetry so strategies push diagnostics AudioMode mode = config.syncPull ? AudioMode::SyncPull : AudioMode::Threaded; audioBuffer = IAudioBufferFactory::createBuffer(mode, cliLogger.get(), telemetry.get()); diff --git a/src/config/CLIconfig.cpp b/src/config/CLIconfig.cpp index ffba53e..f4c6e7c 100644 --- a/src/config/CLIconfig.cpp +++ b/src/config/CLIconfig.cpp @@ -22,12 +22,11 @@ std::atomic g_interactiveMode(false); void printUsage(const char* progName) { std::cout << "Engine Simulator CLI v2.0\n"; std::cout << "Usage: " << progName << " [options] \n"; - std::cout << " OR: " << progName << " --script [options] [output.wav]\n\n"; + std::cout << " OR: " << progName << " --script [options] [output.wav]\n\n"; std::cout << "Options:\n"; - std::cout << " --script Path to engine .mr configuration file\n"; - std::cout << " --rpm Target RPM to maintain (default: auto)\n"; - std::cout << " --load <0-100> FIXED throttle load percentage (ignored in interactive mode)\n"; - std::cout << " --interactive Enable interactive keyboard control (overrides --load)\n"; + std::cout << " --script Path to engine config (.mr script or .json preset)\n"; + std::cout << " --load <0-100> Dyno load torque percentage (engine works against this)\n"; + std::cout << " --interactive Enable interactive keyboard control\n"; std::cout << " --play, --play-audio Play audio to speakers in real-time\n"; std::cout << " --duration Duration in seconds (default: 3.0, ignored in interactive)\n"; std::cout << " --output Output WAV file path\n"; @@ -41,9 +40,7 @@ void printUsage(const char* progName) { std::cout << " --synth-latency Synthesizer latency in seconds (default: " << EngineSimDefaults::TARGET_SYNTH_LATENCY << ")\n"; std::cout << " --pre-fill-ms Pre-fill buffer ms for sync-pull mode (default: " << EngineSimDefaults::DEFAULT_PREFILL_MS << ")\n\n"; std::cout << "NOTES:\n"; - std::cout << " --load sets a FIXED throttle for non-interactive mode only\n"; - std::cout << " In interactive mode, use J/K or Up/Down arrows to control load\n"; - std::cout << " Use --rpm for RPM control mode (throttle auto-adjusts)\n"; + std::cout << " --load enables dyno brake mode (physics-driven RPM, not rev limiter)\n"; std::cout << " Default mode is sync-pull (synchronous render in audio callback)\n"; std::cout << " Use --threaded for cursor-chasing circular buffer mode\n"; std::cout << " --sim-freq affects both modes - lower values reduce CPU load\n\n"; @@ -54,12 +51,16 @@ void printUsage(const char* progName) { std::cout << " W Increase throttle\n"; std::cout << " SPACE Apply brake\n"; std::cout << " R Reset to idle\n"; + std::cout << " C Increase dyno load torque\n"; + std::cout << " D Decrease dyno load torque\n"; + std::cout << " E Release dyno (free-revving)\n"; + std::cout << " ] / [ Shift up / shift down\n"; std::cout << " Q/ESC Quit\n\n"; std::cout << "Examples:\n"; - std::cout << " " << progName << " --script v8_engine.mr --rpm 850 --duration 5 --output output.wav\n"; + std::cout << " " << progName << " --script v8_engine.mr --load 50 --interactive --play\n"; std::cout << " " << progName << " --script v8_engine.mr --interactive --play\n"; - std::cout << " " << progName << " --script engine-sim-bridge/engine-sim/assets/main.mr --interactive --output recording.wav\n"; - std::cout << " " << progName << " --default-engine --rpm 2000 --play --output engine.wav\n"; + std::cout << " " << progName << " --script engine-sim-bridge/engine-sim/assets/main.mr --load 30 --duration 5 --output output.wav\n"; + std::cout << " " << progName << " --default-engine --load 75 --play\n"; std::cout << " " << progName << " --default-engine --cranking-volume 2.0 --play # 2x volume during cranking\n"; } @@ -72,8 +73,7 @@ bool parseArguments(int argc, char* argv[], CommandLineArgs& args) { std::string scriptPath; std::string positionalEngineConfig; - app.add_option("--rpm", args.targetRPM, "Target RPM to maintain (default: auto)") ->check(CLI::Range(0.0, 20000.0)); - app.add_option("--load", loadArg, "FIXED throttle load percentage (ignored in interactive mode)") ->check(CLI::Range(0.0, 100.0)); + app.add_option("--load", loadArg, "Dyno load torque percentage (engine works against this)") ->check(CLI::Range(0.0, 100.0)); app.add_option("--output", args.outputWav, "Output WAV file path"); app.add_option("--duration", args.duration, "Duration in seconds (default: 3.0, ignored in interactive)"); app.add_option("--sim-freq", args.simulationFrequency, "Physics Hz (default: " + std::to_string(EngineSimDefaults::SIMULATION_FREQUENCY) + ")") ->check(CLI::Range(EngineSimDefaults::SIMULATION_FREQUENCY / 10, EngineSimDefaults::SIMULATION_FREQUENCY * 10)); @@ -82,7 +82,7 @@ bool parseArguments(int argc, char* argv[], CommandLineArgs& args) { app.add_option("--cranking-volume", args.crankingVolume, "Volume boost during cranking (when ignition ON, RPM < 600, no exhaust flow)") ->default_val(1.0f); app.add_option("output_wav", args.outputWav, "Output WAV file") ->required(false); - auto scriptOpt = app.add_option("--script", scriptPath, "Path to engine .mr configuration file"); + auto scriptOpt = app.add_option("--script", scriptPath, "Path to engine config (.mr script or .json preset)"); auto defaultEngineOpt = app.add_flag("--default-engine", args.useDefaultEngine, "Use default engine from main repo (ignores config file)"); auto engineConfigOpt = app.add_option("engine_config", positionalEngineConfig, "Engine configuration file") ->required(false); @@ -94,7 +94,7 @@ bool parseArguments(int argc, char* argv[], CommandLineArgs& args) { bool threadedFlag = false; bool silentFlag = false; app.add_flag("--play,--play-audio", args.playAudio, "Play audio to speakers in real-time"); - app.add_flag("--interactive", args.interactive, "Enable interactive keyboard control (overrides --load)"); + app.add_flag("--interactive", args.interactive, "Enable interactive keyboard control"); app.add_flag("--threaded", threadedFlag, "Use threaded circular buffer (cursor-chasing) (sync-pull is default)"); app.add_flag("--silent", silentFlag, "Run full audio pipeline at zero volume (for testing)"); app.add_flag("--sine", args.sineMode, "Generate 440Hz sine wave test tone (no engine sim)"); @@ -125,9 +125,7 @@ bool parseArguments(int argc, char* argv[], CommandLineArgs& args) { return false; } - if (args.targetRPM < 0 || args.targetRPM > 20000) return fail("ERROR: RPM must be between 0 and 20000\n"); if (args.targetLoad < -1.0 || args.targetLoad > 1.0) return fail("ERROR: Load must be between 0 and 100\n"); - if (args.targetRPM > 0 && args.targetLoad < 0) args.targetLoad = -1.0; // Auto mode return true; } @@ -149,11 +147,9 @@ void ShowConfigHeader(const SimulationConfig& config, const char* engineAPIVersi } else { std::cout << " Duration: " << config.duration << " seconds\n"; } - if (config.targetRPM > 0) { - std::cout << " Target RPM: " << config.targetRPM << "\n"; - } if (config.targetLoad >= 0) { - std::cout << " Target Load: " << static_cast(config.targetLoad * 100) << "%\n"; + std::cout << " Dyno Load: " << static_cast(config.targetLoad * 100) + << "% (" << static_cast(config.targetLoad * EngineSimDefaults::DYNO_MAX_TORQUE_FT_LBS) << " ft*lbs)\n"; } std::cout << " Interactive: " << (config.interactive ? "Yes" : "No") << "\n"; std::cout << " Audio Playback: " << (config.playAudio ? "Yes" : "No") << "\n"; diff --git a/src/config/CLIconfig.h b/src/config/CLIconfig.h index 2791b66..e08d077 100644 --- a/src/config/CLIconfig.h +++ b/src/config/CLIconfig.h @@ -19,8 +19,7 @@ struct CommandLineArgs { std::string engineConfig; std::string outputWav; double duration = 0.0; // 0-sentinel, resolved by bridge/SimulationConfig - double targetRPM = 0.0; - double targetLoad = -1.0; // -1 means auto (RPM control) + double targetLoad = -1.0; // -1 = no dyno, 0.0-1.0 = load torque fraction bool interactive = false; bool playAudio = false; bool useDefaultEngine = false; diff --git a/src/input/KeyboardInputProvider.cpp b/src/input/KeyboardInputProvider.cpp index 5fe9d91..1b6c1a7 100644 --- a/src/input/KeyboardInputProvider.cpp +++ b/src/input/KeyboardInputProvider.cpp @@ -9,12 +9,14 @@ extern std::atomic g_running; namespace input { -KeyboardInputProvider::KeyboardInputProvider(ILogging* logger) +KeyboardInputProvider::KeyboardInputProvider(ILogging* logger, double initialDynoTorqueScale) : keyboardInput_(nullptr) , throttle_(0.1) , baselineThrottle_(0.1) , ignition_(true) , starterSwitch_(false) + , dynoTorqueScale_(initialDynoTorqueScale) + , gearDelta_(0) , lastKey_(-1) , defaultLogger_(logger ? nullptr : new ConsoleLogger()) , logger_(logger ? logger : defaultLogger_.get()) @@ -63,6 +65,9 @@ EngineInput KeyboardInputProvider::OnUpdateSimulation(double dt) { input.throttle = throttle_; input.ignition = ignition_; input.starterMotor = starterSwitch_; + input.dynoTorqueScale = dynoTorqueScale_; + input.gearDelta = gearDelta_; + gearDelta_ = 0; // Reset after consuming input.shouldContinue = true; return input; } @@ -81,48 +86,63 @@ void KeyboardInputProvider::processKeyPress(int key) { case 27: case 'q': case 'Q': g_running.store(false); break; - case 'w': case 'W': - throttle_ = std::min(1.0, throttle_ + 0.05); - baselineThrottle_ = throttle_; - break; - case ' ': - throttle_ = 0.0; - baselineThrottle_ = 0.0; - break; - case 'r': case 'R': - throttle_ = 0.2; - baselineThrottle_ = throttle_; - break; - case 'a': { + + // ENGINE START + case 'i': case 'I': { static bool ignitionState = true; ignitionState = !ignitionState; ignition_ = ignitionState; logger_->info(LogMask::UI, "Ignition %s", ignitionState ? "enabled" : "disabled"); break; } - case 's': { + case 's': case 'S': { static bool starterState = false; starterState = !starterState; starterSwitch_ = starterState; logger_->info(LogMask::UI, "Starter motor %s", starterState ? "enabled" : "disabled"); break; } - case 65: // UP arrow (macOS) - throttle_ = std::min(1.0, throttle_ + 0.05); - baselineThrottle_ = throttle_; + + // THROTTLE CONTROL + case ' ': + throttle_ = 0.0; + baselineThrottle_ = 0.0; break; - case 66: // DOWN arrow (macOS) - throttle_ = std::max(0.0, throttle_ - 0.05); + case 'r': case 'R': + throttle_ = 0.2; baselineThrottle_ = throttle_; break; - case 'k': case 'K': // Alternative UP + + case 'a': case 'w': case 'W': case 65: // UP arrow (macOS) throttle_ = std::min(1.0, throttle_ + 0.05); baselineThrottle_ = throttle_; break; - case 'j': case 'J': // Alternative DOWN + case 'z': case 'Z': case 66: // DOWN arrow (macOS) throttle_ = std::max(0.0, throttle_ - 0.05); baselineThrottle_ = throttle_; break; + + // Dyno Torque Control + case 'e': // Decrease dyno torque (release traction control) + dynoTorqueScale_ = std::max(0.0, dynoTorqueScale_ - 0.1); + logger_->info(LogMask::UI, "Dyno torque: %.0f%%", dynoTorqueScale_ * 100.0); + break; + case 'd': // Increase dyno torque (apply traction control) + dynoTorqueScale_ = std::min(1.0, dynoTorqueScale_ + 0.1); + logger_->info(LogMask::UI, "Dyno torque: %.0f%%", dynoTorqueScale_ * 100.0); + break; + case 'c': // Full release (free-revving) + dynoTorqueScale_ = 0.0; + logger_->info(LogMask::UI, "Dyno torque: RELEASED (0%%)"); + break; + + // GEAR CONTROL + case ']': // Shift up + gearDelta_ = 1; + break; + case '[': // Shift down + gearDelta_ = -1; + break; } lastKey_ = key; } diff --git a/src/input/KeyboardInputProvider.h b/src/input/KeyboardInputProvider.h index a56b56e..5f92aca 100644 --- a/src/input/KeyboardInputProvider.h +++ b/src/input/KeyboardInputProvider.h @@ -12,7 +12,7 @@ namespace input { class KeyboardInputProvider : public IInputProvider { public: - explicit KeyboardInputProvider(ILogging* logger = nullptr); + explicit KeyboardInputProvider(ILogging* logger = nullptr, double initialDynoTorqueScale = -1.0); ~KeyboardInputProvider() override; bool Initialize() override; @@ -33,6 +33,8 @@ class KeyboardInputProvider : public IInputProvider { double baselineThrottle_; bool ignition_; bool starterSwitch_; + double dynoTorqueScale_; + int gearDelta_; int lastKey_; std::string lastError_; diff --git a/src/presentation/ConsolePresentation.cpp b/src/presentation/ConsolePresentation.cpp index 51470cc..ec2e6a7 100644 --- a/src/presentation/ConsolePresentation.cpp +++ b/src/presentation/ConsolePresentation.cpp @@ -49,6 +49,19 @@ std::string ConsolePresentation::formatEngineState(const EngineState& state) con // Throttle out << "[Throttle: " << std::setw(4) << static_cast(state.throttle * 100) << "%] "; + // Gear + out << "[Gear: " << state.gear << "] "; + + // Dyno load (shown when torque is being applied) + if (state.dynoTorque > 0) { + if (state.dynoTargetRPM > 0) { + out << "[Dyno: " << static_cast(state.dynoTargetRPM) << " RPM " + << static_cast(state.dynoTorque) << " ft*lbs] "; + } else { + out << "[Load: " << static_cast(state.dynoTorque) << " ft*lbs] "; + } + } + // Underruns out << "[Underruns: " << state.underrunCount << "] "; @@ -63,11 +76,10 @@ std::string ConsolePresentation::formatEngineState(const EngineState& state) con out << "[" << state.audioMode << "]" << " req=" << std::setw(3) << state.framesRequested << " got=" << std::setw(3) << state.framesRendered - << " rendered=" << std::setw(5) << std::fixed << std::setprecision(1) << state.renderMs << "ms" - << " headroom=" << std::setw(5) << std::showpos << std::setprecision(1) << state.headroomMs + << " took=" << std::setw(5) << std::fixed << std::setprecision(1) << state.renderMs << "ms" + << " room=" << std::setw(5) << std::showpos << std::setprecision(1) << state.headroomMs << std::noshowpos << "ms" - << " (" << budgetColor << std::setw(3) << std::setprecision(0) - << state.budgetPct << "% of budget" << ANSIColors::RESET << ") "; + << budgetColor << "budget: " << std::setw(3) << std::setprecision(0) << state.budgetPct << "%" << ANSIColors::RESET << " "; } // Callback throughput metrics @@ -83,9 +95,9 @@ std::string ConsolePresentation::formatEngineState(const EngineState& state) con std::string trendColor = ANSIColors::getDispositionColour( state.trendPct >= 0.0, state.trendPct >= -1.0); - out << "[callbacks=" << std::setw(4) << std::fixed << std::setprecision(0) << state.callbackRateHz << "Hz " - << "needed=" << std::setw(5) << std::setprecision(1) << neededKfps << "kfps " - << "generating=" << genColor << std::setw(5) << generatingKfps << "kfps" << ANSIColors::RESET << " " + out << "[calls=" << std::setw(4) << std::fixed << std::setprecision(0) << state.callbackRateHz << "Hz " + << "need" << std::setw(5) << std::setprecision(1) << neededKfps << "kfps " + << "actual=" << genColor << std::setw(5) << generatingKfps << "kfps" << ANSIColors::RESET << " " << "trend=" << trendColor << std::setw(5) << std::showpos << std::setprecision(1) << state.trendPct << std::noshowpos << "%" << ANSIColors::RESET << "]"; } diff --git a/test/mocks/MockInputProvider.h b/test/mocks/MockInputProvider.h index c075134..7a509d4 100644 --- a/test/mocks/MockInputProvider.h +++ b/test/mocks/MockInputProvider.h @@ -57,7 +57,7 @@ class MockInputProvider : public input::IInputProvider { input::EngineInput input; input.throttle = throttle_; input.ignition = ignition_; - input.starterMotor = starterMotor_; + input.starterSwitch = starterMotor_; input.shouldContinue = shouldContinue_; return input; diff --git a/test/smoke/SmokeTestHelper.h b/test/smoke/SmokeTestHelper.h index ee69bc0..100d6a6 100644 --- a/test/smoke/SmokeTestHelper.h +++ b/test/smoke/SmokeTestHelper.h @@ -56,7 +56,14 @@ class SmokeTestHelper { std::string projectRoot = getProjectRoot(); std::string cliPath = getCLIPath(); std::string logFile = projectRoot + "/build/cli_test_" + std::to_string(getpid()) + ".log"; - std::string command = "cd \"" + projectRoot + "\" && \"" + cliPath + "\" " + args + " >> " + logFile + " 2>&1"; + std::string command = "cd \"" + projectRoot + "\" && \"" + cliPath + "\" " + args; + + // Many tests already provide explicit shell redirection in args. + // Avoid appending a second redirection chain to keep command behavior deterministic. + if (args.find('>') == std::string::npos) { + command += " >> \"" + logFile + "\" 2>&1"; + } + return system(command.c_str()); } }; diff --git a/test/smoke/test_default_engine.cpp b/test/smoke/test_default_engine.cpp index 1b3b111..b4c42dc 100644 --- a/test/smoke/test_default_engine.cpp +++ b/test/smoke/test_default_engine.cpp @@ -34,13 +34,13 @@ TEST_F(DefaultEngineSmokeTest, ProducesAudioOutput) { EXPECT_EQ(exitCode, 0) << "CLI failed with exit code " << exitCode; } -TEST_F(DefaultEngineSmokeTest, DefaultEngineWithRPMFlag) { - // Test: Run with --default-engine --rpm 2000 --duration 0.1 --silent +TEST_F(DefaultEngineSmokeTest, DefaultEngineWithLoadFlagHigh) { + // Test: Run with --default-engine --load 75 --duration 0.1 --silent // Expect: Exit code 0, no crash - int result = runCLI("--default-engine --rpm 2000 --duration 0.1 --silent > /dev/null 2>&1"); + int result = runCLI("--default-engine --load 75 --duration 0.1 --silent > /dev/null 2>&1"); int exitCode = WIFEXITED(result) ? WEXITSTATUS(result) : -1; - EXPECT_EQ(exitCode, 0) << "CLI failed with RPM flag. Exit code: " << exitCode; + EXPECT_EQ(exitCode, 0) << "CLI failed with load flag. Exit code: " << exitCode; } TEST_F(DefaultEngineSmokeTest, DefaultEngineWithLoadFlag) { diff --git a/test/smoke/test_path_resolution.cpp b/test/smoke/test_path_resolution.cpp index a278f6a..95a7102 100644 --- a/test/smoke/test_path_resolution.cpp +++ b/test/smoke/test_path_resolution.cpp @@ -54,12 +54,20 @@ TEST_F(PathResolutionSmokeTest, DefaultEnginePathResolves) { // Implementation note: Tests that the hardcoded path "engine-sim-bridge/engine-sim/assets/main.mr" // resolves correctly from project root - int result = runCLI("--default-engine --duration 0.1 --silent > /dev/null 2>&1"); + std::string projectRoot = getProjectRoot(); + std::string defaultEnginePath = "engine-sim-bridge/engine-sim/assets/main.mr"; + std::filesystem::path fullPath = std::filesystem::path(projectRoot) / defaultEnginePath; + + ASSERT_TRUE(std::filesystem::exists(fullPath)) + << "Default engine file not found at: " << fullPath.string(); + + int result = runCLI("--default-engine --duration 0.1 --silent"); int exitCode = WIFEXITED(result) ? WEXITSTATUS(result) : -1; EXPECT_EQ(exitCode, 0) << "Default engine path resolution failed. " << "The hardcoded path 'engine-sim-bridge/engine-sim/assets/main.mr' " - << "could not be resolved from project root."; + << "could not be resolved from project root. " + << "projectRoot=" << projectRoot << ", enginePath=" << fullPath.string(); } // ============================================================================ @@ -76,9 +84,8 @@ TEST_F(PathResolutionSmokeTest, RelativeScriptPathResolves) { // Verify the file exists first std::filesystem::path fullPath = std::filesystem::path(projectRoot) / defaultEnginePath; - if (!std::filesystem::exists(fullPath)) { - GTEST_SKIP() << "Default engine file not found at: " << fullPath.string(); - } + ASSERT_TRUE(std::filesystem::exists(fullPath)) + << "Default engine file not found at: " << fullPath.string(); int result = runCLI("--script " + defaultEnginePath + " --duration 0.1 --silent > /dev/null 2>&1"); int exitCode = WIFEXITED(result) ? WEXITSTATUS(result) : -1; @@ -100,9 +107,8 @@ TEST_F(PathResolutionSmokeTest, AbsoluteScriptPathResolves) { std::filesystem::path fullPath = std::filesystem::path(projectRoot) / defaultEnginePath; // Verify the file exists - if (!std::filesystem::exists(fullPath)) { - GTEST_SKIP() << "Default engine file not found at: " << fullPath.string(); - } + ASSERT_TRUE(std::filesystem::exists(fullPath)) + << "Default engine file not found at: " << fullPath.string(); std::string absolutePath = fullPath.string(); int result = runCLI("--script \"" + absolutePath + "\" --duration 0.1 --silent > /dev/null 2>&1"); @@ -128,9 +134,8 @@ TEST_F(PathResolutionSmokeTest, AssetBasePathDerivedCorrectly) { std::string defaultEnginePath = "engine-sim-bridge/engine-sim/assets/main.mr"; std::filesystem::path fullPath = std::filesystem::path(projectRoot) / defaultEnginePath; - if (!std::filesystem::exists(fullPath)) { - GTEST_SKIP() << "Default engine file not found at: " << fullPath.string(); - } + ASSERT_TRUE(std::filesystem::exists(fullPath)) + << "Default engine file not found at: " << fullPath.string(); // Run the CLI - if asset base path is wrong, impulse responses won't load int result = runCLI("--script " + defaultEnginePath + " --duration 0.1 --silent > /dev/null 2>&1"); @@ -170,9 +175,8 @@ TEST_F(PathResolutionSmokeTest, CurrentDirectoryPathResolves) { std::string defaultEnginePath = "engine-sim-bridge/engine-sim/assets/main.mr"; std::filesystem::path fullPath = std::filesystem::path(projectRoot) / defaultEnginePath; - if (!std::filesystem::exists(fullPath)) { - GTEST_SKIP() << "Default engine file not found at: " << fullPath.string(); - } + ASSERT_TRUE(std::filesystem::exists(fullPath)) + << "Default engine file not found at: " << fullPath.string(); // Change to project root and use ./ chdir(projectRoot.c_str()); diff --git a/test/smoke/test_silent_flag.cpp b/test/smoke/test_silent_flag.cpp index c8ddb5c..9f0bb36 100644 --- a/test/smoke/test_silent_flag.cpp +++ b/test/smoke/test_silent_flag.cpp @@ -53,11 +53,11 @@ TEST_F(SilentFlagTest, SilentModeWithThreaded) { EXPECT_EQ(exitCode, 0) << "CLI failed with --silent --threaded. Exit code: " << exitCode; } -TEST_F(SilentFlagTest, SilentModeWithRPM) { - // Test: Run with --silent --rpm to test silent mode with RPM control +TEST_F(SilentFlagTest, SilentModeWithLoad) { + // Test: Run with --silent --load to test silent mode with dyno load // Expect: No crash - int result = runCLI("--sine --silent --rpm 1000 --duration 0.1 > /dev/null 2>&1"); + int result = runCLI("--sine --silent --load 50 --duration 0.1 > /dev/null 2>&1"); int exitCode = WIFEXITED(result) ? WEXITSTATUS(result) : -1; - EXPECT_EQ(exitCode, 0) << "CLI failed with --silent --rpm. Exit code: " << exitCode; + EXPECT_EQ(exitCode, 0) << "CLI failed with --silent --load. Exit code: " << exitCode; } diff --git a/test/smoke/test_sine_mode.cpp b/test/smoke/test_sine_mode.cpp index 1bff220..6399a00 100644 --- a/test/smoke/test_sine_mode.cpp +++ b/test/smoke/test_sine_mode.cpp @@ -34,11 +34,11 @@ TEST_F(SineModeSmokeTest, ProducesAudioOutput) { EXPECT_EQ(exitCode, 0) << "CLI failed with exit code " << exitCode; } -TEST_F(SineModeSmokeTest, SineModeWithRPMFlag) { - // Test: Run with --sine --rpm 1000 --duration 0.1 --silent +TEST_F(SineModeSmokeTest, SineModeWithLoadFlag) { + // Test: Run with --sine --load 50 --duration 0.1 --silent // Expect: Exit code 0, no crash - int result = runCLI("--sine --rpm 1000 --duration 0.1 --silent > /dev/null 2>&1"); + int result = runCLI("--sine --load 50 --duration 0.1 --silent > /dev/null 2>&1"); int exitCode = WIFEXITED(result) ? WEXITSTATUS(result) : -1; - EXPECT_EQ(exitCode, 0) << "CLI failed with RPM flag. Exit code: " << exitCode; + EXPECT_EQ(exitCode, 0) << "CLI failed with load flag. Exit code: " << exitCode; } diff --git a/vehicle-sim b/vehicle-sim index 6594af5..3ffc2b7 160000 --- a/vehicle-sim +++ b/vehicle-sim @@ -1 +1 @@ -Subproject commit 6594af5a05717f321de510b65f646e7fb2184ea0 +Subproject commit 3ffc2b7bce9bfa38c3c940b3e399ba6e208ece7c